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 C4ADC6C1AE; Sun, 16 May 2021 12:31:49 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org C4ADC6C1AE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1621157509; bh=jQ337rp48obPlBDHXHTtuaG33uIV2NRuKSMTFpRF/Po=; h=To:Cc:Date:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=aBFBaJFBF9qBOo1ISL/F1TQFl/gQ3r35qrrawfDjWMK8gwxOPcoFKacKCCVF0MmGO MyUDrEt3+QCw0aKTH1IsFDK3gHhqAD41Y4cgK4nkFLx3ceDEr1nJJ3jmU7yLZbD4iO bCOVvLY9IqKO+QCecO1RhXo42DKDcaWIBexV0VI4= 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 1138A6C1AE for ; Sun, 16 May 2021 12:31:48 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 1138A6C1AE Received: by smtpng2.m.smailru.net with esmtpa (envelope-from ) id 1liD7j-0005zd-5x; Sun, 16 May 2021 12:31:47 +0300 To: v.shpilevoy@tarantool.org Cc: tarantool-patches@dev.tarantool.org Date: Sun, 16 May 2021 12:31:46 +0300 Message-Id: <7db92f114edfe61c8c3ca6d00e082ac0e6063be9.1621157404.git.imeevma@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-7564579A: 78E4E2B564C1792B X-77F55803: 4F1203BC0FB41BD95978C26455E69BE0890FB394E039F71AA2C815CBBA0C08E7182A05F53808504013007D3091BA9EE821E871C31DDBD6EABB72A718060FCAFB0BA4BADB33C43A05 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE741BD59B4915947BEEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F790063761A26A2A89ED60DE8638F802B75D45FF914D58D5BE9E6BC1A93B80C6DEB9DEE97C6FB206A91F05B2C95918796BE363FAB50D046EC915F1C19414A38D98B987DBD2E47CDBA5A96583C09775C1D3CA48CF17B107DEF921CE79117882F4460429724CE54428C33FAD30A8DF7F3B2552694AC26CFBAC0749D213D2E47CDBA5A9658378DA827A17800CE71AE4D56B06699BBC9FA2833FD35BB23DF004C906525384302BEBFE083D3B9BA71A620F70A64A45A98AA50765F79006372E808ACE2090B5E1725E5C173C3A84C3C5EA940A35A165FF2DBA43225CD8A89FC0F9454058DFE53CC6EABA9B74D0DA47B5C8C57E37DE458BEDA766A37F9254B7 X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975CA200E0309169BAACF67428B3D49298D6A650121A148747E79C2B6934AE262D3EE7EAB7254005DCED8E15D08FB1FB7B0692E1F3B950BCE21616EB5DE968479BF5B2CF3E77A3BD9B2CBDC6A1CF3F042BAD6DF99611D93F60EFA70DDFFB3186CBC5699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D348BE83DFD8AFB1CAC733CFBA8AFED405DD58E6A7F8B1F73B4134BD568A3AD5AF8119530D3BEF79D851D7E09C32AA3244CAB4C5B8DC0996C9A84D3A892A98872E4F26BFA4C8A6946B8729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojbL9S8ysBdXgAElepiYJV4Pe2a3OK9ewq X-Mailru-Sender: 689FA8AB762F73936BC43F508A063822ADFC4ED2997D63B935913F513561622383D72C36FC87018B9F80AB2734326CD2FB559BB5D741EB96352A0ABBE4FDA4210A04DAD6CC59E33667EA787935ED9F1B X-Mras: Ok Subject: [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: imeevma@tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" 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