Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions docs/install-js-lang.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Install js_lang component

--8<--- "experimental.md"
--8<--- "tech.preview.md:5:5"

The `plugin_dir` system variable specifies where the component library is located. If you need to, you should set the `plugin_dir` variable when you start the server.

Expand All @@ -14,4 +14,12 @@ If you decide to uninstall the component, you may have to restart the server bef

When you install the `component_js_lang`, it gives you a new global privilege called `CREATE_JS_ROUTINE`. This privilege allows you to create JS routines within the database.

For more details, check out [INSTALL COMPONENT](install-component.md).
For more details, check out [INSTALL COMPONENT](install-component.md).

## Further reading

- [js_lang stored procedure and function overview](js-lang-overview.md)
- [Uninstall the js_lang component](uninstall-js-lang.md)
- [js_lang stored function or procedure](js-lang-procedures.md)
- [js_lang privileges](js-lang-privileges.md)
- [Troubleshoot js_lang procedures and functions](js-lang-troubleshoot.md)
30 changes: 19 additions & 11 deletions docs/js-lang-overview.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# JS stored procedure and function overview
# js_lang stored procedure and function overview

--8<--- "experimental.md"
--8<--- "tech.preview.md:5:5"

Integrating stored procedures and functions in JS within a MySQL-compatible database provides a versatile and practical approach to managing complex data processing tasks. This method significantly enhances performance, allowing developers to execute intricate operations more efficiently. For those proficient in JS, this approach streamlines the development process, reducing the load on client applications and optimizing overall system performance. By employing stored procedures and functions, developers achieve faster data processing and facilitate more manageable maintenance and scalability, making it an ideal solution for those skilled in JS.
You can use stored procedures and functions written in JS with a MySQL-compatible database. This feature helps you manage complex data processing tasks. This method improves performance. This method lets developers run complex operations faster. If you know JS, you can use your existing skills. Using stored procedures and functions reduces the work done by client applications. Using stored procedures and functions also improves overall system performance. Using stored procedures and functions helps developers process data faster. Using stored procedures and functions also makes maintenance and scaling easier. This approach is a good solution for developers who know JS.

| Benefit | Description |
|------------------------------------|-----------------------------------------------------------------------------------------------|
| Familiarity | Developers who are already proficient in JS can leverage their existing skills. |
| Efficiency | JS allows for more efficient execution of complex data processing tasks. |
| Performance | Stored procedures and functions in JS can enhance database performance by reducing client load.|
| Reusability | Encapsulated logic in stored procedures and functions can be reused across multiple applications.|
| Scalability | Facilitates easier maintenance and scalability of database operations. |
| Simplified Development Process | Streamlines the development process, making it more manageable for those skilled in JS. |
| Integration with Client Applications| Seamless integration with client applications, reducing the need for additional processing. |
| Optimization | Optimizes overall system performance through efficient data processing. |
| Familiarity | Developers who already know JS can use their existing skills. |
| Efficiency | JS can run complex data processing tasks more efficiently. |
| Performance | Stored procedures and functions in JS improve database performance. They reduce the work done by client applications.|
| Reusability | You can write code once in stored procedures and functions. Then you can use that code in multiple applications.|
| Scalability | Using stored procedures and functions makes database operations easier to maintain and scale. |
| Simplified Development Process | This feature makes development easier for developers who know JS. |
| Integration with Client Applications| Stored procedures and functions work well with client applications. You need less additional processing.|
| Optimization | This feature improves overall system performance through efficient data processing. |


## Limitations
Expand Down Expand Up @@ -73,3 +73,11 @@ The system always maps JS null and undefined values to SQL NULL, regardless of t
| `SET` | - Numbers: stored as integers/doubles<br>- BigInts: stored as integers<br>- Others: converted to strings with charset conversion if needed | Tries native storage before falling back to strings | `1` → `1`<br>`"value"` → `"value"` |
| `GEOMETRY` | - Valid `ArrayBuffer`/`View`: stored as binary<br>- Others: cause an error | Enforces format rules to maintain spatial integrity | valid buffer → `GEOMETRY` |
| `JSON` | Converted using `JSON.stringify()` | Converts objects or arrays to serialized strings | `{key: "value"}` → `"{"key":"value"}"` |

## Further reading

- [Install js_lang component](install-js-lang.md)
- [Uninstall the js_lang component](uninstall-js-lang.md)
- [js_lang stored function or procedure](js-lang-procedures.md)
- [js_lang privileges](js-lang-privileges.md)
- [Troubleshoot js_lang procedures and functions](js-lang-troubleshoot.md)
14 changes: 11 additions & 3 deletions docs/js-lang-privileges.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# JS privileges
# js_lang privileges

--8<--- "experimental.md"
--8<--- "tech.preview.md:5:5"

Privileges control what users can do. You use them to give specific permissions to different users. This ability helps you keep your data secure by only allowing authorized users to access and change information in the database.

Expand All @@ -14,4 +14,12 @@ mysql> GRANT CREATE_JS_ROUTINE ON *.* TO user1@localhost;

If a user is granted the ability to create routines and holds the CREATE_JS_ROUTINE privilege, they are capable of creating stored functions and procedures using JS.

However, it is important to note that at this time, the creation of JS triggers or events is not supported.
However, it is important to note that at this time, the creation of JS triggers or events is not supported.

## Further reading

- [js_lang stored procedure and function overview](js-lang-overview.md)
- [Install js_lang component](install-js-lang.md)
- [Uninstall the js_lang component](uninstall-js-lang.md)
- [js_lang stored function or procedure](js-lang-procedures.md)
- [Troubleshoot js_lang procedures and functions](js-lang-troubleshoot.md)
12 changes: 10 additions & 2 deletions docs/js-lang-procedures.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# JS stored function or procedure
# js_lang stored function or procedure

--8<--- "experimental.md"
--8<--- "tech.preview.md:5:5"

Once the component's installed, you can write stored functions and procedures in JavaScript. The syntax looks like this:

Expand Down Expand Up @@ -34,3 +34,11 @@ $$

You can modify or delete stored programs in JS by using the standard `ALTER PROCEDURE/FUNCTION` and `DROP PROCEDURE/FUNCTION` statements. These statements do not require the `CREATE_JS_ROUTINE` privilege.

## Further reading

- [js_lang stored procedure and function overview](js-lang-overview.md)
- [Install js_lang component](install-js-lang.md)
- [Uninstall the js_lang component](uninstall-js-lang.md)
- [js_lang privileges](js-lang-privileges.md)
- [Troubleshoot js_lang procedures and functions](js-lang-troubleshoot.md)

14 changes: 11 additions & 3 deletions docs/js-lang-troubleshoot.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Troubleshoot JS procedures and functions
# Troubleshoot js_lang procedures and functions

--8<--- "experimental.md"
--8<--- "tech.preview.md:5:5"

The component includes a set of User-Defined Functions (UDFs) that retrieve and clear information about the last JS error that occurred in the current connection for the current user. This information updates each time a JS error occurs for the current connection and user. Successful execution of JS code does not change this state.

Expand All @@ -16,4 +16,12 @@ To terminate a connection or statement executing a JS routine, you can take imme

This functionality is crucial for managing and controlling the execution of routines, ensuring that any unintended or potentially harmful operations can be swiftly terminated to maintain the stability and performance of the database environment.

If the `MAX_EXECUTION_TIME` timeout is exceeded for a statement running a JS routine, the execution aborts execution without much delay. You can use this option to limit the execution time of a JS routine that's performing a long computation.
If the `MAX_EXECUTION_TIME` timeout is exceeded for a statement running a JS routine, the execution aborts execution without much delay. You can use this option to limit the execution time of a JS routine that's performing a long computation.

## Further reading

- [js_lang stored procedure and function overview](js-lang-overview.md)
- [Install js_lang component](install-js-lang.md)
- [Uninstall the js_lang component](uninstall-js-lang.md)
- [js_lang stored function or procedure](js-lang-procedures.md)
- [js_lang privileges](js-lang-privileges.md)
12 changes: 11 additions & 1 deletion docs/uninstall-js-lang.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
# Uninstall the js_lang component

--8<--- "tech.preview.md:5:5"

The uninstall works only when no connections are using JavaScript stored programs. If there are connections, the procedure fails with an error.

To remove the component, run the following:

```{.bash data-prompt="mysql>"}
mysql> UNINSTALL COMPONENT 'file://component_js_lang';
```
```

## Further reading

- [js_lang stored procedure and function overview](js-lang-overview.md)
- [Install js_lang component](install-js-lang.md)
- [js_lang stored function or procedure](js-lang-procedures.md)
- [js_lang privileges](js-lang-privileges.md)
- [Troubleshoot js_lang procedures and functions](js-lang-troubleshoot.md)
2 changes: 1 addition & 1 deletion mkdocs-base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ nav:
- binlog-space.md
- extended-select-into-outfile.md
- innodb-expanded-fast-index-creation.md
- JS language support:
- js-lang language support:
- js-lang-overview.md
- install-js-lang.md
- js-lang-privileges.md
Expand Down