From: sergeyb@tarantool.org To: tarantool-patches@dev.tarantool.org, imun@tarantool.org, v.shpilevoy@tarantool.org Cc: o.piskunov@tarantool.org Subject: [Tarantool-patches] [PATCH v4 7/10] schema: fix index promotion to functional index Date: Tue, 21 Apr 2020 17:00:24 +0300 [thread overview] Message-ID: <0b86996f4cac3e620137abf271a43bde499e5334.1587476678.git.sergeyb@tarantool.org> (raw) In-Reply-To: <cover.1587476678.git.sergeyb@tarantool.org> From: Vladislav Shpilevoy <v.shpilevoy@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. --- src/box/lua/schema.lua | 2 +- test/engine/func_index.result | 36 +++++++++++++++++++++++++++++++++ test/engine/func_index.test.lua | 14 +++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/src/box/lua/schema.lua b/src/box/lua/schema.lua index de47b807e..0beb66510 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..8e7767dce 100644 --- a/test/engine/func_index.result +++ b/test/engine/func_index.result @@ -847,3 +847,39 @@ 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..3b48bb478 100644 --- a/test/engine/func_index.test.lua +++ b/test/engine/func_index.test.lua @@ -294,3 +294,17 @@ 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') -- 2.23.0
next prev parent reply other threads:[~2020-04-21 14:02 UTC|newest] Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-04-21 14:00 [Tarantool-patches] [PATCH v4 0/10] Add static analysis with luacheck sergeyb 2020-04-21 14:00 ` [Tarantool-patches] [PATCH v4 1/10] Add initial luacheck config sergeyb 2020-04-21 14:00 ` [Tarantool-patches] [PATCH v4 2/10] gitlab-ci: enable static analysis with luacheck sergeyb 2020-04-21 20:04 ` Alexander Tikhonov 2020-04-22 8:09 ` Sergey Bronnikov 2020-04-22 8:11 ` Kirill Yukhin 2020-04-21 14:00 ` [Tarantool-patches] [PATCH v4 3/10] Fix luacheck warnings in extra/dist/tarantoolctl.in sergeyb 2020-04-23 11:40 ` Igor Munkin 2020-04-24 8:02 ` Sergey Bronnikov 2020-04-21 14:00 ` [Tarantool-patches] [PATCH v4 4/10] Fix luacheck warnings in src/lua/ sergeyb 2020-04-23 14:13 ` Igor Munkin 2020-04-24 9:12 ` Sergey Bronnikov 2020-04-21 14:00 ` [Tarantool-patches] [PATCH v4 5/10] Fix luacheck warnings in src/box/lua/ sergeyb 2020-04-23 22:54 ` Igor Munkin 2020-05-07 10:32 ` Sergey Bronnikov 2020-05-07 14:34 ` Sergey Bronnikov 2020-05-07 10:52 ` Sergey Bronnikov 2020-04-21 14:00 ` [Tarantool-patches] [PATCH v4 6/10] Fix luacheck warnings in test/ sergeyb 2020-04-27 14:38 ` Igor Munkin 2020-05-06 16:16 ` Sergey Bronnikov 2020-04-21 14:00 ` sergeyb [this message] 2020-04-23 23:24 ` [Tarantool-patches] [PATCH v4 7/10] schema: fix index promotion to functional index Igor Munkin 2020-04-23 23:29 ` Igor Munkin 2020-04-28 23:19 ` Vladislav Shpilevoy 2020-04-21 14:00 ` [Tarantool-patches] [PATCH v4 8/10] schema: fix internal symbols dangling in _G sergeyb 2020-04-21 14:13 ` Oleg Babin 2020-04-21 14:45 ` Sergey Bronnikov 2020-04-21 19:52 ` Igor Munkin 2020-04-23 23:27 ` Igor Munkin 2020-04-28 23:19 ` Vladislav Shpilevoy 2020-04-21 14:00 ` [Tarantool-patches] [PATCH v4 9/10] Disabled test/luajit-tap in luacheckrc sergeyb 2020-04-24 10:16 ` Igor Munkin 2020-04-29 14:25 ` Sergey Bronnikov 2020-04-21 14:00 ` [Tarantool-patches] [PATCH v4 10/10] luajit: Fix warnings spotted by luacheck sergeyb 2020-04-21 19:33 ` Igor Munkin 2020-04-22 10:14 ` Sergey Bronnikov 2020-04-23 6:24 ` Sergey Bronnikov 2020-04-23 10:03 ` Igor Munkin 2020-04-23 10:30 ` Sergey Bronnikov
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=0b86996f4cac3e620137abf271a43bde499e5334.1587476678.git.sergeyb@tarantool.org \ --to=sergeyb@tarantool.org \ --cc=imun@tarantool.org \ --cc=o.piskunov@tarantool.org \ --cc=tarantool-patches@dev.tarantool.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH v4 7/10] 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