From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Vladimir Davydov Subject: [PATCH 2/2] tuple format: remove invalid assertion from tuple_format_iterator_next Date: Wed, 22 May 2019 18:26:47 +0300 Message-Id: In-Reply-To: References: In-Reply-To: References: To: tarantool-patches@freelists.org List-ID: It's too early to assert msgpack type as an array when a multikey field is encountered - we haven't checked the field type yet so the type might as well be a map, in which case we will raise an error just a few lines below. Remove the assertion and add a test case. --- https://github.com/tarantool/tarantool/commits/dv/tuple-format-check-fixes src/box/tuple_format.c | 1 - test/engine/multikey.result | 28 ++++++++++++++++++++++++++++ test/engine/multikey.test.lua | 12 ++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/box/tuple_format.c b/src/box/tuple_format.c index 9b913306..02fadf1c 100644 --- a/src/box/tuple_format.c +++ b/src/box/tuple_format.c @@ -1138,7 +1138,6 @@ tuple_format_iterator_next(struct tuple_format_iterator *it, * and is equal to multikey index * comparison hint. */ - assert(type == MP_ARRAY); it->multikey_frame = mp_stack_top(&it->stack); } it->parent = &field->token; diff --git a/test/engine/multikey.result b/test/engine/multikey.result index e7326cb9..30208227 100644 --- a/test/engine/multikey.result +++ b/test/engine/multikey.result @@ -835,3 +835,31 @@ s.index.sk:select() s:drop() --- ... +-- +-- Inserting a map where a multikey array is expected is +-- handled gracefully: no crashes, just an error message. +-- +s = box.schema.space.create('test', {engine = engine}) +--- +... +_ = s:create_index('pk') +--- +... +_ = s:create_index('sk', {parts = {{'[2][*]', 'unsigned'}}}) +--- +... +s:insert{1, {a = 1}} -- error +--- +- error: 'Tuple field 2 type does not match one required by operation: expected array' +... +s:insert{2, {1}} -- ok +--- +- [2, [1]] +... +s.index.sk:select() +--- +- - [2, [1]] +... +s:drop() +--- +... diff --git a/test/engine/multikey.test.lua b/test/engine/multikey.test.lua index 48eed2a3..6d974716 100644 --- a/test/engine/multikey.test.lua +++ b/test/engine/multikey.test.lua @@ -224,3 +224,15 @@ s:insert{7, {}} -- ok s:insert{8, {2}} -- ok s.index.sk:select() s:drop() + +-- +-- Inserting a map where a multikey array is expected is +-- handled gracefully: no crashes, just an error message. +-- +s = box.schema.space.create('test', {engine = engine}) +_ = s:create_index('pk') +_ = s:create_index('sk', {parts = {{'[2][*]', 'unsigned'}}}) +s:insert{1, {a = 1}} -- error +s:insert{2, {1}} -- ok +s.index.sk:select() +s:drop() -- 2.11.0