From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 22C0A6C1AE; Wed, 19 May 2021 13:48:47 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 22C0A6C1AE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1621421327; bh=bxmjYB4k/fUXbIdUlPZam+yNYtmDjJoPN9Plgo28muI=; h=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=rSvFyODxzKiR3zcilBkvaJ/XmqkCk/bjpqwfRHIBAQpw4n87/a0vSanG/y0oylGMn pi/FAn76QvjTCZyU8sJNfIzV5H7zou0w3wTE6FjHtN7V3Kfj4g2y8yBoLNan731Lwh 83QtzSbUBsZFpKHonqalRV1H+LlxpFKnKm+nDHqM= Received: from smtpng2.m.smailru.net (smtpng2.m.smailru.net [94.100.179.3]) (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 47E296C1AE for ; Wed, 19 May 2021 13:48:45 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 47E296C1AE Received: by smtpng2.m.smailru.net with esmtpa (envelope-from ) id 1ljJkq-0001mo-Ag; Wed, 19 May 2021 13:48:44 +0300 Date: Wed, 19 May 2021 13:48:43 +0300 To: v.shpilevoy@tarantool.org, tarantool-patches@dev.tarantool.org Message-ID: <20210519104843.GA214487@tarantool.org> References: <7db92f114edfe61c8c3ca6d00e082ac0e6063be9.1621157404.git.imeevma@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <7db92f114edfe61c8c3ca6d00e082ac0e6063be9.1621157404.git.imeevma@gmail.com> X-7564579A: 78E4E2B564C1792B X-77F55803: 4F1203BC0FB41BD91B019B01C53E51AFFAE5AC8370B8C7D84BE9C2CBFD04F41900894C459B0CD1B93C44C7AE7CBD1C98EF5F9D8018C1D8FB4A524B1BD77900E0033FDC616F2E6AF2 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE749E036A12C4E6A87EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006377845AD97F799C6E88638F802B75D45FF914D58D5BE9E6BC1A93B80C6DEB9DEE97C6FB206A91F05B2EDDFC1CC4A2CF15ADFDFEC466D5AFD4E4A8204C501E24153D2E47CDBA5A96583C09775C1D3CA48CFCA5A41EBD8A3A0199FA2833FD35BB23D2EF20D2F80756B5F868A13BD56FB6657A471835C12D1D977725E5C173C3A84C3CA5A41EBD8A3A0199FA2833FD35BB23DF004C906525384302BEBFE083D3B9BA71A620F70A64A45A98AA50765F79006372E808ACE2090B5E1725E5C173C3A84C3C5EA940A35A165FF2DBA43225CD8A89F83C798A30B85E16B57739F23D657EF2BB5C8C57E37DE458BEDA766A37F9254B7 X-C1DE0DAB: 0D63561A33F958A5BAD82BAAFD5E24A4C22B4FBF4B7663C81F055E88C1405DD8D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA752546FE575EB473F1410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3444047AE358B407540E6FC429DB306E7ABD3B2A5D3C527E82ECE34C2ED73985EA1EB1DE1E7964E5F41D7E09C32AA3244C11831146E18896F2E310F95412EBA61B7C0C08F7987826B9729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojF35yOkZDoIWWiTMT8zNOWw== X-Mailru-Sender: 689FA8AB762F73936BC43F508A063822AD1F3979C2AD57648FB20665978B132383D72C36FC87018B9F80AB2734326CD2FB559BB5D741EB96352A0ABBE4FDA4210A04DAD6CC59E33667EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH 1/1] box: make UUID part of SCALAR X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Mergen Imeev via Tarantool-patches Reply-To: Mergen Imeev Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hi! I found a bug in my patch. in some cases, comparisons between UUIDs in SCALAR field may result in a segmentation fault. For example, if we insert "11111111-1111-1111-1111-111111111111" in a space, and then try to insert "11111111-1111-1111-1111-111111111112", we get a segmentation fault. However, if we try to insert "11111111-1111-2222-1111-111111111111" as the second value, we will not get an error. I fixed this and changed the test accordingly. Diff and new patch below. https://github.com/tarantool/tarantool/issues/6042 https://github.com/tarantool/tarantool/tree/imeevma/gh-6042-make-uuid-part-of-scalar Diff: diff --git a/src/box/tuple_compare.cc b/src/box/tuple_compare.cc index 3ae1dcc8f..98938fb39 100644 --- a/src/box/tuple_compare.cc +++ b/src/box/tuple_compare.cc @@ -397,7 +397,7 @@ static mp_compare_f mp_class_comparators[] = { /* .MP_CLASS_NUMBER = */ mp_compare_number, /* .MP_CLASS_STR = */ mp_compare_str, /* .MP_CLASS_BIN = */ mp_compare_bin, - /* .MP_CLASS_UUID = */ NULL, + /* .MP_CLASS_UUID = */ mp_compare_uuid, /* .MP_CLASS_ARRAY = */ NULL, /* .MP_CLASS_MAP = */ NULL, }; diff --git a/test/app/uuid.result b/test/app/uuid.result index c085f9b6d..47d855d53 100644 --- a/test/app/uuid.result +++ b/test/app/uuid.result @@ -452,6 +452,14 @@ s = box.schema.space.create('s', {format={{'s', 'scalar'}}}) _ = s:create_index('i') --- ... +s:insert({uuid.fromstr('11111111-1111-1111-1111-111111111111')}) +--- +- [11111111-1111-1111-1111-111111111111] +... +s:insert({uuid.fromstr('11111111-1111-1111-1111-111111111112')}) +--- +- [11111111-1111-1111-1111-111111111112] +... s:insert({1}) --- - [1] @@ -468,14 +476,6 @@ box.execute([[INSERT INTO "s" VALUES (x'303030')]]) --- - row_count: 1 ... -s:insert({uuid.fromstr('11111111-1111-1111-1111-111111111111')}) ---- -- [11111111-1111-1111-1111-111111111111] -... -s:insert({uuid.fromstr('11111111-1111-2222-1111-111111111111')}) ---- -- [11111111-1111-2222-1111-111111111111] -... -- -- Make sure that comparison in right. Comparison in SCALAR field: -- bool < number < string < varbinary < uuid. @@ -487,11 +487,11 @@ s:select() - ['1'] - ['000'] - [11111111-1111-1111-1111-111111111111] - - [11111111-1111-2222-1111-111111111111] + - [11111111-1111-1111-1111-111111111112] ... s:select({}, {iterator='LE'}) --- -- - [11111111-1111-2222-1111-111111111111] +- - [11111111-1111-1111-1111-111111111112] - [11111111-1111-1111-1111-111111111111] - ['000'] - ['1'] diff --git a/test/app/uuid.test.lua b/test/app/uuid.test.lua index d2c34fadd..5c9f4dd02 100644 --- a/test/app/uuid.test.lua +++ b/test/app/uuid.test.lua @@ -169,12 +169,12 @@ u2_str = nil -- s = box.schema.space.create('s', {format={{'s', 'scalar'}}}) _ = s:create_index('i') +s:insert({uuid.fromstr('11111111-1111-1111-1111-111111111111')}) +s:insert({uuid.fromstr('11111111-1111-1111-1111-111111111112')}) s:insert({1}) s:insert({'1'}) s:insert({true}) box.execute([[INSERT INTO "s" VALUES (x'303030')]]) -s:insert({uuid.fromstr('11111111-1111-1111-1111-111111111111')}) -s:insert({uuid.fromstr('11111111-1111-2222-1111-111111111111')}) -- -- Make sure that comparison in right. Comparison in SCALAR field: New patch: commit 7fdd8c271fc0438ba372a46e0b3954d4a3f70544 Author: Mergen Imeev Date: Thu Apr 22 18:00:32 2021 +0300 box: make UUID part of SCALAR Prior to this patch, UUID was not part of SCALAR. However, this should be changed to comply with the RFC "Consistent Lua/SQL types". Closes #6042 @TarantoolBot document Title: UUID is now part of SCALAR The UUID field type is now part of the SCALAR field type. This means that now values of type UUID can be inserted into the SCALAR field, and these values can participate in the sorting of the SCALAR fields. The order is as follows: boolean < number < string < varbinary < uuid. diff --git a/changelogs/unreleased/make-uuid-part-of-scalar.md b/changelogs/unreleased/make-uuid-part-of-scalar.md new file mode 100644 index 000000000..eeead4ffb --- /dev/null +++ b/changelogs/unreleased/make-uuid-part-of-scalar.md @@ -0,0 +1,3 @@ +## feature/core + + * Field type UUID is now part of field type SCALAR (gh-6042). diff --git a/src/box/field_def.c b/src/box/field_def.c index 213e91699..51acb8025 100644 --- a/src/box/field_def.c +++ b/src/box/field_def.c @@ -83,7 +83,7 @@ const uint32_t field_ext_type[] = { /* [FIELD_TYPE_INTEGER] = */ 0, /* [FIELD_TYPE_BOOLEAN] = */ 0, /* [FIELD_TYPE_VARBINARY] = */ 0, - /* [FIELD_TYPE_SCALAR] = */ 1U << MP_DECIMAL, + /* [FIELD_TYPE_SCALAR] = */ (1U << MP_DECIMAL) | (1U << MP_UUID), /* [FIELD_TYPE_DECIMAL] = */ 1U << MP_DECIMAL, /* [FIELD_TYPE_UUID] = */ 1U << MP_UUID, /* [FIELD_TYPE_ARRAY] = */ 0, diff --git a/src/box/tuple_compare.cc b/src/box/tuple_compare.cc index 0946d77f8..98938fb39 100644 --- a/src/box/tuple_compare.cc +++ b/src/box/tuple_compare.cc @@ -397,7 +397,7 @@ static mp_compare_f mp_class_comparators[] = { /* .MP_CLASS_NUMBER = */ mp_compare_number, /* .MP_CLASS_STR = */ mp_compare_str, /* .MP_CLASS_BIN = */ mp_compare_bin, - /* .MP_CLASS_UUID = */ NULL, + /* .MP_CLASS_UUID = */ mp_compare_uuid, /* .MP_CLASS_ARRAY = */ NULL, /* .MP_CLASS_MAP = */ NULL, }; @@ -1790,6 +1790,8 @@ field_hint_scalar(const char *field, struct coll *coll) decimal_t dec; return hint_decimal(decimal_unpack(&field, len, &dec)); } + case MP_UUID: + return hint_uuid_raw(field); default: unreachable(); } diff --git a/test/app/uuid.result b/test/app/uuid.result index b4870302e..47d855d53 100644 --- a/test/app/uuid.result +++ b/test/app/uuid.result @@ -443,6 +443,64 @@ u1_str = nil u2_str = nil --- ... +-- +-- gh-6042: add UUID to SCALAR. +-- +s = box.schema.space.create('s', {format={{'s', 'scalar'}}}) +--- +... +_ = s:create_index('i') +--- +... +s:insert({uuid.fromstr('11111111-1111-1111-1111-111111111111')}) +--- +- [11111111-1111-1111-1111-111111111111] +... +s:insert({uuid.fromstr('11111111-1111-1111-1111-111111111112')}) +--- +- [11111111-1111-1111-1111-111111111112] +... +s:insert({1}) +--- +- [1] +... +s:insert({'1'}) +--- +- ['1'] +... +s:insert({true}) +--- +- [true] +... +box.execute([[INSERT INTO "s" VALUES (x'303030')]]) +--- +- row_count: 1 +... +-- +-- Make sure that comparison in right. Comparison in SCALAR field: +-- bool < number < string < varbinary < uuid. +-- +s:select() +--- +- - [true] + - [1] + - ['1'] + - ['000'] + - [11111111-1111-1111-1111-111111111111] + - [11111111-1111-1111-1111-111111111112] +... +s:select({}, {iterator='LE'}) +--- +- - [11111111-1111-1111-1111-111111111112] + - [11111111-1111-1111-1111-111111111111] + - ['000'] + - ['1'] + - [1] + - [true] +... +s:drop() +--- +... uuid = nil --- ... diff --git a/test/app/uuid.test.lua b/test/app/uuid.test.lua index 867bbd832..5c9f4dd02 100644 --- a/test/app/uuid.test.lua +++ b/test/app/uuid.test.lua @@ -164,6 +164,26 @@ u1 = nil u1_str = nil u2_str = nil +-- +-- gh-6042: add UUID to SCALAR. +-- +s = box.schema.space.create('s', {format={{'s', 'scalar'}}}) +_ = s:create_index('i') +s:insert({uuid.fromstr('11111111-1111-1111-1111-111111111111')}) +s:insert({uuid.fromstr('11111111-1111-1111-1111-111111111112')}) +s:insert({1}) +s:insert({'1'}) +s:insert({true}) +box.execute([[INSERT INTO "s" VALUES (x'303030')]]) + +-- +-- Make sure that comparison in right. Comparison in SCALAR field: +-- bool < number < string < varbinary < uuid. +-- +s:select() +s:select({}, {iterator='LE'}) +s:drop() + uuid = nil test_run:cmd("clear filter") diff --git a/test/engine/ddl.result b/test/engine/ddl.result index 08ad1a57b..0fed1cbe4 100644 --- a/test/engine/ddl.result +++ b/test/engine/ddl.result @@ -1428,11 +1428,9 @@ fail_format_change(12, 'number') - 'Tuple field 12 (field12) type does not match one required by operation: expected number, got extension' ... --- uuid --X--> scalar -fail_format_change(12, 'scalar') +-- uuid ----> scalar +ok_format_change(12, 'scalar') --- -- 'Tuple field 12 (field12) type does not match one required by operation: expected - scalar, got extension' ... -- uuid --X--> string fail_format_change(12, 'string') diff --git a/test/engine/ddl.test.lua b/test/engine/ddl.test.lua index 5ba80e075..08162f253 100644 --- a/test/engine/ddl.test.lua +++ b/test/engine/ddl.test.lua @@ -522,8 +522,8 @@ fail_format_change(11, 'uuid') ok_format_change(12, 'any') -- uuid --X--> number fail_format_change(12, 'number') --- uuid --X--> scalar -fail_format_change(12, 'scalar') +-- uuid ----> scalar +ok_format_change(12, 'scalar') -- uuid --X--> string fail_format_change(12, 'string') -- uuid --X--> integer On Sun, May 16, 2021 at 12:31:46PM +0300, Mergen Imeev via Tarantool-patches wrote: > Prior to this patch, UUID was not part of SCALAR. However, this should > be changed to comply with the RFC "Consistent Lua/SQL types". > > Closes #6042 > > @TarantoolBot document > Title: UUID is now part of SCALAR > > The UUID field type is now part of the SCALAR field type. This means > that now values of type UUID can be inserted into the SCALAR field, and > these values can participate in the sorting of the SCALAR fields. The > order is as follows: boolean < number < string < varbinary < uuid. > --- > > https://github.com/tarantool/tarantool/issues/6042 > https://github.com/tarantool/tarantool/tree/imeevma/gh-6042-make-uuid-part-of-scalar > > .../unreleased/make-uuid-part-of-scalar.md | 3 + > src/box/field_def.c | 2 +- > src/box/tuple_compare.cc | 2 + > test/app/uuid.result | 58 +++++++++++++++++++ > test/app/uuid.test.lua | 20 +++++++ > test/engine/ddl.result | 6 +- > test/engine/ddl.test.lua | 4 +- > 7 files changed, 88 insertions(+), 7 deletions(-) > create mode 100644 changelogs/unreleased/make-uuid-part-of-scalar.md > > diff --git a/changelogs/unreleased/make-uuid-part-of-scalar.md b/changelogs/unreleased/make-uuid-part-of-scalar.md > new file mode 100644 > index 000000000..eeead4ffb > --- /dev/null > +++ b/changelogs/unreleased/make-uuid-part-of-scalar.md > @@ -0,0 +1,3 @@ > +## feature/core > + > + * Field type UUID is now part of field type SCALAR (gh-6042). > diff --git a/src/box/field_def.c b/src/box/field_def.c > index 213e91699..51acb8025 100644 > --- a/src/box/field_def.c > +++ b/src/box/field_def.c > @@ -83,7 +83,7 @@ const uint32_t field_ext_type[] = { > /* [FIELD_TYPE_INTEGER] = */ 0, > /* [FIELD_TYPE_BOOLEAN] = */ 0, > /* [FIELD_TYPE_VARBINARY] = */ 0, > - /* [FIELD_TYPE_SCALAR] = */ 1U << MP_DECIMAL, > + /* [FIELD_TYPE_SCALAR] = */ (1U << MP_DECIMAL) | (1U << MP_UUID), > /* [FIELD_TYPE_DECIMAL] = */ 1U << MP_DECIMAL, > /* [FIELD_TYPE_UUID] = */ 1U << MP_UUID, > /* [FIELD_TYPE_ARRAY] = */ 0, > diff --git a/src/box/tuple_compare.cc b/src/box/tuple_compare.cc > index 0946d77f8..3ae1dcc8f 100644 > --- a/src/box/tuple_compare.cc > +++ b/src/box/tuple_compare.cc > @@ -1790,6 +1790,8 @@ field_hint_scalar(const char *field, struct coll *coll) > decimal_t dec; > return hint_decimal(decimal_unpack(&field, len, &dec)); > } > + case MP_UUID: > + return hint_uuid_raw(field); > default: > unreachable(); > } > diff --git a/test/app/uuid.result b/test/app/uuid.result > index b4870302e..c085f9b6d 100644 > --- a/test/app/uuid.result > +++ b/test/app/uuid.result > @@ -443,6 +443,64 @@ u1_str = nil > u2_str = nil > --- > ... > +-- > +-- gh-6042: add UUID to SCALAR. > +-- > +s = box.schema.space.create('s', {format={{'s', 'scalar'}}}) > +--- > +... > +_ = s:create_index('i') > +--- > +... > +s:insert({1}) > +--- > +- [1] > +... > +s:insert({'1'}) > +--- > +- ['1'] > +... > +s:insert({true}) > +--- > +- [true] > +... > +box.execute([[INSERT INTO "s" VALUES (x'303030')]]) > +--- > +- row_count: 1 > +... > +s:insert({uuid.fromstr('11111111-1111-1111-1111-111111111111')}) > +--- > +- [11111111-1111-1111-1111-111111111111] > +... > +s:insert({uuid.fromstr('11111111-1111-2222-1111-111111111111')}) > +--- > +- [11111111-1111-2222-1111-111111111111] > +... > +-- > +-- Make sure that comparison in right. Comparison in SCALAR field: > +-- bool < number < string < varbinary < uuid. > +-- > +s:select() > +--- > +- - [true] > + - [1] > + - ['1'] > + - ['000'] > + - [11111111-1111-1111-1111-111111111111] > + - [11111111-1111-2222-1111-111111111111] > +... > +s:select({}, {iterator='LE'}) > +--- > +- - [11111111-1111-2222-1111-111111111111] > + - [11111111-1111-1111-1111-111111111111] > + - ['000'] > + - ['1'] > + - [1] > + - [true] > +... > +s:drop() > +--- > +... > uuid = nil > --- > ... > diff --git a/test/app/uuid.test.lua b/test/app/uuid.test.lua > index 867bbd832..d2c34fadd 100644 > --- a/test/app/uuid.test.lua > +++ b/test/app/uuid.test.lua > @@ -164,6 +164,26 @@ u1 = nil > u1_str = nil > u2_str = nil > > +-- > +-- gh-6042: add UUID to SCALAR. > +-- > +s = box.schema.space.create('s', {format={{'s', 'scalar'}}}) > +_ = s:create_index('i') > +s:insert({1}) > +s:insert({'1'}) > +s:insert({true}) > +box.execute([[INSERT INTO "s" VALUES (x'303030')]]) > +s:insert({uuid.fromstr('11111111-1111-1111-1111-111111111111')}) > +s:insert({uuid.fromstr('11111111-1111-2222-1111-111111111111')}) > + > +-- > +-- Make sure that comparison in right. Comparison in SCALAR field: > +-- bool < number < string < varbinary < uuid. > +-- > +s:select() > +s:select({}, {iterator='LE'}) > +s:drop() > + > uuid = nil > > test_run:cmd("clear filter") > diff --git a/test/engine/ddl.result b/test/engine/ddl.result > index 08ad1a57b..0fed1cbe4 100644 > --- a/test/engine/ddl.result > +++ b/test/engine/ddl.result > @@ -1428,11 +1428,9 @@ fail_format_change(12, 'number') > - 'Tuple field 12 (field12) type does not match one required by operation: expected > number, got extension' > ... > --- uuid --X--> scalar > -fail_format_change(12, 'scalar') > +-- uuid ----> scalar > +ok_format_change(12, 'scalar') > --- > -- 'Tuple field 12 (field12) type does not match one required by operation: expected > - scalar, got extension' > ... > -- uuid --X--> string > fail_format_change(12, 'string') > diff --git a/test/engine/ddl.test.lua b/test/engine/ddl.test.lua > index 5ba80e075..08162f253 100644 > --- a/test/engine/ddl.test.lua > +++ b/test/engine/ddl.test.lua > @@ -522,8 +522,8 @@ fail_format_change(11, 'uuid') > ok_format_change(12, 'any') > -- uuid --X--> number > fail_format_change(12, 'number') > --- uuid --X--> scalar > -fail_format_change(12, 'scalar') > +-- uuid ----> scalar > +ok_format_change(12, 'scalar') > -- uuid --X--> string > fail_format_change(12, 'string') > -- uuid --X--> integer > -- > 2.25.1 >