From: Vladimir Davydov <vdavydov.dev@gmail.com> To: Kirill Shcherbatov <kshcherbatov@tarantool.org> Cc: tarantool-patches@freelists.org Subject: Re: [PATCH v4 6/6] box: introduce Lua persistent functions Date: Mon, 24 Jun 2019 15:38:05 +0300 [thread overview] Message-ID: <20190624123805.35oxjrmyhzwro2wd@esperanza> (raw) In-Reply-To: <47082b6bbc04a389a3c82ac27174bcdef81de2ce.1561298197.git.kshcherbatov@tarantool.org> On Sun, Jun 23, 2019 at 04:57:57PM +0300, Kirill Shcherbatov wrote: > diff --git a/src/box/lua/call.c b/src/box/lua/call.c > index f98ab42ac..d3d874477 100644 > --- a/src/box/lua/call.c > +++ b/src/box/lua/call.c > @@ -669,6 +870,22 @@ lbox_func_new(struct lua_State *L, struct func *func) > lua_pushstring(L, "language"); > lua_pushstring(L, func_language_strs[func->def->language]); > lua_settable(L, top); > + lua_pushstring(L, "is_deterministic"); > + lua_pushboolean(L, func->def->is_deterministic); > + lua_settable(L, top); > + if (func->def->body != NULL) { > + lua_pushstring(L, "body"); > + lua_pushstring(L, func->def->body); > + lua_settable(L, top); > + lua_pushstring(L, "is_sandboxed"); > + lua_pushboolean(L, func->def->is_sandboxed); > + lua_settable(L, top); > + } > + if (func->def->comment != NULL) { > + lua_pushstring(L, "comment"); > + lua_pushstring(L, func->def->comment); > + lua_settable(L, top); > + } We must delete 'body' and 'is_sandboxed' in case the function isn't persistent, otherwise it might inherit old values. > diff --git a/src/box/lua/schema.lua b/src/box/lua/schema.lua > index 9c3ee063c..455d1e18a 100644 > --- a/src/box/lua/schema.lua > +++ b/src/box/lua/schema.lua > @@ -2138,7 +2138,10 @@ box.schema.func.create = function(name, opts) > opts = opts or {} > check_param_table(opts, { setuid = 'boolean', > if_not_exists = 'boolean', > - language = 'string'}) > + language = 'string', body = 'string', > + is_deterministic = 'boolean', > + is_sandboxed = 'boolean', opts = 'table', opts = 'table' not needed, apparently. Pushed to master with the following changes: diff --git a/src/box/lua/call.c b/src/box/lua/call.c index d50e23bf..88110c43 100644 --- a/src/box/lua/call.c +++ b/src/box/lua/call.c @@ -868,22 +868,27 @@ lbox_func_new(struct lua_State *L, struct func *func) lua_pushstring(L, "language"); lua_pushstring(L, func_language_strs[func->def->language]); lua_settable(L, top); + lua_pushstring(L, "body"); + if (func->def->body != NULL) + lua_pushstring(L, func->def->body); + else + lua_pushnil(L); + lua_settable(L, top); + lua_pushstring(L, "comment"); + if (func->def->comment != NULL) + lua_pushstring(L, func->def->comment); + else + lua_pushnil(L); + lua_settable(L, top); lua_pushstring(L, "is_deterministic"); lua_pushboolean(L, func->def->is_deterministic); lua_settable(L, top); - if (func->def->body != NULL) { - lua_pushstring(L, "body"); - lua_pushstring(L, func->def->body); - lua_settable(L, top); - lua_pushstring(L, "is_sandboxed"); + lua_pushstring(L, "is_sandboxed"); + if (func->def->body != NULL) lua_pushboolean(L, func->def->is_sandboxed); - lua_settable(L, top); - } - if (func->def->comment != NULL) { - lua_pushstring(L, "comment"); - lua_pushstring(L, func->def->comment); - lua_settable(L, top); - } + else + lua_pushnil(L); + lua_settable(L, top); /* Bless func object. */ lua_getfield(L, LUA_GLOBALSINDEX, "box"); diff --git a/src/box/lua/schema.lua b/src/box/lua/schema.lua index 455d1e18..1ab97440 100644 --- a/src/box/lua/schema.lua +++ b/src/box/lua/schema.lua @@ -2140,8 +2140,8 @@ box.schema.func.create = function(name, opts) if_not_exists = 'boolean', language = 'string', body = 'string', is_deterministic = 'boolean', - is_sandboxed = 'boolean', opts = 'table', - comment = 'string'}) + is_sandboxed = 'boolean', + comment = 'string' }) local _func = box.space[box.schema.FUNC_ID] local _vfunc = box.space[box.schema.VFUNC_ID] local func = _vfunc.index.name:get{name} diff --git a/test/box/function1.result b/test/box/function1.result index 969798ea..7bea2d64 100644 --- a/test/box/function1.result +++ b/test/box/function1.result @@ -448,7 +448,6 @@ func - is_deterministic: false id: 2 setuid: false - comment: Divide two values name: function1.divide language: C ...
next prev parent reply other threads:[~2019-06-24 12:38 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-06-23 13:57 [PATCH v4 0/6] box: rework functions machinery Kirill Shcherbatov 2019-06-23 13:57 ` [PATCH v4 1/6] box: rework func cache update machinery Kirill Shcherbatov 2019-06-24 10:22 ` Vladimir Davydov 2019-06-23 13:57 ` [PATCH v4 2/6] box: rework box_lua_{call, eval} to use input port Kirill Shcherbatov 2019-06-24 10:23 ` Vladimir Davydov 2019-06-23 13:57 ` [PATCH v4 3/6] box: rework func object as a function frontend Kirill Shcherbatov 2019-06-24 10:23 ` Vladimir Davydov 2019-06-23 13:57 ` [PATCH v4 4/6] box: export registered functions in box.func folder Kirill Shcherbatov 2019-06-24 10:25 ` Vladimir Davydov 2019-06-23 13:57 ` [PATCH v4 5/6] box: refactor box_lua_find helper Kirill Shcherbatov 2019-06-24 12:35 ` Vladimir Davydov 2019-06-23 13:57 ` [PATCH v4 6/6] box: introduce Lua persistent functions Kirill Shcherbatov 2019-06-24 12:38 ` Vladimir Davydov [this message] 2019-06-25 8:22 ` [tarantool-patches] " Konstantin Osipov
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20190624123805.35oxjrmyhzwro2wd@esperanza \ --to=vdavydov.dev@gmail.com \ --cc=kshcherbatov@tarantool.org \ --cc=tarantool-patches@freelists.org \ --subject='Re: [PATCH v4 6/6] box: introduce Lua persistent functions' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox