Tarantool development patches archive
 help / color / mirror / Atom feed
* [PATCH v1 1/1] box: ban multikey index with multiple root field
@ 2019-05-23  7:15 Kirill Shcherbatov
  2019-05-23  8:27 ` Vladimir Davydov
  0 siblings, 1 reply; 2+ messages in thread
From: Kirill Shcherbatov @ 2019-05-23  7:15 UTC (permalink / raw)
  To: tarantool-patches, vdavydov.dev; +Cc: Kirill Shcherbatov

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v1 1/1] box: ban multikey index with multiple root field
  2019-05-23  7:15 [PATCH v1 1/1] box: ban multikey index with multiple root field Kirill Shcherbatov
@ 2019-05-23  8:27 ` Vladimir Davydov
  0 siblings, 0 replies; 2+ messages in thread
From: Vladimir Davydov @ 2019-05-23  8:27 UTC (permalink / raw)
  To: Kirill Shcherbatov; +Cc: tarantool-patches

Pushed to master.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-05-23  8:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-23  7:15 [PATCH v1 1/1] box: ban multikey index with multiple root field Kirill Shcherbatov
2019-05-23  8:27 ` Vladimir Davydov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox