From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> To: Sergey Bronnikov <sergeyb@tarantool.org>, avtikhon@tarantool.org, alexander.turenko@tarantool.org, o.piskunov@tarantool.org, tarantool-patches@dev.tarantool.org Subject: [Tarantool-patches] [PATCH v3 7/6] schema: fix index promotion to functional index Date: Wed, 15 Apr 2020 01:30:39 +0200 [thread overview] Message-ID: <9cbf485c-4612-4514-a2b5-782eee81b26c@tarantool.org> (raw) In-Reply-To: <cover.1586849129.git.sergeyb@tarantool.org> When index:alter() was called on a non-functional index with specified 'func', it led to accessing a not declared variable in schema.lua. diff --git a/src/box/lua/schema.lua b/src/box/lua/schema.lua index 545abe714..ad4a5470b 100644 --- a/src/box/lua/schema.lua +++ b/src/box/lua/schema.lua @@ -1210,7 +1210,7 @@ box.schema.index.alter = function(space_id, index_id, options) index_opts, parts} if index_opts.func ~= nil then local _func_index = box.space[box.schema.FUNC_INDEX_ID] - _func_index:insert{space_id, iid, index_opts.func} + _func_index:insert{space_id, index_id, index_opts.func} end space_sequence_alter_commit(sequence_proxy) end diff --git a/test/engine/func_index.result b/test/engine/func_index.result index a827c929f..dfa609ce8 100644 --- a/test/engine/func_index.result +++ b/test/engine/func_index.result @@ -847,3 +847,42 @@ s:drop() box.func.extr:drop() | --- | ... + +-- +-- Function is added at alter. +-- +s = box.schema.space.create('withdata', {engine = engine}) + | --- + | ... +lua_code = [[function(tuple) return {tuple[2] >= 0 and tuple[2] or -tuple[2]} end]] + | --- + | ... +box.schema.func.create('second_field_module', {body = lua_code, is_deterministic = true, is_sandboxed = true}) + | --- + | ... +pk = s:create_index('pk') + | --- + | ... +sk = s:create_index('sk', {parts = {{2, 'unsigned'}}}) + | --- + | ... +sk:alter({func = 'second_field_module', parts = {{1, 'unsigned'}}}) + | --- + | ... +s:insert({1, -3}) + | --- + | - [1, -3] + | ... +sk:get{3} + | --- + | - [1, -3] + | ... +s:drop() + | --- + | ... +box.schema.func.drop('second_field_module') + | --- + | ... diff --git a/test/engine/func_index.test.lua b/test/engine/func_index.test.lua index 5db588c1f..98df886f4 100644 --- a/test/engine/func_index.test.lua +++ b/test/engine/func_index.test.lua @@ -294,3 +294,18 @@ idx:get({3}) s:drop() box.func.extr:drop() + +-- +-- Function is added at alter. +-- +s = box.schema.space.create('withdata', {engine = engine}) +lua_code = [[function(tuple) return {tuple[2] >= 0 and tuple[2] or -tuple[2]} end]] +box.schema.func.create('second_field_module', {body = lua_code, is_deterministic = true, is_sandboxed = true}) +pk = s:create_index('pk') +sk = s:create_index('sk', {parts = {{2, 'unsigned'}}}) +sk:alter({func = 'second_field_module', parts = {{1, 'unsigned'}}}) +s:insert({1, -3}) +sk:get{3} +s:drop() +box.schema.func.drop('second_field_module')
next prev parent reply other threads:[~2020-04-14 23:30 UTC|newest] Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-04-14 7:55 [Tarantool-patches] [PATCH v3 0/6] Add static analysis with luacheck Sergey Bronnikov 2020-04-14 7:56 ` [Tarantool-patches] [PATCH 1/6] Fix luacheck warnings in src/lua/ Sergey Bronnikov 2020-04-14 23:29 ` Vladislav Shpilevoy 2020-04-15 20:51 ` Igor Munkin 2020-04-15 21:40 ` Vladislav Shpilevoy 2020-04-17 9:07 ` Sergey Bronnikov 2020-04-17 9:09 ` Sergey Bronnikov 2020-04-15 20:51 ` Igor Munkin 2020-04-15 21:46 ` Vladislav Shpilevoy 2020-04-16 13:52 ` Igor Munkin 2020-04-17 9:26 ` Sergey Bronnikov 2020-04-17 12:13 ` Igor Munkin 2020-04-14 7:57 ` [Tarantool-patches] [PATCH 2/6] Fix luacheck warnings in test/ Sergey Bronnikov 2020-04-14 23:29 ` Vladislav Shpilevoy 2020-04-17 12:05 ` Igor Munkin 2020-04-17 19:51 ` Sergey Bronnikov 2020-04-17 19:47 ` Sergey Bronnikov 2020-04-16 13:43 ` Igor Munkin 2020-04-14 7:57 ` [Tarantool-patches] [PATCH 3/6] Fix luacheck warnings in src/box/lua/ Sergey Bronnikov 2020-04-14 23:30 ` Vladislav Shpilevoy 2020-04-14 7:58 ` [Tarantool-patches] [PATCH 4/6] Fix luacheck warnings in extra/dist/tarantoolctl.in Sergey Bronnikov 2020-04-14 23:30 ` Vladislav Shpilevoy 2020-04-15 15:35 ` Igor Munkin 2020-04-14 8:01 ` [Tarantool-patches] [PATCH 5/6] Add luacheck config Sergey Bronnikov 2020-04-14 23:30 ` Vladislav Shpilevoy 2020-04-14 8:01 ` [Tarantool-patches] [PATCH 6/6] gitlab-ci: enable static analysis with luacheck Sergey Bronnikov 2020-04-14 23:30 ` Vladislav Shpilevoy [this message] 2020-04-14 23:30 ` [Tarantool-patches] [PATCH v3 8/6] schema: fix internal symbols dangling in _G Vladislav Shpilevoy
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=9cbf485c-4612-4514-a2b5-782eee81b26c@tarantool.org \ --to=v.shpilevoy@tarantool.org \ --cc=alexander.turenko@tarantool.org \ --cc=avtikhon@tarantool.org \ --cc=o.piskunov@tarantool.org \ --cc=sergeyb@tarantool.org \ --cc=tarantool-patches@dev.tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH v3 7/6] schema: fix index promotion to functional index' \ /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