Tarantool development patches archive
 help / color / mirror / Atom feed
* [Tarantool-patches] [PATCH 1/1] box: make UUID part of SCALAR
@ 2021-05-16  9:31 Mergen Imeev via Tarantool-patches
  2021-05-19 10:48 ` Mergen Imeev via Tarantool-patches
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Mergen Imeev via Tarantool-patches @ 2021-05-16  9:31 UTC (permalink / raw)
  To: v.shpilevoy; +Cc: 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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Tarantool-patches] [PATCH 1/1] box: make UUID part of SCALAR
  2021-05-16  9:31 [Tarantool-patches] [PATCH 1/1] box: make UUID part of SCALAR Mergen Imeev via Tarantool-patches
@ 2021-05-19 10:48 ` Mergen Imeev via Tarantool-patches
  2021-05-21 19:09 ` Vladislav Shpilevoy via Tarantool-patches
  2021-05-24  9:49 ` Kirill Yukhin via Tarantool-patches
  2 siblings, 0 replies; 8+ messages in thread
From: Mergen Imeev via Tarantool-patches @ 2021-05-19 10:48 UTC (permalink / raw)
  To: v.shpilevoy, 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 <imeevma@gmail.com>
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
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Tarantool-patches] [PATCH 1/1] box: make UUID part of SCALAR
  2021-05-16  9:31 [Tarantool-patches] [PATCH 1/1] box: make UUID part of SCALAR Mergen Imeev via Tarantool-patches
  2021-05-19 10:48 ` Mergen Imeev via Tarantool-patches
@ 2021-05-21 19:09 ` Vladislav Shpilevoy via Tarantool-patches
  2021-05-24  9:49 ` Kirill Yukhin via Tarantool-patches
  2 siblings, 0 replies; 8+ messages in thread
From: Vladislav Shpilevoy via Tarantool-patches @ 2021-05-21 19:09 UTC (permalink / raw)
  To: imeevma; +Cc: tarantool-patches

Hi! Thanks for the patch!

> 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

<...>

> +--
> +-- Make sure that comparison in right. Comparison in SCALAR field:

in -> is

> +-- bool < number < string < varbinary < uuid.
> +--
The rest is LGTM. Send it to a second reviewer right away.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Tarantool-patches] [PATCH 1/1] box: make UUID part of SCALAR
  2021-05-16  9:31 [Tarantool-patches] [PATCH 1/1] box: make UUID part of SCALAR Mergen Imeev via Tarantool-patches
  2021-05-19 10:48 ` Mergen Imeev via Tarantool-patches
  2021-05-21 19:09 ` Vladislav Shpilevoy via Tarantool-patches
@ 2021-05-24  9:49 ` Kirill Yukhin via Tarantool-patches
  2 siblings, 0 replies; 8+ messages in thread
From: Kirill Yukhin via Tarantool-patches @ 2021-05-24  9:49 UTC (permalink / raw)
  To: imeevma; +Cc: v.shpilevoy, tarantool-patches

Hello,

On 16 май 12:31, 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

I've checked your patch into master.

--
Regards, Kirill Yukhin

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Tarantool-patches] [PATCH 1/1] box: make UUID part of SCALAR
  2021-04-26 15:31   ` Mergen Imeev via Tarantool-patches
@ 2021-04-28 14:43     ` Serge Petrenko via Tarantool-patches
  0 siblings, 0 replies; 8+ messages in thread
From: Serge Petrenko via Tarantool-patches @ 2021-04-28 14:43 UTC (permalink / raw)
  To: Mergen Imeev; +Cc: tarantool-patches



26.04.2021 18:31, Mergen Imeev пишет:
> 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:
>
Thanks for the fixes!
LGTM.

-- 
Serge Petrenko


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Tarantool-patches] [PATCH 1/1] box: make UUID part of SCALAR
  2021-04-25  9:07 ` Serge Petrenko via Tarantool-patches
@ 2021-04-26 15:31   ` Mergen Imeev via Tarantool-patches
  2021-04-28 14:43     ` Serge Petrenko via Tarantool-patches
  0 siblings, 1 reply; 8+ messages in thread
From: Mergen Imeev via Tarantool-patches @ 2021-04-26 15:31 UTC (permalink / raw)
  To: Serge Petrenko; +Cc: 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 <imeevma@gmail.com>
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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Tarantool-patches] [PATCH 1/1] box: make UUID part of SCALAR
  2021-04-23 11:40 Mergen Imeev via Tarantool-patches
@ 2021-04-25  9:07 ` Serge Petrenko via Tarantool-patches
  2021-04-26 15:31   ` Mergen Imeev via Tarantool-patches
  0 siblings, 1 reply; 8+ messages in thread
From: Serge Petrenko via Tarantool-patches @ 2021-04-25  9:07 UTC (permalink / raw)
  To: imeevma; +Cc: tarantool-patches



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?

> +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.

> -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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Tarantool-patches] [PATCH 1/1] box: make UUID part of SCALAR
@ 2021-04-23 11:40 Mergen Imeev via Tarantool-patches
  2021-04-25  9:07 ` Serge Petrenko via Tarantool-patches
  0 siblings, 1 reply; 8+ messages in thread
From: Mergen Imeev via Tarantool-patches @ 2021-04-23 11:40 UTC (permalink / raw)
  To: sergepetrenko; +Cc: 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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-05-24  9:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-16  9:31 [Tarantool-patches] [PATCH 1/1] box: make UUID part of SCALAR Mergen Imeev via Tarantool-patches
2021-05-19 10:48 ` Mergen Imeev via Tarantool-patches
2021-05-21 19:09 ` Vladislav Shpilevoy via Tarantool-patches
2021-05-24  9:49 ` Kirill Yukhin via Tarantool-patches
  -- strict thread matches above, loose matches on Subject: below --
2021-04-23 11:40 Mergen Imeev via Tarantool-patches
2021-04-25  9:07 ` Serge Petrenko via Tarantool-patches
2021-04-26 15:31   ` Mergen Imeev via Tarantool-patches
2021-04-28 14:43     ` Serge Petrenko via Tarantool-patches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox