From: Vladimir Davydov <vdavydov.dev@gmail.com> To: tarantool-patches@freelists.org Subject: [PATCH] schema: fix box.func cleanup after a function is dropped Date: Mon, 1 Jul 2019 14:19:24 +0300 [thread overview] Message-ID: <123c5aa5e061478e53a7c6b35cb82bff9bd78239.1561979892.git.vdavydov.dev@gmail.com> (raw) Fixes commit abf5ef4fead9 ("box: export registered functions in box.func folder"). --- src/box/lua/call.c | 2 +- src/box/schema.h | 30 +++++++++++++++--------------- test/box/function1.result | 16 ++++++++++++++++ test/box/function1.test.lua | 4 ++++ 4 files changed, 36 insertions(+), 16 deletions(-) diff --git a/src/box/lua/call.c b/src/box/lua/call.c index a236325b..38f2f696 100644 --- a/src/box/lua/call.c +++ b/src/box/lua/call.c @@ -712,7 +712,7 @@ lbox_func_new_or_delete(struct trigger *trigger, void *event) { struct lua_State *L = (struct lua_State *) trigger->data; struct func *func = (struct func *)event; - if (func != NULL) + if (func_by_id(func->def->fid) != NULL) lbox_func_new(L, func); else lbox_func_delete(L, func); diff --git a/src/box/schema.h b/src/box/schema.h index f0039b29..30366382 100644 --- a/src/box/schema.h +++ b/src/box/schema.h @@ -41,6 +41,8 @@ extern "C" { #endif /* defined(__cplusplus) */ +struct func; + extern uint32_t schema_version; extern uint32_t space_cache_version; @@ -89,6 +91,19 @@ space_cache_find(uint32_t id) return NULL; } +/** + * Insert a new function object in the function cache. + * @param func Function object to insert. + */ +void +func_cache_insert(struct func *func); + +void +func_cache_delete(uint32_t fid); + +struct func * +func_by_id(uint32_t fid); + struct func * func_by_name(const char *name, uint32_t name_len); @@ -162,21 +177,6 @@ schema_free(); struct space *schema_space(uint32_t id); -/** - * Insert a new function object in the function cache. - * @param func Function object to insert. - */ -void -func_cache_insert(struct func *func); - -void -func_cache_delete(uint32_t fid); - -struct func; - -struct func * -func_by_id(uint32_t fid); - static inline struct func * func_cache_find(uint32_t fid) { diff --git a/test/box/function1.result b/test/box/function1.result index 99006926..439e19e9 100644 --- a/test/box/function1.result +++ b/test/box/function1.result @@ -79,6 +79,10 @@ box.func["function1.args"]:call({ 15 }) box.schema.func.drop("function1.args") --- ... +box.func["function1.args"] +--- +- null +... box.schema.func.create('function1.multi_inc', {language = "C"}) --- ... @@ -377,6 +381,10 @@ func.drop() --- - error: 'builtin/box/schema.lua: Use func:drop(...) instead of func.drop(...)' ... +box.func.divide +--- +- null +... func:drop() --- - error: Function 'divide' does not exist @@ -422,6 +430,10 @@ func:call({4, 2, 1}) func:drop() --- ... +box.func["function1.divide"] +--- +- null +... func --- - language: C @@ -471,6 +483,10 @@ func:call({{1, 2, 99, 3, -1}}) func:drop() --- ... +box.func.minmax +--- +- null +... -- Test access checks for registered functions. function secret() return 1 end --- diff --git a/test/box/function1.test.lua b/test/box/function1.test.lua index 25966b91..4ec9c04a 100644 --- a/test/box/function1.test.lua +++ b/test/box/function1.test.lua @@ -26,6 +26,7 @@ box.func["function1.args"]:call() box.func["function1.args"]:call({ "xx" }) box.func["function1.args"]:call({ 15 }) box.schema.func.drop("function1.args") +box.func["function1.args"] box.schema.func.create('function1.multi_inc', {language = "C"}) box.schema.user.grant('guest', 'execute', 'function', 'function1.multi_inc') @@ -132,6 +133,7 @@ func:call({4, 2, 1}) func:drop() func func.drop() +box.func.divide func:drop() func:call({4, 2}) box.internal.func_call('divide', 4, 2) @@ -145,6 +147,7 @@ func:call({4}) func:call({4, 2}) func:call({4, 2, 1}) func:drop() +box.func["function1.divide"] func func:drop() func:call({4, 2}) @@ -165,6 +168,7 @@ box.schema.func.create("minmax") func = box.func.minmax func:call({{1, 2, 99, 3, -1}}) func:drop() +box.func.minmax -- Test access checks for registered functions. function secret() return 1 end -- 2.11.0
next reply other threads:[~2019-07-01 11:19 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-07-01 11:19 Vladimir Davydov [this message] 2019-07-01 11:19 ` Vladimir Davydov
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=123c5aa5e061478e53a7c6b35cb82bff9bd78239.1561979892.git.vdavydov.dev@gmail.com \ --to=vdavydov.dev@gmail.com \ --cc=tarantool-patches@freelists.org \ --subject='Re: [PATCH] schema: fix box.func cleanup after a function is dropped' \ /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