From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 920F6445320 for ; Mon, 13 Jul 2020 13:42:34 +0300 (MSK) References: <20200707211957.4974-1-i.kosarev@tarantool.org> From: Aleksandr Lyapunov Message-ID: <117c7a39-27d4-5fe1-7b8c-e8bec2dd6704@tarantool.org> Date: Mon, 13 Jul 2020 13:42:33 +0300 MIME-Version: 1.0 In-Reply-To: <20200707211957.4974-1-i.kosarev@tarantool.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Subject: Re: [Tarantool-patches] [PATCH] engine: fix assert for multikey indexes List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Ilya Kosarev , tarantool-patches@dev.tarantool.org Hi, thanks for the patch! LGTM On 08.07.2020 00:19, Ilya Kosarev wrote: > Since 4273ec52e122d6d37c8deedf1bc10732a7e40c0e (box: introduce JSON > Indexes) we can create multikey index using array which might be the > first tuple field. It technically breaks assertion which implies that > first tuple field can't have offset in the tuple field map. Now the > assert us updated correspondingly. According test case is added. > > Closes #5132 > --- > Branch: https://github.com/tarantool/tarantool/tree/i.kosarev/gh-5132-multiey-index-wrong-format-assert > Issue: https://github.com/tarantool/tarantool/issues/5132 > > @ChangeLog: > * Fix assert outdated due to multikey index arrival. > > src/box/tuple_format.c | 4 ++-- > .../gh-5132-multikey-index-assert.result | 22 +++++++++++++++++++ > .../gh-5132-multikey-index-assert.test.lua | 9 ++++++++ > 3 files changed, 33 insertions(+), 2 deletions(-) > create mode 100644 test/engine/gh-5132-multikey-index-assert.result > create mode 100644 test/engine/gh-5132-multikey-index-assert.test.lua > > diff --git a/src/box/tuple_format.c b/src/box/tuple_format.c > index 68ec2a749..e9920480a 100644 > --- a/src/box/tuple_format.c > +++ b/src/box/tuple_format.c > @@ -478,8 +478,8 @@ tuple_format_create(struct tuple_format *format, struct key_def * const *keys, > } > } > > - assert(tuple_format_field(format, 0)->offset_slot == > - TUPLE_OFFSET_SLOT_NIL); > + assert(tuple_format_field(format, 0)->offset_slot == TUPLE_OFFSET_SLOT_NIL > + || json_token_is_multikey(&tuple_format_field(format, 0)->token)); > size_t field_map_size = -current_slot * sizeof(uint32_t); > if (field_map_size > UINT16_MAX) { > /** tuple->data_offset is 16 bits */ > diff --git a/test/engine/gh-5132-multikey-index-assert.result b/test/engine/gh-5132-multikey-index-assert.result > new file mode 100644 > index 000000000..dbd2e1b5f > --- /dev/null > +++ b/test/engine/gh-5132-multikey-index-assert.result > @@ -0,0 +1,22 @@ > +-- test-run result file version 2 > +test_run = require('test_run').new() > + | --- > + | ... > + > +space = box.schema.space.create('gh-5132-multikey', {engine = test_run:get_cfg('engine')}) > + | --- > + | ... > +space:format({{name = "attributes", type = "array"}, {name = "uid", type = "string"}}) > + | --- > + | ... > +_ = space:create_index('primary', {name = "uid", parts = {{field = "uid"}}}) > + | --- > + | ... > + > +_ = space:create_index('secondary', {name = "kv", parts = {{field = "attributes", path = "[*].key", type = "string"}}}) > + | --- > + | ... > + > +space:drop() > + | --- > + | ... > diff --git a/test/engine/gh-5132-multikey-index-assert.test.lua b/test/engine/gh-5132-multikey-index-assert.test.lua > new file mode 100644 > index 000000000..3394456de > --- /dev/null > +++ b/test/engine/gh-5132-multikey-index-assert.test.lua > @@ -0,0 +1,9 @@ > +test_run = require('test_run').new() > + > +space = box.schema.space.create('gh-5132-multikey', {engine = test_run:get_cfg('engine')}) > +space:format({{name = "attributes", type = "array"}, {name = "uid", type = "string"}}) > +_ = space:create_index('primary', {name = "uid", parts = {{field = "uid"}}}) > + > +_ = space:create_index('secondary', {name = "kv", parts = {{field = "attributes", path = "[*].key", type = "string"}}}) > + > +space:drop()