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 771F96EC5E; Fri, 23 Apr 2021 14:40:46 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 771F96EC5E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1619178046; bh=4ybs8OqLQnnNr+GwUeeFwAfVpU22HZc01sRdBqu7Qyg=; h=To:Cc:Date:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=ncsl9UYA+MI+KxIIvLrGjSFiyFhb4UOeLCHXy1jcTBUaTc8TLW+/JmyzxZoFCVUQn f4x1IqcmEukiAWYZ67RRgcgTtyoZyPOhqP2YG3uaHgmz2R0gOKjO1fEJ83r+yLyg3T inOnK/bw2/YI8wbqBmYn2JhineT/y69pwH4DVFFY= 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 EF17D6EC5E for ; Fri, 23 Apr 2021 14:40:43 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org EF17D6EC5E Received: by smtpng2.m.smailru.net with esmtpa (envelope-from ) id 1lZuAt-0001cd-4G; Fri, 23 Apr 2021 14:40:43 +0300 To: sergepetrenko@tarantool.org Cc: tarantool-patches@dev.tarantool.org Date: Fri, 23 Apr 2021 14:40:42 +0300 Message-Id: X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9203E2ABA940B75486323DEBBB34FA34625FD3482BBBCEE36182A05F538085040F559CB240EF7FFECBCB30D19D2F66EB3F2111E523A4D77799B486D87251A098A X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE78E8C2D701AF938A6EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637C8CBD5573EAF738DEA1F7E6F0F101C67CDEEF6D7F21E0D1D9295C2E9FA3191EE1B59CA4C82EFA6584E27DEE3FA4BCBDCE462EF4A6E81F9C2F6B57BC7E64490618DEB871D839B73339E8FC8737B5C2249D082881546D93491CC7F00164DA146DAFE8445B8C89999729449624AB7ADAF37F6B57BC7E64490611E7FA7ABCAF51C92176DF2183F8FC7C07E7E81EEA8A9722B8941B15DA834481F9449624AB7ADAF372E808ACE2090B5E14AD6D5ED66289B5259CC434672EE63711DD303D21008E298D5E8D9A59859A8B6B372FE9A2E580EFC725E5C173C3A84C3727597FF642BA4D735872C767BF85DA2F004C90652538430E4A6367B16DE6309 X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975C3E7AEEB2EA3DACB309AF72333BCADC2BFBF7B9FC091C62759C2B6934AE262D3EE7EAB7254005DCED8E15D08FB1FB7B0692E1F3B950BCE21616EB5DE968479BF5B2CF3E77A3BD9B2CBDC6A1CF3F042BAD6DF99611D93F60EFE5E764EB5D94DBD4699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D341776B9FDE05FBA7ABCA8579CD08B3243FC3E21BBBCEBCA73BC28A4A53E78C0E479E49824E5FA06241D7E09C32AA3244C0FEB1F71DD04835616E7AF2E01AB4DF030363D8B7DA7DD44729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojMA4lh0BuVjN0xyruWuoRsg== X-Mailru-Sender: 689FA8AB762F73936BC43F508A063822A279C08B05F39CB686BC26CB5AC0620D83D72C36FC87018B9F80AB2734326CD2FB559BB5D741EB96352A0ABBE4FDA4210A04DAD6CC59E33667EA787935ED9F1B 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 | 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/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..6b22b1d2c 100644 --- a/test/app/uuid.result +++ b/test/app/uuid.result @@ -443,6 +443,52 @@ 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({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() +--- +- - [1] + - ['1'] + - [11111111-1111-1111-1111-111111111111] + - [11111111-1111-2222-1111-111111111111] +... +s:select({}, {iterator='LE'}) +--- +- - [11111111-1111-2222-1111-111111111111] + - [11111111-1111-1111-1111-111111111111] + - ['1'] + - [1] +... +s:drop() +--- +... uuid = nil --- ... 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. +-- +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 -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 -- 2.25.1