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 2DD966C7D7; Mon, 26 Apr 2021 18:31:55 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 2DD966C7D7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1619451115; bh=K6IPfgP0qhbNHRbfA4gVGNr75FbQKtTEp6v6clN2Pvo=; h=Date:To:Cc:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=xiBNCFsrKe8eeTqV6ixN2gVAH0PUu1huFdEOrB5DUw3FzN+th2k78Q7A8M3bSxvWN 6s+nzQT3/0RZ4teX5/OQ65BdxUApKt5e/+ypOK4sTj2cxQ5hNDyZABIHUJj/DtzrYX NZdfffUv2F8UGEySQITH/dWyQEFxuD3utfdTtXXw= 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 73BE26FC8E for ; Mon, 26 Apr 2021 18:31:53 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 73BE26FC8E Received: by smtpng2.m.smailru.net with esmtpa (envelope-from ) id 1lb3DE-0007GC-J9; Mon, 26 Apr 2021 18:31:53 +0300 Date: Mon, 26 Apr 2021 18:31:51 +0300 To: Serge Petrenko Cc: tarantool-patches@dev.tarantool.org Message-ID: <20210426153151.GA156387@tarantool.org> References: <4d65f57c-2477-c95a-f199-0af890ae148a@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <4d65f57c-2477-c95a-f199-0af890ae148a@tarantool.org> X-7564579A: EEAE043A70213CC8 X-77F55803: 4F1203BC0FB41BD9ECFD8CE5F05940103F64F7B2B6947DF2DC80D3601B233994182A05F53808504081FAC57381FA1C160348C4DC9AB5894BA3FE5EB44881EB067691EF63CD016DCF X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7B3C0829F48AFDC41EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637F08BD7C3AB07DC7F8638F802B75D45FF914D58D5BE9E6BC1A93B80C6DEB9DEE97C6FB206A91F05B2FECA8C68DEC653FEFD648ADADC5BE25FE5D25F19253116ADD2E47CDBA5A96583C09775C1D3CA48CFCA5A41EBD8A3A0199FA2833FD35BB23D2EF20D2F80756B5F868A13BD56FB6657A471835C12D1D977725E5C173C3A84C3CA5A41EBD8A3A0199FA2833FD35BB23DF004C906525384302BEBFE083D3B9BA71A620F70A64A45A98AA50765F79006372E808ACE2090B5E1725E5C173C3A84C3C5EA940A35A165FF2DBA43225CD8A89F83C798A30B85E16B6D8C47C27EEC5E9FB5C8C57E37DE458BEDA766A37F9254B7 X-C1DE0DAB: 0D63561A33F958A5C36CE9627A8C8F86ADA9EE63DBC3C3C4A72716B52BD4B024D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA7502E6951B79FF9A3F410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D349A949488F6BF46DD5A2E90E413FDD2639F050114BB3F606A26F75A202FC99244568C224254256C551D7E09C32AA3244CDAFA4F68E0C26103DF1E1C7F635401485595C85A795C7BAE729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojmUj/IHfqgKepfJ9fJ5xVBg== X-Mailru-Sender: 689FA8AB762F73936BC43F508A063822F37078CB2DD98CC38604B86C8F456B8483D72C36FC87018B9F80AB2734326CD2FB559BB5D741EB96352A0ABBE4FDA4210A04DAD6CC59E33667EA787935ED9F1B 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" Thank you for the review! My answers, diff and new patch below. On Sun, Apr 25, 2021 at 12:07:25PM +0300, Serge Petrenko wrote: > > > 23.04.2021 14:40, imeevma@tarantool.org пишет: > > 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. > > --- > > Thanks for the patch! > Generally LGTM with 2 comments. > > > 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 | 46 +++++++++++++++++++ > > test/app/uuid.test.lua | 18 ++++++++ > > test/engine/ddl.result | 4 +- > > test/engine/ddl.test.lua | 2 +- > > 7 files changed, 72 insertions(+), 5 deletions(-) > > create mode 100644 changelogs/unreleased/make-uuid-part-of-scalar.md > > > > ... > > > > diff --git a/test/app/uuid.test.lua b/test/app/uuid.test.lua > > index 867bbd832..7c0942fd6 100644 > > --- a/test/app/uuid.test.lua > > +++ b/test/app/uuid.test.lua > > @@ -164,6 +164,24 @@ 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({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. > > +-- > > I'd also insert a varbinary value to the index, just to check. > Is it possible from lua? > Fixed. It is possible, but it is easier to use SQL. Also, I inserted boolean. > > +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..e044bc094 100644 > > --- a/test/engine/ddl.result > > +++ b/test/engine/ddl.result > > @@ -1429,10 +1429,8 @@ fail_format_change(12, 'number') > > number, got extension' > > ... > > -- uuid --X--> scalar > > The comment should be "-- uuid -----> scalar" now. > Fixed. > > -fail_format_change(12, '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..0cf25aa46 100644 > > --- a/test/engine/ddl.test.lua > > +++ b/test/engine/ddl.test.lua > > @@ -523,7 +523,7 @@ ok_format_change(12, 'any') > > -- uuid --X--> number > > fail_format_change(12, 'number') > > -- uuid --X--> scalar > > -fail_format_change(12, 'scalar') > > +ok_format_change(12, 'scalar') > > -- uuid --X--> string > > fail_format_change(12, 'string') > > -- uuid --X--> integer > > -- > Serge Petrenko > Diff: diff --git a/test/app/uuid.result b/test/app/uuid.result index 6b22b1d2c..c085f9b6d 100644 --- a/test/app/uuid.result +++ b/test/app/uuid.result @@ -460,6 +460,14 @@ 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] @@ -474,8 +482,10 @@ s:insert({uuid.fromstr('11111111-1111-2222-1111-111111111111')}) -- s:select() --- -- - [1] +- - [true] + - [1] - ['1'] + - ['000'] - [11111111-1111-1111-1111-111111111111] - [11111111-1111-2222-1111-111111111111] ... @@ -483,8 +493,10 @@ s:select({}, {iterator='LE'}) --- - - [11111111-1111-2222-1111-111111111111] - [11111111-1111-1111-1111-111111111111] + - ['000'] - ['1'] - [1] + - [true] ... s:drop() --- diff --git a/test/app/uuid.test.lua b/test/app/uuid.test.lua index 7c0942fd6..d2c34fadd 100644 --- a/test/app/uuid.test.lua +++ b/test/app/uuid.test.lua @@ -171,6 +171,8 @@ 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')}) diff --git a/test/engine/ddl.result b/test/engine/ddl.result index e044bc094..0fed1cbe4 100644 --- a/test/engine/ddl.result +++ b/test/engine/ddl.result @@ -1428,7 +1428,7 @@ fail_format_change(12, 'number') - 'Tuple field 12 (field12) type does not match one required by operation: expected number, got extension' ... --- uuid --X--> scalar +-- uuid ----> scalar ok_format_change(12, 'scalar') --- ... diff --git a/test/engine/ddl.test.lua b/test/engine/ddl.test.lua index 0cf25aa46..08162f253 100644 --- a/test/engine/ddl.test.lua +++ b/test/engine/ddl.test.lua @@ -522,7 +522,7 @@ fail_format_change(11, 'uuid') ok_format_change(12, 'any') -- uuid --X--> number fail_format_change(12, 'number') --- uuid --X--> scalar +-- uuid ----> scalar ok_format_change(12, 'scalar') -- uuid --X--> string fail_format_change(12, 'string') New patch: commit e4a47eb977a40454b834b4df6b1aaa40be406024 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..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