From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Kirill Shcherbatov Subject: [PATCH v1 1/1] box: ban multikey index with multiple root field Date: Thu, 23 May 2019 10:15:34 +0300 Message-Id: <37db0e91be78bca289f50c77a405f1eb1dc36841.1558595664.git.kshcherbatov@tarantool.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit To: tarantool-patches@freelists.org, vdavydov.dev@gmail.com Cc: Kirill Shcherbatov List-ID: The test for multikey index prefix compatibility was insufficient because JSON path is relative for some fieldno. Those root field identifiers also must coincide. Follow up #1257 --- https://github.com/tarantool/tarantool/commits/kshch/multikey-incompatable-parts-fixup src/box/key_def.c | 3 ++- test/engine/multikey.result | 4 ++++ test/engine/multikey.test.lua | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/box/key_def.c b/src/box/key_def.c index fc547570f..eebfb7fe4 100644 --- a/src/box/key_def.c +++ b/src/box/key_def.c @@ -181,7 +181,8 @@ key_def_set_part_path(struct key_def *def, uint32_t part_no, const char *path, def->multikey_path = part->path; def->multikey_fieldno = part->fieldno; def->multikey_path_len = (uint32_t) multikey_path_len; - } else if (json_path_cmp(path, multikey_path_len, def->multikey_path, + } else if (def->multikey_fieldno != part->fieldno || + json_path_cmp(path, multikey_path_len, def->multikey_path, def->multikey_path_len, TUPLE_INDEX_BASE) != 0) { diag_set(ClientError, ER_WRONG_INDEX_OPTIONS, diff --git a/test/engine/multikey.result b/test/engine/multikey.result index 302082270..968be4cc3 100644 --- a/test/engine/multikey.result +++ b/test/engine/multikey.result @@ -29,6 +29,10 @@ _ = s:create_index('idx2', {parts = {{3, 'str', path = '[*].fname'}, {3, 'str', - error: 'Wrong index options (field 2): no more than one array index placeholder [*] is allowed in JSON path' ... +_ = s:create_index('idx2', {parts = {{2, 'str', path = '[*]'}, {3, 'str', path = '[*]'}}}) +--- +- error: 'Wrong index options (field 2): incompatable multikey index path' +... idx0 = s:create_index('idx0', {parts = {{3, 'str', path = '[1].fname'}}}) --- ... diff --git a/test/engine/multikey.test.lua b/test/engine/multikey.test.lua index 6d974716a..ed7033494 100644 --- a/test/engine/multikey.test.lua +++ b/test/engine/multikey.test.lua @@ -11,6 +11,7 @@ pk = s:create_index('pk') -- Test incompatible multikey index parts. _ = s:create_index('idx3', {parts = {{3, 'str', path = '[*].fname'}, {3, 'str', path = '["data"][*].sname'}}}) _ = s:create_index('idx2', {parts = {{3, 'str', path = '[*].fname'}, {3, 'str', path = '[*].sname[*].a'}}}) +_ = s:create_index('idx2', {parts = {{2, 'str', path = '[*]'}, {3, 'str', path = '[*]'}}}) idx0 = s:create_index('idx0', {parts = {{3, 'str', path = '[1].fname'}}}) _ = s:create_index('idx', {parts = {{3, 'str', path = '[*].fname'}, {3, 'str', path = '[*].sname'}}}) idx0:drop() -- 2.21.0