[Tarantool-patches] [PATCH v2 4/4] box: introduce indices by UUID
Serge Petrenko
sergepetrenko at tarantool.org
Fri Apr 10 02:50:42 MSK 2020
It is now possible to create an index over UUID values, returned by
`uuid.new()`.
Closes #4268
Closes #2916
@TarantoolBot document
Title: Document uuid field type.
There's a new field type -- UUID, it accepts values returned by
`uuid.new()`.
The index may be either unique or non-unique, nullable or non-nullable,
and may be a primary key.
The values in an index are ordered lexicographically by their string
representation.
To create an index over a uuid field for space `test`, say:
```
box.space.test:create_index("pk", {parts={1, 'uuid'}})
```
Now you may insert uuids into the space:
```
tarantool> box.space.test:insert{uuid.new()}
---
- [e631fdcc-0e8a-4d2f-83fd-b0ce6762b13f]
...
tarantool> box.space.test:insert{uuid.fromstr('64d22e4d-ac92-4a23-899a-e59f34af5479')}
---
- [64d22e4d-ac92-4a23-899a-e59f34af5479]
...
tarantool> box.space.test:select{}
---
- - [64d22e4d-ac92-4a23-899a-e59f34af5479]
- [e631fdcc-0e8a-4d2f-83fd-b0ce6762b13f]
...
```
---
src/box/field_def.c | 32 +++++++------
src/box/field_def.h | 1 +
src/box/tuple_compare.cc | 59 ++++++++++++++++++++++++
test/engine/ddl.result | 97 ++++++++++++++++++++++++++++++++++++++-
test/engine/ddl.test.lua | 42 ++++++++++++++++-
test/engine/uuid.result | 55 ++++++++++++++++++++++
test/engine/uuid.test.lua | 27 +++++++++++
7 files changed, 298 insertions(+), 15 deletions(-)
create mode 100644 test/engine/uuid.result
create mode 100644 test/engine/uuid.test.lua
diff --git a/src/box/field_def.c b/src/box/field_def.c
index fde4e5a00..82a2493fa 100644
--- a/src/box/field_def.c
+++ b/src/box/field_def.c
@@ -33,6 +33,8 @@
#include "trivia/util.h"
#include "key_def.h"
#include "mp_extension_types.h"
+#include "lib/uuid/mp_uuid.h"
+#include "uuid/tt_uuid.h"
const char *mp_type_strs[] = {
/* .MP_NIL = */ "nil",
@@ -67,6 +69,7 @@ const uint32_t field_mp_type[] = {
(1U << MP_FLOAT) | (1U << MP_DOUBLE) | (1U << MP_STR) |
(1U << MP_BIN) | (1U << MP_BOOL),
/* [FIELD_TYPE_DECIMAL] = */ 0, /* only MP_DECIMAL is supported */
+ /* [FIELD_TYPE_UUID] = */ 0, /* only MP_UUID is supported */
/* [FIELD_TYPE_ARRAY] = */ 1U << MP_ARRAY,
/* [FIELD_TYPE_MAP] = */ (1U << MP_MAP),
};
@@ -82,6 +85,7 @@ const uint32_t field_ext_type[] = {
/* [FIELD_TYPE_VARBINARY] = */ 0,
/* [FIELD_TYPE_SCALAR] = */ 1U << MP_DECIMAL,
/* [FIELD_TYPE_DECIMAL] = */ 1U << MP_DECIMAL,
+ /* [FIELD_TYPE_UUID] = */ 1U << MP_UUID,
/* [FIELD_TYPE_ARRAY] = */ 0,
/* [FIELD_TYPE_MAP] = */ 0,
};
@@ -97,6 +101,7 @@ const char *field_type_strs[] = {
/* [FIELD_TYPE_VARBINARY] = */"varbinary",
/* [FIELD_TYPE_SCALAR] = */ "scalar",
/* [FIELD_TYPE_DECIMAL] = */ "decimal",
+ /* [FIELD_TYPE_UUID] = */ "uuid",
/* [FIELD_TYPE_ARRAY] = */ "array",
/* [FIELD_TYPE_MAP] = */ "map",
};
@@ -123,19 +128,20 @@ field_type_by_name_wrapper(const char *str, uint32_t len)
* values can be stored in the j type.
*/
static const bool field_type_compatibility[] = {
- /* ANY UNSIGNED STRING NUMBER DOUBLE INTEGER BOOLEAN VARBINARY SCALAR DECIMAL ARRAY MAP */
-/* ANY */ true, false, false, false, false, false, false, false, false, false, false, false,
-/* UNSIGNED */ true, true, false, true, false, true, false, false, true, false, false, false,
-/* STRING */ true, false, true, false, false, false, false, false, true, false, false, false,
-/* NUMBER */ true, false, false, true, false, false, false, false, true, false, false, false,
-/* DOUBLE */ true, false, false, true, true, false, false, false, true, false, false, false,
-/* INTEGER */ true, false, false, true, false, true, false, false, true, false, false, false,
-/* BOOLEAN */ true, false, false, false, false, false, true, false, true, false, false, false,
-/* VARBINARY*/ true, false, false, false, false, false, false, true, true, false, false, false,
-/* SCALAR */ true, false, false, false, false, false, false, false, true, false, false, false,
-/* DECIMAL */ true, false, false, true, false, false, false, false, true, true, false, false,
-/* ARRAY */ true, false, false, false, false, false, false, false, false, false, true, false,
-/* MAP */ true, false, false, false, false, false, false, false, false, false, false, true,
+ /* ANY UNSIGNED STRING NUMBER DOUBLE INTEGER BOOLEAN VARBINARY SCALAR DECIMAL UUID ARRAY MAP */
+/* ANY */ true, false, false, false, false, false, false, false, false, false, false, false, false,
+/* UNSIGNED */ true, true, false, true, false, true, false, false, true, false, false, false, false,
+/* STRING */ true, false, true, false, false, false, false, false, true, false, false, false, false,
+/* NUMBER */ true, false, false, true, false, false, false, false, true, false, false, false, false,
+/* DOUBLE */ true, false, false, true, true, false, false, false, true, false, false, false, false,
+/* INTEGER */ true, false, false, true, false, true, false, false, true, false, false, false, false,
+/* BOOLEAN */ true, false, false, false, false, false, true, false, true, false, false, false, false,
+/* VARBINARY*/ true, false, false, false, false, false, false, true, true, false, false, false, false,
+/* SCALAR */ true, false, false, false, false, false, false, false, true, false, false, false, false,
+/* DECIMAL */ true, false, false, true, false, false, false, false, true, true, false, false, false,
+/* UUID */ true, false, false, false, false, false, false, false, false, false, true, false, false,
+/* ARRAY */ true, false, false, false, false, false, false, false, false, false, false, true, false,
+/* MAP */ true, false, false, false, false, false, false, false, false, false, false, false, true,
};
bool
diff --git a/src/box/field_def.h b/src/box/field_def.h
index 8e82369f1..c5cfe5e86 100644
--- a/src/box/field_def.h
+++ b/src/box/field_def.h
@@ -60,6 +60,7 @@ enum field_type {
FIELD_TYPE_VARBINARY,
FIELD_TYPE_SCALAR,
FIELD_TYPE_DECIMAL,
+ FIELD_TYPE_UUID,
FIELD_TYPE_ARRAY,
FIELD_TYPE_MAP,
field_type_MAX
diff --git a/src/box/tuple_compare.cc b/src/box/tuple_compare.cc
index 3f8a0ce24..a47f7ac6d 100644
--- a/src/box/tuple_compare.cc
+++ b/src/box/tuple_compare.cc
@@ -35,6 +35,7 @@
#include <math.h>
#include "lib/core/decimal.h"
#include "lib/core/mp_decimal.h"
+#include "lib/uuid/mp_uuid.h"
#include "lib/core/mp_extension_types.h"
/* {{{ tuple_compare */
@@ -74,6 +75,7 @@ enum mp_class {
MP_CLASS_NUMBER,
MP_CLASS_STR,
MP_CLASS_BIN,
+ MP_CLASS_UUID,
MP_CLASS_ARRAY,
MP_CLASS_MAP,
mp_class_max,
@@ -96,6 +98,7 @@ static enum mp_class mp_classes[] = {
static enum mp_class mp_ext_classes[] = {
/* .MP_UNKNOWN_EXTENSION = */ mp_class_max, /* unsupported */
/* .MP_DECIMAL = */ MP_CLASS_NUMBER,
+ /* .MP_UUID = */ MP_CLASS_UUID,
};
static enum mp_class
@@ -110,6 +113,7 @@ mp_extension_class(const char *data)
assert(mp_typeof(*data) == MP_EXT);
int8_t type;
mp_decode_extl(&data, &type);
+ assert(type >= 0 && type < mp_extension_type_MAX);
return mp_ext_classes[type];
}
@@ -378,6 +382,25 @@ mp_compare_bin(const char *field_a, const char *field_b)
return COMPARE_RESULT(size_a, size_b);
}
+static inline int
+mp_compare_uuid(const char *field_a, const char *field_b)
+{
+ const char *str_a, *str_b;
+ int8_t type;
+ uint32_t len;
+ str_a = mp_decode_ext(&field_a, &type, &len);
+ assert(type == MP_UUID && len == UUID_PACKED_LEN);
+ str_b = mp_decode_ext(&field_b, &type, &len);
+ assert(type == MP_UUID && len == UUID_PACKED_LEN);
+ /*
+ * Packed uuid fields are in the right order for
+ * comparison and are big-endian, so memcmp is
+ * the same as tt_uuid_compare() and lets us
+ * spare 2 mp_uuid_unpack() calls.
+ */
+ return memcmp(str_a, str_b, UUID_PACKED_LEN);
+}
+
typedef int (*mp_compare_f)(const char *, const char *);
static mp_compare_f mp_class_comparators[] = {
/* .MP_CLASS_NIL = */ NULL,
@@ -385,6 +408,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_ARRAY = */ NULL,
/* .MP_CLASS_MAP = */ NULL,
};
@@ -463,6 +487,8 @@ tuple_compare_field(const char *field_a, const char *field_b,
mp_compare_scalar(field_a, field_b);
case FIELD_TYPE_DECIMAL:
return mp_compare_decimal(field_a, field_b);
+ case FIELD_TYPE_UUID:
+ return mp_compare_uuid(field_a, field_b);
default:
unreachable();
return 0;
@@ -501,6 +527,8 @@ tuple_compare_field_with_type(const char *field_a, enum mp_type a_type,
case FIELD_TYPE_DECIMAL:
return mp_compare_number_with_type(field_a, a_type,
field_b, b_type);
+ case FIELD_TYPE_UUID:
+ return mp_compare_uuid(field_a, field_b);
default:
unreachable();
return 0;
@@ -1578,6 +1606,21 @@ hint_decimal(decimal_t *dec)
return hint_create(MP_CLASS_NUMBER, val);
}
+static inline hint_t
+hint_uuid_raw(const char *data)
+{
+ /*
+ * Packed UUID fields are big-endian and are stored in the
+ * order allowing lexicographical comparison, so the first
+ * 8 bytes of the packed representation constitute a big
+ * endian unsigned integer. Use it as a hint.
+ */
+ uint64_t val = mp_load_u64(&data);
+ /* Make space for class representation. */
+ val >>= HINT_CLASS_BITS;
+ return hint_create(MP_CLASS_UUID, val);
+}
+
static inline uint64_t
hint_str_raw(const char *s, uint32_t len)
{
@@ -1698,6 +1741,17 @@ field_hint_decimal(const char *field)
}
}
+static inline hint_t
+field_hint_uuid(const char *field)
+{
+ assert(mp_typeof(*field) == MP_EXT);
+ int8_t type;
+ uint32_t len;
+ const char *data = mp_decode_ext(&field, &type, &len);
+ assert(type == MP_UUID && len == UUID_PACKED_LEN);
+ return hint_uuid_raw(data);
+}
+
static inline hint_t
field_hint_string(const char *field, struct coll *coll)
{
@@ -1782,6 +1836,8 @@ field_hint(const char *field, struct coll *coll)
return field_hint_scalar(field, coll);
case FIELD_TYPE_DECIMAL:
return field_hint_decimal(field);
+ case FIELD_TYPE_UUID:
+ return field_hint_uuid(field);
default:
unreachable();
}
@@ -1893,6 +1949,9 @@ key_def_set_hint_func(struct key_def *def)
case FIELD_TYPE_DECIMAL:
key_def_set_hint_func<FIELD_TYPE_DECIMAL>(def);
break;
+ case FIELD_TYPE_UUID:
+ key_def_set_hint_func<FIELD_TYPE_UUID>(def);
+ break;
default:
/* Invalid key definition. */
def->key_hint = NULL;
diff --git a/test/engine/ddl.result b/test/engine/ddl.result
index 67b22ed9e..b7c04aafe 100644
--- a/test/engine/ddl.result
+++ b/test/engine/ddl.result
@@ -1037,6 +1037,9 @@ s:drop()
decimal = require('decimal')
---
...
+uuid = require('uuid')
+---
+...
-- Ensure that vinyl correctly process field count change.
s = box.schema.space.create('test', {engine = engine, field_count = 2})
---
@@ -1098,13 +1101,16 @@ format[10] = {name = 'field10', type = 'map'}
format[11] = {name = 'field11', type = 'decimal'}
---
...
+format[12] = {name = 'field12', type = 'uuid'}
+---
+...
s = box.schema.space.create('test', {engine = engine, format = format})
---
...
pk = s:create_index('pk')
---
...
-t = s:replace{1, {2}, 3, '4', 5.5, -6, true, -8, {9, 9}, {val = 10}, decimal.new(-11.11)}
+t = s:replace{1, {2}, 3, '4', 5.5, -6, true, -8, {9, 9}, {val = 10}, decimal.new(-11.11), uuid.new()}
---
...
inspector:cmd("setopt delimiter ';'")
@@ -1171,6 +1177,11 @@ fail_format_change(3, 'decimal')
---
- 'Tuple field 3 type does not match one required by operation: expected decimal'
...
+-- unsigned --X--> uuid
+fail_format_change(3, 'uuid')
+---
+- 'Tuple field 3 type does not match one required by operation: expected uuid'
+...
-- string -----> any
ok_format_change(4, 'any')
---
@@ -1189,6 +1200,11 @@ fail_format_change(4, 'decimal')
---
- 'Tuple field 4 type does not match one required by operation: expected decimal'
...
+-- string --X--> uuid
+fail_format_change(4, 'uuid')
+---
+- 'Tuple field 4 type does not match one required by operation: expected uuid'
+...
-- number -----> any
ok_format_change(5, 'any')
---
@@ -1207,6 +1223,11 @@ fail_format_change(5, 'decimal')
---
- 'Tuple field 5 type does not match one required by operation: expected decimal'
...
+-- number --X--> uuid
+fail_format_change(5, 'uuid')
+---
+- 'Tuple field 5 type does not match one required by operation: expected uuid'
+...
-- integer -----> any
ok_format_change(6, 'any')
---
@@ -1229,6 +1250,11 @@ fail_format_change(6, 'decimal')
---
- 'Tuple field 6 type does not match one required by operation: expected decimal'
...
+-- integer --X--> uuid
+fail_format_change(6, 'uuid')
+---
+- 'Tuple field 6 type does not match one required by operation: expected uuid'
+...
-- boolean -----> any
ok_format_change(7, 'any')
---
@@ -1247,6 +1273,11 @@ fail_format_change(7, 'decimal')
---
- 'Tuple field 7 type does not match one required by operation: expected decimal'
...
+-- boolean --X--> uuid
+fail_format_change(7, 'uuid')
+---
+- 'Tuple field 7 type does not match one required by operation: expected uuid'
+...
-- scalar -----> any
ok_format_change(8, 'any')
---
@@ -1261,6 +1292,11 @@ fail_format_change(8, 'decimal')
---
- 'Tuple field 8 type does not match one required by operation: expected decimal'
...
+-- scalar --X--> uuid
+fail_format_change(8, 'uuid')
+---
+- 'Tuple field 8 type does not match one required by operation: expected uuid'
+...
-- array -----> any
ok_format_change(9, 'any')
---
@@ -1275,6 +1311,11 @@ fail_format_change(9, 'decimal')
---
- 'Tuple field 9 type does not match one required by operation: expected decimal'
...
+-- array --X--> uuid
+fail_format_change(9, 'uuid')
+---
+- 'Tuple field 9 type does not match one required by operation: expected uuid'
+...
-- map -----> any
ok_format_change(10, 'any')
---
@@ -1289,6 +1330,11 @@ fail_format_change(10, 'decimal')
---
- 'Tuple field 10 type does not match one required by operation: expected decimal'
...
+-- map --X--> uuid
+fail_format_change(10, 'uuid')
+---
+- 'Tuple field 10 type does not match one required by operation: expected uuid'
+...
-- decimal ----> any
ok_format_change(11, 'any')
---
@@ -1326,6 +1372,55 @@ fail_format_change(11, 'array')
---
- 'Tuple field 11 type does not match one required by operation: expected array'
...
+-- decimal --X--> uuid
+fail_format_change(11, 'uuid')
+---
+- 'Tuple field 11 type does not match one required by operation: expected uuid'
+...
+-- uuid ----> any
+ok_format_change(12, 'any')
+---
+...
+-- uuid --X--> number
+fail_format_change(12, 'number')
+---
+- 'Tuple field 12 type does not match one required by operation: expected number'
+...
+-- uuid --X--> scalar
+fail_format_change(12, 'scalar')
+---
+- 'Tuple field 12 type does not match one required by operation: expected scalar'
+...
+-- uuid --X--> string
+fail_format_change(12, 'string')
+---
+- 'Tuple field 12 type does not match one required by operation: expected string'
+...
+-- uuid --X--> integer
+fail_format_change(12, 'integer')
+---
+- 'Tuple field 12 type does not match one required by operation: expected integer'
+...
+-- uuid --X--> unsigned
+fail_format_change(12, 'unsigned')
+---
+- 'Tuple field 12 type does not match one required by operation: expected unsigned'
+...
+-- uuid --X--> map
+fail_format_change(12, 'map')
+---
+- 'Tuple field 12 type does not match one required by operation: expected map'
+...
+-- uuid --X--> array
+fail_format_change(12, 'array')
+---
+- 'Tuple field 12 type does not match one required by operation: expected array'
+...
+-- uuid --X--> decimal
+fail_format_change(12, 'decimal')
+---
+- 'Tuple field 12 type does not match one required by operation: expected decimal'
+...
s:drop()
---
...
diff --git a/test/engine/ddl.test.lua b/test/engine/ddl.test.lua
index e761966d7..7d408807f 100644
--- a/test/engine/ddl.test.lua
+++ b/test/engine/ddl.test.lua
@@ -356,6 +356,7 @@ s:drop()
--
decimal = require('decimal')
+uuid = require('uuid')
-- Ensure that vinyl correctly process field count change.
s = box.schema.space.create('test', {engine = engine, field_count = 2})
@@ -379,10 +380,11 @@ format[8] = {name = 'field8', type = 'scalar'}
format[9] = {name = 'field9', type = 'array'}
format[10] = {name = 'field10', type = 'map'}
format[11] = {name = 'field11', type = 'decimal'}
+format[12] = {name = 'field12', type = 'uuid'}
s = box.schema.space.create('test', {engine = engine, format = format})
pk = s:create_index('pk')
-t = s:replace{1, {2}, 3, '4', 5.5, -6, true, -8, {9, 9}, {val = 10}, decimal.new(-11.11)}
+t = s:replace{1, {2}, 3, '4', 5.5, -6, true, -8, {9, 9}, {val = 10}, decimal.new(-11.11), uuid.new()}
inspector:cmd("setopt delimiter ';'")
function fail_format_change(fieldno, new_type)
@@ -421,6 +423,8 @@ ok_format_change(3, 'scalar')
fail_format_change(3, 'map')
-- unsigned --X--> decimal
fail_format_change(3, 'decimal')
+-- unsigned --X--> uuid
+fail_format_change(3, 'uuid')
-- string -----> any
ok_format_change(4, 'any')
@@ -430,6 +434,8 @@ ok_format_change(4, 'scalar')
fail_format_change(4, 'boolean')
-- string --X--> decimal
fail_format_change(4, 'decimal')
+-- string --X--> uuid
+fail_format_change(4, 'uuid')
-- number -----> any
ok_format_change(5, 'any')
@@ -439,6 +445,8 @@ ok_format_change(5, 'scalar')
fail_format_change(5, 'integer')
-- number --X--> decimal
fail_format_change(5, 'decimal')
+-- number --X--> uuid
+fail_format_change(5, 'uuid')
-- integer -----> any
ok_format_change(6, 'any')
@@ -450,6 +458,8 @@ ok_format_change(6, 'scalar')
fail_format_change(6, 'unsigned')
-- integer --X--> decimal
fail_format_change(6, 'decimal')
+-- integer --X--> uuid
+fail_format_change(6, 'uuid')
-- boolean -----> any
ok_format_change(7, 'any')
@@ -459,6 +469,8 @@ ok_format_change(7, 'scalar')
fail_format_change(7, 'string')
-- boolead --X--> decimal
fail_format_change(7, 'decimal')
+-- boolean --X--> uuid
+fail_format_change(7, 'uuid')
-- scalar -----> any
ok_format_change(8, 'any')
@@ -466,6 +478,8 @@ ok_format_change(8, 'any')
fail_format_change(8, 'unsigned')
-- scalar --X--> decimal
fail_format_change(8, 'decimal')
+-- scalar --X--> uuid
+fail_format_change(8, 'uuid')
-- array -----> any
ok_format_change(9, 'any')
@@ -473,6 +487,8 @@ ok_format_change(9, 'any')
fail_format_change(9, 'scalar')
-- arary --X--> decimal
fail_format_change(9, 'decimal')
+-- array --X--> uuid
+fail_format_change(9, 'uuid')
-- map -----> any
ok_format_change(10, 'any')
@@ -480,6 +496,8 @@ ok_format_change(10, 'any')
fail_format_change(10, 'scalar')
-- map --X--> decimal
fail_format_change(10, 'decimal')
+-- map --X--> uuid
+fail_format_change(10, 'uuid')
-- decimal ----> any
ok_format_change(11, 'any')
@@ -497,6 +515,28 @@ fail_format_change(11, 'unsigned')
fail_format_change(11, 'map')
-- decimal --X--> array
fail_format_change(11, 'array')
+-- decimal --X--> uuid
+fail_format_change(11, 'uuid')
+
+-- uuid ----> any
+ok_format_change(12, 'any')
+-- uuid --X--> number
+fail_format_change(12, 'number')
+-- uuid --X--> scalar
+fail_format_change(12, 'scalar')
+-- uuid --X--> string
+fail_format_change(12, 'string')
+-- uuid --X--> integer
+fail_format_change(12, 'integer')
+-- uuid --X--> unsigned
+fail_format_change(12, 'unsigned')
+-- uuid --X--> map
+fail_format_change(12, 'map')
+-- uuid --X--> array
+fail_format_change(12, 'array')
+-- uuid --X--> decimal
+fail_format_change(12, 'decimal')
+
s:drop()
-- Check new fields adding.
diff --git a/test/engine/uuid.result b/test/engine/uuid.result
new file mode 100644
index 000000000..c4c186e92
--- /dev/null
+++ b/test/engine/uuid.result
@@ -0,0 +1,55 @@
+-- test-run result file version 2
+env = require('test_run')
+ | ---
+ | ...
+test_run = env.new()
+ | ---
+ | ...
+engine = test_run:get_cfg('engine')
+ | ---
+ | ...
+
+uuid = require('uuid')
+ | ---
+ | ...
+ffi = require('ffi')
+ | ---
+ | ...
+
+-- check uuid indices
+_ = box.schema.space.create('test', {engine=engine})
+ | ---
+ | ...
+_ = box.space.test:create_index('pk', {parts={1,'uuid'}})
+ | ---
+ | ...
+
+for i = 1,16 do\
+ box.space.test:insert{uuid.new()}\
+end
+ | ---
+ | ...
+
+a = box.space.test:select{}
+ | ---
+ | ...
+err = nil
+ | ---
+ | ...
+for i = 1, #a - 1 do\
+ if tostring(a[i][1]) >= tostring(a[i+1][1]) then\
+ err = {a[i][1], a[i+1][1]}\
+ break\
+ end\
+end
+ | ---
+ | ...
+
+err
+ | ---
+ | - null
+ | ...
+
+box.space.test:drop()
+ | ---
+ | ...
diff --git a/test/engine/uuid.test.lua b/test/engine/uuid.test.lua
new file mode 100644
index 000000000..f34795ce4
--- /dev/null
+++ b/test/engine/uuid.test.lua
@@ -0,0 +1,27 @@
+env = require('test_run')
+test_run = env.new()
+engine = test_run:get_cfg('engine')
+
+uuid = require('uuid')
+ffi = require('ffi')
+
+-- check uuid indices
+_ = box.schema.space.create('test', {engine=engine})
+_ = box.space.test:create_index('pk', {parts={1,'uuid'}})
+
+for i = 1,16 do\
+ box.space.test:insert{uuid.new()}\
+end
+
+a = box.space.test:select{}
+err = nil
+for i = 1, #a - 1 do\
+ if tostring(a[i][1]) >= tostring(a[i+1][1]) then\
+ err = {a[i][1], a[i+1][1]}\
+ break\
+ end\
+end
+
+err
+
+box.space.test:drop()
--
2.21.1 (Apple Git-122.3)
More information about the Tarantool-patches
mailing list