libsql icon indicating copy to clipboard operation
libsql copied to clipboard

Implement CREATE FUNCTION for dynamic user-defined function creation

Open psarna opened this issue 3 years ago • 0 comments

In order to provide best developer experience, it should be possible to create and register WebAssembly-based user-defined functions right from the CQL interface, without having to recompile libSQL or register it at the higher code layer, e.g. from a driver.

For that purpose, there already exists a CREATE FUNCTION statement and we should consider adding it to libSQL, with WebAssembly as the supported language. In order to be more or less human-readable, this statement could accept function body in WebAssembly text format (.wat), and then compile it locally, or just in the blob form, in case somebody prefers to avoid the recompilation.

Functions created by CREATE FUNCTION could be stored in a system table, 100% cached in memory, where they can be easily inspected and verified.

Then, the existing code paths for looking up SQL functions can be extended to also peek into the table mentioned above.

psarna avatar Oct 05 '22 08:10 psarna