-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The box.internal.sql_function_create is forbidden #879
Comments
Drafted. Waiting for approval. |
@pgulutzan, we need description of this feature to link it from 2.3.1 release notes (to avoid quite big description in the release notes itself). Can you share commit, which handles this issue? I think I can review it from correctness point of view and it should be good enough for now. @artembo, can you help with processes? Where we should land the commit to have it in 2.3 documentation? Will it land also to 2.2 documentation: in other words, should we explicitly mention that it is 2.3-only feature in the text itself? |
@Totktonada, just commit the changes to appropriate branches and it will be delivered to tarantool.io within one hour. CI is set up for 1.6, 1.10, 2.2 and 2.3 branches which correspond the documentation versions on the website. @lenkis, is mentioning version-specific peculiarities required in the documentation text itself? |
@Toktonada: Sorry, all changes that I made in version 2.3 since December 8 have disappeared. I guess that @lenkis has done some moving and restructuring. I will ask her what is going on. |
@Totktonada, Today I recovered and pushed the material into doc branch pgulutzan-2.3 |
@Totktonada, documentation is now pushed, in Calling Lua routines from SQL |
I heard no major complaints soon, so I close this. |
Legacy mechanism box.internal.sql_function_create to make some
Lua function available in SQL is forbidden now.
To make some function available in SQL you need to use
box.schema.func.create() mechanism: you need to specify
are able to define a persistent Lua function)
functions allows to generate more efficient SQL VDBE bytecode
so you better specify it when it is true
a type of value returned by function
function argument types
should be available ('LUA' by default). You need to specify
{'LUA', 'SQL'} to make function available both in SQL requests
and visible in box.func folder
Example:
-- Case1: C function
-- function1.so has int divide() symbol
box.schema.func.create("function1.divide", {language = 'C',
returns = 'number',
param_list = {'number', 'number'},
is_deterministic = true,
exports = {'LUA', 'SQL'}})
box.execute('SELECT "function1.divide"(6, 3)')
type: number
rows:
box.schema.func.drop("function1.divide")
-- Case2: Persistent Lua function
box.schema.func.create("SUMMARIZE", {language = 'LUA',
returns = 'number',
body = 'function (a, b) return a + b end',
param_list = {'number', 'number'},
is_deterministic = true,
exports = {'LUA', 'SQL'}})
box.execute('SELECT summarize(1, 2)')
type: number
rows:
box.schema.func.drop("summarize")
Moreover there is a special predefined Lua function LUA that
allows to evaluate a custom Lua expressions in SQL.
You need to pass a string in form "return ...." to LUA function
that returns more than one value of any type.
Example:
box.execute('SELECT lua('return 1 + 1')')
type: any
rows:
box.execute('SELECT lua('return box.cfg.memtx_memory')')
type: any
rows:
Requested by @kshcherbatov in tarantool/tarantool@d4a7459.
The text was updated successfully, but these errors were encountered: