MDEV-29959 UUID Sorting

* UUIDs version >= 6 are now stored without byte-swapping
* UUIDs with version >=8 and variant=0 are now considered invalid
* old tables are supported
* old (always byte swapped) and new (swapped for version < 6) UUIDs
  can be compared and converted transparently
This commit is contained in:
Sergei Golubchik 2023-05-17 16:14:24 +02:00
parent 8bf25f3fb3
commit ef84f8137b
12 changed files with 906 additions and 329 deletions

View file

@ -33,7 +33,7 @@ String *Item_func_sys_guid::val_str(String *str)
const Type_handler *Item_func_uuid::type_handler() const
{
return UUIDBundle::singleton();
return Type_handler_uuid_new::singleton();
}
bool Item_func_uuid::val_native(THD *, Native *to)

View file

@ -0,0 +1,425 @@
create table t1 (a uuid, b int not null, index (a));
insert t1 select sformat('11223344-5566-{:x}777-{}888-99aabbccddee', seq div 4, elt(1+(seq % 4),0,8,'c','e')),seq from seq_0_to_63;
Warnings:
Warning 1292 Incorrect uuid value: '11223344-5566-8777-0888-99aabbccddee' for column `test`.`t1`.`a` at row 33
Warning 1292 Incorrect uuid value: '11223344-5566-9777-0888-99aabbccddee' for column `test`.`t1`.`a` at row 37
Warning 1292 Incorrect uuid value: '11223344-5566-a777-0888-99aabbccddee' for column `test`.`t1`.`a` at row 41
Warning 1292 Incorrect uuid value: '11223344-5566-b777-0888-99aabbccddee' for column `test`.`t1`.`a` at row 45
Warning 1292 Incorrect uuid value: '11223344-5566-c777-0888-99aabbccddee' for column `test`.`t1`.`a` at row 49
Warning 1292 Incorrect uuid value: '11223344-5566-d777-0888-99aabbccddee' for column `test`.`t1`.`a` at row 53
Warning 1292 Incorrect uuid value: '11223344-5566-e777-0888-99aabbccddee' for column `test`.`t1`.`a` at row 57
Warning 1292 Incorrect uuid value: '11223344-5566-f777-0888-99aabbccddee' for column `test`.`t1`.`a` at row 61
select * from t1;
a b
11223344-5566-0777-0888-99aabbccddee 0
11223344-5566-0777-8888-99aabbccddee 1
11223344-5566-0777-c888-99aabbccddee 2
11223344-5566-0777-e888-99aabbccddee 3
11223344-5566-1777-0888-99aabbccddee 4
11223344-5566-1777-8888-99aabbccddee 5
11223344-5566-1777-c888-99aabbccddee 6
11223344-5566-1777-e888-99aabbccddee 7
11223344-5566-2777-0888-99aabbccddee 8
11223344-5566-2777-8888-99aabbccddee 9
11223344-5566-2777-c888-99aabbccddee 10
11223344-5566-2777-e888-99aabbccddee 11
11223344-5566-3777-0888-99aabbccddee 12
11223344-5566-3777-8888-99aabbccddee 13
11223344-5566-3777-c888-99aabbccddee 14
11223344-5566-3777-e888-99aabbccddee 15
11223344-5566-4777-0888-99aabbccddee 16
11223344-5566-4777-8888-99aabbccddee 17
11223344-5566-4777-c888-99aabbccddee 18
11223344-5566-4777-e888-99aabbccddee 19
11223344-5566-5777-0888-99aabbccddee 20
11223344-5566-5777-8888-99aabbccddee 21
11223344-5566-5777-c888-99aabbccddee 22
11223344-5566-5777-e888-99aabbccddee 23
11223344-5566-6777-0888-99aabbccddee 24
11223344-5566-6777-8888-99aabbccddee 25
11223344-5566-6777-c888-99aabbccddee 26
11223344-5566-6777-e888-99aabbccddee 27
11223344-5566-7777-0888-99aabbccddee 28
11223344-5566-7777-8888-99aabbccddee 29
11223344-5566-7777-c888-99aabbccddee 30
11223344-5566-7777-e888-99aabbccddee 31
NULL 32
11223344-5566-8777-8888-99aabbccddee 33
11223344-5566-8777-c888-99aabbccddee 34
11223344-5566-8777-e888-99aabbccddee 35
NULL 36
11223344-5566-9777-8888-99aabbccddee 37
11223344-5566-9777-c888-99aabbccddee 38
11223344-5566-9777-e888-99aabbccddee 39
NULL 40
11223344-5566-a777-8888-99aabbccddee 41
11223344-5566-a777-c888-99aabbccddee 42
11223344-5566-a777-e888-99aabbccddee 43
NULL 44
11223344-5566-b777-8888-99aabbccddee 45
11223344-5566-b777-c888-99aabbccddee 46
11223344-5566-b777-e888-99aabbccddee 47
NULL 48
11223344-5566-c777-8888-99aabbccddee 49
11223344-5566-c777-c888-99aabbccddee 50
11223344-5566-c777-e888-99aabbccddee 51
NULL 52
11223344-5566-d777-8888-99aabbccddee 53
11223344-5566-d777-c888-99aabbccddee 54
11223344-5566-d777-e888-99aabbccddee 55
NULL 56
11223344-5566-e777-8888-99aabbccddee 57
11223344-5566-e777-c888-99aabbccddee 58
11223344-5566-e777-e888-99aabbccddee 59
NULL 60
11223344-5566-f777-8888-99aabbccddee 61
11223344-5566-f777-c888-99aabbccddee 62
11223344-5566-f777-e888-99aabbccddee 63
select * from t1 order by a;
a b
NULL 40
NULL 32
NULL 36
NULL 44
NULL 48
NULL 52
NULL 56
NULL 60
11223344-5566-0777-0888-99aabbccddee 0
11223344-5566-1777-0888-99aabbccddee 4
11223344-5566-2777-0888-99aabbccddee 8
11223344-5566-3777-0888-99aabbccddee 12
11223344-5566-4777-0888-99aabbccddee 16
11223344-5566-5777-0888-99aabbccddee 20
11223344-5566-6777-0888-99aabbccddee 24
11223344-5566-6777-8888-99aabbccddee 25
11223344-5566-6777-c888-99aabbccddee 26
11223344-5566-6777-e888-99aabbccddee 27
11223344-5566-7777-0888-99aabbccddee 28
11223344-5566-7777-8888-99aabbccddee 29
11223344-5566-7777-c888-99aabbccddee 30
11223344-5566-7777-e888-99aabbccddee 31
11223344-5566-8777-8888-99aabbccddee 33
11223344-5566-8777-c888-99aabbccddee 34
11223344-5566-8777-e888-99aabbccddee 35
11223344-5566-9777-8888-99aabbccddee 37
11223344-5566-9777-c888-99aabbccddee 38
11223344-5566-9777-e888-99aabbccddee 39
11223344-5566-a777-8888-99aabbccddee 41
11223344-5566-a777-c888-99aabbccddee 42
11223344-5566-a777-e888-99aabbccddee 43
11223344-5566-b777-8888-99aabbccddee 45
11223344-5566-b777-c888-99aabbccddee 46
11223344-5566-b777-e888-99aabbccddee 47
11223344-5566-c777-8888-99aabbccddee 49
11223344-5566-c777-c888-99aabbccddee 50
11223344-5566-c777-e888-99aabbccddee 51
11223344-5566-d777-8888-99aabbccddee 53
11223344-5566-d777-c888-99aabbccddee 54
11223344-5566-d777-e888-99aabbccddee 55
11223344-5566-e777-8888-99aabbccddee 57
11223344-5566-e777-c888-99aabbccddee 58
11223344-5566-e777-e888-99aabbccddee 59
11223344-5566-f777-8888-99aabbccddee 61
11223344-5566-f777-c888-99aabbccddee 62
11223344-5566-f777-e888-99aabbccddee 63
11223344-5566-0777-8888-99aabbccddee 1
11223344-5566-1777-8888-99aabbccddee 5
11223344-5566-2777-8888-99aabbccddee 9
11223344-5566-3777-8888-99aabbccddee 13
11223344-5566-4777-8888-99aabbccddee 17
11223344-5566-5777-8888-99aabbccddee 21
11223344-5566-0777-c888-99aabbccddee 2
11223344-5566-1777-c888-99aabbccddee 6
11223344-5566-2777-c888-99aabbccddee 10
11223344-5566-3777-c888-99aabbccddee 14
11223344-5566-4777-c888-99aabbccddee 18
11223344-5566-5777-c888-99aabbccddee 22
11223344-5566-0777-e888-99aabbccddee 3
11223344-5566-1777-e888-99aabbccddee 7
11223344-5566-2777-e888-99aabbccddee 11
11223344-5566-3777-e888-99aabbccddee 15
11223344-5566-4777-e888-99aabbccddee 19
11223344-5566-5777-e888-99aabbccddee 23
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` uuid DEFAULT NULL,
`b` int(11) NOT NULL,
KEY `a` (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
# now let's use the table as above, but created in 10.11.4
select * from t2;
a b
11223344-5566-0777-0888-99aabbccddee 0
11223344-5566-0777-8888-99aabbccddee 1
11223344-5566-0777-c888-99aabbccddee 2
11223344-5566-0777-e888-99aabbccddee 3
11223344-5566-1777-0888-99aabbccddee 4
11223344-5566-1777-8888-99aabbccddee 5
11223344-5566-1777-c888-99aabbccddee 6
11223344-5566-1777-e888-99aabbccddee 7
11223344-5566-2777-0888-99aabbccddee 8
11223344-5566-2777-8888-99aabbccddee 9
11223344-5566-2777-c888-99aabbccddee 10
11223344-5566-2777-e888-99aabbccddee 11
11223344-5566-3777-0888-99aabbccddee 12
11223344-5566-3777-8888-99aabbccddee 13
11223344-5566-3777-c888-99aabbccddee 14
11223344-5566-3777-e888-99aabbccddee 15
11223344-5566-4777-0888-99aabbccddee 16
11223344-5566-4777-8888-99aabbccddee 17
11223344-5566-4777-c888-99aabbccddee 18
11223344-5566-4777-e888-99aabbccddee 19
11223344-5566-5777-0888-99aabbccddee 20
11223344-5566-5777-8888-99aabbccddee 21
11223344-5566-5777-c888-99aabbccddee 22
11223344-5566-5777-e888-99aabbccddee 23
11223344-5566-6777-0888-99aabbccddee 24
11223344-5566-6777-8888-99aabbccddee 25
11223344-5566-6777-c888-99aabbccddee 26
11223344-5566-6777-e888-99aabbccddee 27
11223344-5566-7777-0888-99aabbccddee 28
11223344-5566-7777-8888-99aabbccddee 29
11223344-5566-7777-c888-99aabbccddee 30
11223344-5566-7777-e888-99aabbccddee 31
11223344-5566-8777-0888-99aabbccddee 32
11223344-5566-8777-8888-99aabbccddee 33
11223344-5566-8777-c888-99aabbccddee 34
11223344-5566-8777-e888-99aabbccddee 35
11223344-5566-9777-0888-99aabbccddee 36
11223344-5566-9777-8888-99aabbccddee 37
11223344-5566-9777-c888-99aabbccddee 38
11223344-5566-9777-e888-99aabbccddee 39
11223344-5566-a777-0888-99aabbccddee 40
11223344-5566-a777-8888-99aabbccddee 41
11223344-5566-a777-c888-99aabbccddee 42
11223344-5566-a777-e888-99aabbccddee 43
11223344-5566-b777-0888-99aabbccddee 44
11223344-5566-b777-8888-99aabbccddee 45
11223344-5566-b777-c888-99aabbccddee 46
11223344-5566-b777-e888-99aabbccddee 47
11223344-5566-c777-0888-99aabbccddee 48
11223344-5566-c777-8888-99aabbccddee 49
11223344-5566-c777-c888-99aabbccddee 50
11223344-5566-c777-e888-99aabbccddee 51
11223344-5566-d777-0888-99aabbccddee 52
11223344-5566-d777-8888-99aabbccddee 53
11223344-5566-d777-c888-99aabbccddee 54
11223344-5566-d777-e888-99aabbccddee 55
11223344-5566-e777-0888-99aabbccddee 56
11223344-5566-e777-8888-99aabbccddee 57
11223344-5566-e777-c888-99aabbccddee 58
11223344-5566-e777-e888-99aabbccddee 59
11223344-5566-f777-0888-99aabbccddee 60
11223344-5566-f777-8888-99aabbccddee 61
11223344-5566-f777-c888-99aabbccddee 62
11223344-5566-f777-e888-99aabbccddee 63
select * from t2 order by a;
a b
11223344-5566-0777-0888-99aabbccddee 0
11223344-5566-1777-0888-99aabbccddee 4
11223344-5566-2777-0888-99aabbccddee 8
11223344-5566-3777-0888-99aabbccddee 12
11223344-5566-4777-0888-99aabbccddee 16
11223344-5566-5777-0888-99aabbccddee 20
11223344-5566-6777-0888-99aabbccddee 24
11223344-5566-7777-0888-99aabbccddee 28
11223344-5566-8777-0888-99aabbccddee 32
11223344-5566-9777-0888-99aabbccddee 36
11223344-5566-a777-0888-99aabbccddee 40
11223344-5566-b777-0888-99aabbccddee 44
11223344-5566-c777-0888-99aabbccddee 48
11223344-5566-d777-0888-99aabbccddee 52
11223344-5566-e777-0888-99aabbccddee 56
11223344-5566-f777-0888-99aabbccddee 60
11223344-5566-0777-8888-99aabbccddee 1
11223344-5566-1777-8888-99aabbccddee 5
11223344-5566-2777-8888-99aabbccddee 9
11223344-5566-3777-8888-99aabbccddee 13
11223344-5566-4777-8888-99aabbccddee 17
11223344-5566-5777-8888-99aabbccddee 21
11223344-5566-6777-8888-99aabbccddee 25
11223344-5566-7777-8888-99aabbccddee 29
11223344-5566-8777-8888-99aabbccddee 33
11223344-5566-9777-8888-99aabbccddee 37
11223344-5566-a777-8888-99aabbccddee 41
11223344-5566-b777-8888-99aabbccddee 45
11223344-5566-c777-8888-99aabbccddee 49
11223344-5566-d777-8888-99aabbccddee 53
11223344-5566-e777-8888-99aabbccddee 57
11223344-5566-f777-8888-99aabbccddee 61
11223344-5566-0777-c888-99aabbccddee 2
11223344-5566-1777-c888-99aabbccddee 6
11223344-5566-2777-c888-99aabbccddee 10
11223344-5566-3777-c888-99aabbccddee 14
11223344-5566-4777-c888-99aabbccddee 18
11223344-5566-5777-c888-99aabbccddee 22
11223344-5566-6777-c888-99aabbccddee 26
11223344-5566-7777-c888-99aabbccddee 30
11223344-5566-8777-c888-99aabbccddee 34
11223344-5566-9777-c888-99aabbccddee 38
11223344-5566-a777-c888-99aabbccddee 42
11223344-5566-b777-c888-99aabbccddee 46
11223344-5566-c777-c888-99aabbccddee 50
11223344-5566-d777-c888-99aabbccddee 54
11223344-5566-e777-c888-99aabbccddee 58
11223344-5566-f777-c888-99aabbccddee 62
11223344-5566-0777-e888-99aabbccddee 3
11223344-5566-1777-e888-99aabbccddee 7
11223344-5566-2777-e888-99aabbccddee 11
11223344-5566-3777-e888-99aabbccddee 15
11223344-5566-4777-e888-99aabbccddee 19
11223344-5566-5777-e888-99aabbccddee 23
11223344-5566-6777-e888-99aabbccddee 27
11223344-5566-7777-e888-99aabbccddee 31
11223344-5566-8777-e888-99aabbccddee 35
11223344-5566-9777-e888-99aabbccddee 39
11223344-5566-a777-e888-99aabbccddee 43
11223344-5566-b777-e888-99aabbccddee 47
11223344-5566-c777-e888-99aabbccddee 51
11223344-5566-d777-e888-99aabbccddee 55
11223344-5566-e777-e888-99aabbccddee 59
11223344-5566-f777-e888-99aabbccddee 63
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`a` uuid DEFAULT NULL,
`b` int(11) NOT NULL,
KEY `a` (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
select * from t1, t2 where t1.a=t2.a;
a b a b
11223344-5566-0777-0888-99aabbccddee 0 11223344-5566-0777-0888-99aabbccddee 0
11223344-5566-0777-8888-99aabbccddee 1 11223344-5566-0777-8888-99aabbccddee 1
11223344-5566-0777-c888-99aabbccddee 2 11223344-5566-0777-c888-99aabbccddee 2
11223344-5566-0777-e888-99aabbccddee 3 11223344-5566-0777-e888-99aabbccddee 3
11223344-5566-1777-0888-99aabbccddee 4 11223344-5566-1777-0888-99aabbccddee 4
11223344-5566-1777-8888-99aabbccddee 5 11223344-5566-1777-8888-99aabbccddee 5
11223344-5566-1777-c888-99aabbccddee 6 11223344-5566-1777-c888-99aabbccddee 6
11223344-5566-1777-e888-99aabbccddee 7 11223344-5566-1777-e888-99aabbccddee 7
11223344-5566-2777-0888-99aabbccddee 8 11223344-5566-2777-0888-99aabbccddee 8
11223344-5566-2777-8888-99aabbccddee 9 11223344-5566-2777-8888-99aabbccddee 9
11223344-5566-2777-c888-99aabbccddee 10 11223344-5566-2777-c888-99aabbccddee 10
11223344-5566-2777-e888-99aabbccddee 11 11223344-5566-2777-e888-99aabbccddee 11
11223344-5566-3777-0888-99aabbccddee 12 11223344-5566-3777-0888-99aabbccddee 12
11223344-5566-3777-8888-99aabbccddee 13 11223344-5566-3777-8888-99aabbccddee 13
11223344-5566-3777-c888-99aabbccddee 14 11223344-5566-3777-c888-99aabbccddee 14
11223344-5566-3777-e888-99aabbccddee 15 11223344-5566-3777-e888-99aabbccddee 15
11223344-5566-4777-0888-99aabbccddee 16 11223344-5566-4777-0888-99aabbccddee 16
11223344-5566-4777-8888-99aabbccddee 17 11223344-5566-4777-8888-99aabbccddee 17
11223344-5566-4777-c888-99aabbccddee 18 11223344-5566-4777-c888-99aabbccddee 18
11223344-5566-4777-e888-99aabbccddee 19 11223344-5566-4777-e888-99aabbccddee 19
11223344-5566-5777-0888-99aabbccddee 20 11223344-5566-5777-0888-99aabbccddee 20
11223344-5566-5777-8888-99aabbccddee 21 11223344-5566-5777-8888-99aabbccddee 21
11223344-5566-5777-c888-99aabbccddee 22 11223344-5566-5777-c888-99aabbccddee 22
11223344-5566-5777-e888-99aabbccddee 23 11223344-5566-5777-e888-99aabbccddee 23
11223344-5566-6777-0888-99aabbccddee 24 11223344-5566-6777-0888-99aabbccddee 24
11223344-5566-6777-8888-99aabbccddee 25 11223344-5566-6777-8888-99aabbccddee 25
11223344-5566-6777-c888-99aabbccddee 26 11223344-5566-6777-c888-99aabbccddee 26
11223344-5566-6777-e888-99aabbccddee 27 11223344-5566-6777-e888-99aabbccddee 27
11223344-5566-7777-0888-99aabbccddee 28 11223344-5566-7777-0888-99aabbccddee 28
11223344-5566-7777-8888-99aabbccddee 29 11223344-5566-7777-8888-99aabbccddee 29
11223344-5566-7777-c888-99aabbccddee 30 11223344-5566-7777-c888-99aabbccddee 30
11223344-5566-7777-e888-99aabbccddee 31 11223344-5566-7777-e888-99aabbccddee 31
11223344-5566-8777-8888-99aabbccddee 33 11223344-5566-8777-8888-99aabbccddee 33
11223344-5566-8777-c888-99aabbccddee 34 11223344-5566-8777-c888-99aabbccddee 34
11223344-5566-8777-e888-99aabbccddee 35 11223344-5566-8777-e888-99aabbccddee 35
11223344-5566-9777-8888-99aabbccddee 37 11223344-5566-9777-8888-99aabbccddee 37
11223344-5566-9777-c888-99aabbccddee 38 11223344-5566-9777-c888-99aabbccddee 38
11223344-5566-9777-e888-99aabbccddee 39 11223344-5566-9777-e888-99aabbccddee 39
11223344-5566-a777-8888-99aabbccddee 41 11223344-5566-a777-8888-99aabbccddee 41
11223344-5566-a777-c888-99aabbccddee 42 11223344-5566-a777-c888-99aabbccddee 42
11223344-5566-a777-e888-99aabbccddee 43 11223344-5566-a777-e888-99aabbccddee 43
11223344-5566-b777-8888-99aabbccddee 45 11223344-5566-b777-8888-99aabbccddee 45
11223344-5566-b777-c888-99aabbccddee 46 11223344-5566-b777-c888-99aabbccddee 46
11223344-5566-b777-e888-99aabbccddee 47 11223344-5566-b777-e888-99aabbccddee 47
11223344-5566-c777-8888-99aabbccddee 49 11223344-5566-c777-8888-99aabbccddee 49
11223344-5566-c777-c888-99aabbccddee 50 11223344-5566-c777-c888-99aabbccddee 50
11223344-5566-c777-e888-99aabbccddee 51 11223344-5566-c777-e888-99aabbccddee 51
11223344-5566-d777-8888-99aabbccddee 53 11223344-5566-d777-8888-99aabbccddee 53
11223344-5566-d777-c888-99aabbccddee 54 11223344-5566-d777-c888-99aabbccddee 54
11223344-5566-d777-e888-99aabbccddee 55 11223344-5566-d777-e888-99aabbccddee 55
11223344-5566-e777-8888-99aabbccddee 57 11223344-5566-e777-8888-99aabbccddee 57
11223344-5566-e777-c888-99aabbccddee 58 11223344-5566-e777-c888-99aabbccddee 58
11223344-5566-e777-e888-99aabbccddee 59 11223344-5566-e777-e888-99aabbccddee 59
11223344-5566-f777-8888-99aabbccddee 61 11223344-5566-f777-8888-99aabbccddee 61
11223344-5566-f777-c888-99aabbccddee 62 11223344-5566-f777-c888-99aabbccddee 62
11223344-5566-f777-e888-99aabbccddee 63 11223344-5566-f777-e888-99aabbccddee 63
select * from t1 union select * from t2;
a b
11223344-5566-0777-0888-99aabbccddee 0
11223344-5566-0777-8888-99aabbccddee 1
11223344-5566-0777-c888-99aabbccddee 2
11223344-5566-0777-e888-99aabbccddee 3
11223344-5566-1777-0888-99aabbccddee 4
11223344-5566-1777-8888-99aabbccddee 5
11223344-5566-1777-c888-99aabbccddee 6
11223344-5566-1777-e888-99aabbccddee 7
11223344-5566-2777-0888-99aabbccddee 8
11223344-5566-2777-8888-99aabbccddee 9
11223344-5566-2777-c888-99aabbccddee 10
11223344-5566-2777-e888-99aabbccddee 11
11223344-5566-3777-0888-99aabbccddee 12
11223344-5566-3777-8888-99aabbccddee 13
11223344-5566-3777-c888-99aabbccddee 14
11223344-5566-3777-e888-99aabbccddee 15
11223344-5566-4777-0888-99aabbccddee 16
11223344-5566-4777-8888-99aabbccddee 17
11223344-5566-4777-c888-99aabbccddee 18
11223344-5566-4777-e888-99aabbccddee 19
11223344-5566-5777-0888-99aabbccddee 20
11223344-5566-5777-8888-99aabbccddee 21
11223344-5566-5777-c888-99aabbccddee 22
11223344-5566-5777-e888-99aabbccddee 23
11223344-5566-6777-0888-99aabbccddee 24
11223344-5566-6777-8888-99aabbccddee 25
11223344-5566-6777-c888-99aabbccddee 26
11223344-5566-6777-e888-99aabbccddee 27
11223344-5566-7777-0888-99aabbccddee 28
11223344-5566-7777-8888-99aabbccddee 29
11223344-5566-7777-c888-99aabbccddee 30
11223344-5566-7777-e888-99aabbccddee 31
11223344-5566-8777-8888-99aabbccddee 33
11223344-5566-8777-c888-99aabbccddee 34
11223344-5566-8777-e888-99aabbccddee 35
11223344-5566-9777-8888-99aabbccddee 37
11223344-5566-9777-c888-99aabbccddee 38
11223344-5566-9777-e888-99aabbccddee 39
11223344-5566-a777-8888-99aabbccddee 41
11223344-5566-a777-c888-99aabbccddee 42
11223344-5566-a777-e888-99aabbccddee 43
11223344-5566-b777-8888-99aabbccddee 45
11223344-5566-b777-c888-99aabbccddee 46
11223344-5566-b777-e888-99aabbccddee 47
11223344-5566-c777-8888-99aabbccddee 49
11223344-5566-c777-c888-99aabbccddee 50
11223344-5566-c777-e888-99aabbccddee 51
11223344-5566-d777-8888-99aabbccddee 53
11223344-5566-d777-c888-99aabbccddee 54
11223344-5566-d777-e888-99aabbccddee 55
11223344-5566-e777-8888-99aabbccddee 57
11223344-5566-e777-c888-99aabbccddee 58
11223344-5566-e777-e888-99aabbccddee 59
11223344-5566-f777-8888-99aabbccddee 61
11223344-5566-f777-c888-99aabbccddee 62
11223344-5566-f777-e888-99aabbccddee 63
NULL 32
NULL 36
NULL 40
NULL 44
NULL 48
NULL 52
NULL 56
NULL 60
alter ignore table t2 force;
Warnings:
Warning 1292 Incorrect uuid value: '11223344-5566-8777-0888-99aabbccddee' for column `test`.`t2`.`a` at row 33
Warning 1292 Incorrect uuid value: '11223344-5566-9777-0888-99aabbccddee' for column `test`.`t2`.`a` at row 37
Warning 1292 Incorrect uuid value: '11223344-5566-a777-0888-99aabbccddee' for column `test`.`t2`.`a` at row 41
Warning 1292 Incorrect uuid value: '11223344-5566-b777-0888-99aabbccddee' for column `test`.`t2`.`a` at row 45
Warning 1292 Incorrect uuid value: '11223344-5566-c777-0888-99aabbccddee' for column `test`.`t2`.`a` at row 49
Warning 1292 Incorrect uuid value: '11223344-5566-d777-0888-99aabbccddee' for column `test`.`t2`.`a` at row 53
Warning 1292 Incorrect uuid value: '11223344-5566-e777-0888-99aabbccddee' for column `test`.`t2`.`a` at row 57
Warning 1292 Incorrect uuid value: '11223344-5566-f777-0888-99aabbccddee' for column `test`.`t2`.`a` at row 61
drop table t1, t2;

View file

@ -0,0 +1,26 @@
# try all combinations of version and variant
source include/have_sequence.inc;
create table t1 (a uuid, b int not null, index (a));
insert t1 select sformat('11223344-5566-{:x}777-{}888-99aabbccddee', seq div 4, elt(1+(seq % 4),0,8,'c','e')),seq from seq_0_to_63;
select * from t1;
select * from t1 order by a;
show create table t1;
--echo # now let's use the table as above, but created in 10.11.4
let $datadir= `select @@datadir`;
--copy_file $MTR_SUITE_DIR/std_data/mdev-29959.frm $datadir/test/t2.frm
--copy_file $MTR_SUITE_DIR/std_data/mdev-29959.MYI $datadir/test/t2.MYI
--copy_file $MTR_SUITE_DIR/std_data/mdev-29959.MYD $datadir/test/t2.MYD
select * from t2;
select * from t2 order by a;
show create table t2;
select * from t1, t2 where t1.a=t2.a;
--sorted_result
select * from t1 union select * from t2;
alter ignore table t2 force;
drop table t1, t2;

View file

@ -413,156 +413,6 @@ a
00000000-0000-0000-0000-000000000000
00000000-0000-0000-0000-000000000000
00000000-0000-0000-0000-000000000000
00000001-0000-0000-0000-000000000000
00000002-0000-0000-0000-000000000000
00000003-0000-0000-0000-000000000000
00000004-0000-0000-0000-000000000000
00000005-0000-0000-0000-000000000000
00000006-0000-0000-0000-000000000000
00000007-0000-0000-0000-000000000000
00000008-0000-0000-0000-000000000000
00000009-0000-0000-0000-000000000000
0000000a-0000-0000-0000-000000000000
0000000b-0000-0000-0000-000000000000
0000000c-0000-0000-0000-000000000000
0000000d-0000-0000-0000-000000000000
0000000e-0000-0000-0000-000000000000
0000000f-0000-0000-0000-000000000000
00000100-0000-0000-0000-000000000000
00000200-0000-0000-0000-000000000000
00000300-0000-0000-0000-000000000000
00000400-0000-0000-0000-000000000000
00000500-0000-0000-0000-000000000000
00000600-0000-0000-0000-000000000000
00000700-0000-0000-0000-000000000000
00000800-0000-0000-0000-000000000000
00000900-0000-0000-0000-000000000000
00000a00-0000-0000-0000-000000000000
00000b00-0000-0000-0000-000000000000
00000c00-0000-0000-0000-000000000000
00000d00-0000-0000-0000-000000000000
00000e00-0000-0000-0000-000000000000
00000f00-0000-0000-0000-000000000000
00010000-0000-0000-0000-000000000000
00020000-0000-0000-0000-000000000000
00030000-0000-0000-0000-000000000000
00040000-0000-0000-0000-000000000000
00050000-0000-0000-0000-000000000000
00060000-0000-0000-0000-000000000000
00070000-0000-0000-0000-000000000000
00080000-0000-0000-0000-000000000000
00090000-0000-0000-0000-000000000000
000a0000-0000-0000-0000-000000000000
000b0000-0000-0000-0000-000000000000
000c0000-0000-0000-0000-000000000000
000d0000-0000-0000-0000-000000000000
000e0000-0000-0000-0000-000000000000
000f0000-0000-0000-0000-000000000000
01000000-0000-0000-0000-000000000000
02000000-0000-0000-0000-000000000000
03000000-0000-0000-0000-000000000000
04000000-0000-0000-0000-000000000000
05000000-0000-0000-0000-000000000000
06000000-0000-0000-0000-000000000000
07000000-0000-0000-0000-000000000000
08000000-0000-0000-0000-000000000000
09000000-0000-0000-0000-000000000000
0a000000-0000-0000-0000-000000000000
0b000000-0000-0000-0000-000000000000
0c000000-0000-0000-0000-000000000000
0d000000-0000-0000-0000-000000000000
0e000000-0000-0000-0000-000000000000
0f000000-0000-0000-0000-000000000000
00000000-0001-0000-0000-000000000000
00000000-0002-0000-0000-000000000000
00000000-0003-0000-0000-000000000000
00000000-0004-0000-0000-000000000000
00000000-0005-0000-0000-000000000000
00000000-0006-0000-0000-000000000000
00000000-0007-0000-0000-000000000000
00000000-0008-0000-0000-000000000000
00000000-0009-0000-0000-000000000000
00000000-000a-0000-0000-000000000000
00000000-000b-0000-0000-000000000000
00000000-000c-0000-0000-000000000000
00000000-000d-0000-0000-000000000000
00000000-000e-0000-0000-000000000000
00000000-000f-0000-0000-000000000000
00000000-0100-0000-0000-000000000000
00000000-0200-0000-0000-000000000000
00000000-0300-0000-0000-000000000000
00000000-0400-0000-0000-000000000000
00000000-0500-0000-0000-000000000000
00000000-0600-0000-0000-000000000000
00000000-0700-0000-0000-000000000000
00000000-0800-0000-0000-000000000000
00000000-0900-0000-0000-000000000000
00000000-0a00-0000-0000-000000000000
00000000-0b00-0000-0000-000000000000
00000000-0c00-0000-0000-000000000000
00000000-0d00-0000-0000-000000000000
00000000-0e00-0000-0000-000000000000
00000000-0f00-0000-0000-000000000000
00000000-0000-0001-0000-000000000000
00000000-0000-0002-0000-000000000000
00000000-0000-0003-0000-000000000000
00000000-0000-0004-0000-000000000000
00000000-0000-0005-0000-000000000000
00000000-0000-0006-0000-000000000000
00000000-0000-0007-0000-000000000000
00000000-0000-0008-0000-000000000000
00000000-0000-0009-0000-000000000000
00000000-0000-000a-0000-000000000000
00000000-0000-000b-0000-000000000000
00000000-0000-000c-0000-000000000000
00000000-0000-000d-0000-000000000000
00000000-0000-000e-0000-000000000000
00000000-0000-000f-0000-000000000000
00000000-0000-0100-0000-000000000000
00000000-0000-0200-0000-000000000000
00000000-0000-0300-0000-000000000000
00000000-0000-0400-0000-000000000000
00000000-0000-0500-0000-000000000000
00000000-0000-0600-0000-000000000000
00000000-0000-0700-0000-000000000000
00000000-0000-0800-0000-000000000000
00000000-0000-0900-0000-000000000000
00000000-0000-0a00-0000-000000000000
00000000-0000-0b00-0000-000000000000
00000000-0000-0c00-0000-000000000000
00000000-0000-0d00-0000-000000000000
00000000-0000-0e00-0000-000000000000
00000000-0000-0f00-0000-000000000000
00000000-0000-0000-0001-000000000000
00000000-0000-0000-0002-000000000000
00000000-0000-0000-0003-000000000000
00000000-0000-0000-0004-000000000000
00000000-0000-0000-0005-000000000000
00000000-0000-0000-0006-000000000000
00000000-0000-0000-0007-000000000000
00000000-0000-0000-0008-000000000000
00000000-0000-0000-0009-000000000000
00000000-0000-0000-000a-000000000000
00000000-0000-0000-000b-000000000000
00000000-0000-0000-000c-000000000000
00000000-0000-0000-000d-000000000000
00000000-0000-0000-000e-000000000000
00000000-0000-0000-000f-000000000000
00000000-0000-0000-0100-000000000000
00000000-0000-0000-0200-000000000000
00000000-0000-0000-0300-000000000000
00000000-0000-0000-0400-000000000000
00000000-0000-0000-0500-000000000000
00000000-0000-0000-0600-000000000000
00000000-0000-0000-0700-000000000000
00000000-0000-0000-0800-000000000000
00000000-0000-0000-0900-000000000000
00000000-0000-0000-0a00-000000000000
00000000-0000-0000-0b00-000000000000
00000000-0000-0000-0c00-000000000000
00000000-0000-0000-0d00-000000000000
00000000-0000-0000-0e00-000000000000
00000000-0000-0000-0f00-000000000000
00000000-0000-0000-0000-000000000001
00000000-0000-0000-0000-000000000002
00000000-0000-0000-0000-000000000003
@ -653,6 +503,156 @@ a
00000000-0000-0000-0000-0d0000000000
00000000-0000-0000-0000-0e0000000000
00000000-0000-0000-0000-0f0000000000
00000000-0000-0000-0001-000000000000
00000000-0000-0000-0002-000000000000
00000000-0000-0000-0003-000000000000
00000000-0000-0000-0004-000000000000
00000000-0000-0000-0005-000000000000
00000000-0000-0000-0006-000000000000
00000000-0000-0000-0007-000000000000
00000000-0000-0000-0008-000000000000
00000000-0000-0000-0009-000000000000
00000000-0000-0000-000a-000000000000
00000000-0000-0000-000b-000000000000
00000000-0000-0000-000c-000000000000
00000000-0000-0000-000d-000000000000
00000000-0000-0000-000e-000000000000
00000000-0000-0000-000f-000000000000
00000000-0000-0000-0100-000000000000
00000000-0000-0000-0200-000000000000
00000000-0000-0000-0300-000000000000
00000000-0000-0000-0400-000000000000
00000000-0000-0000-0500-000000000000
00000000-0000-0000-0600-000000000000
00000000-0000-0000-0700-000000000000
00000000-0000-0000-0800-000000000000
00000000-0000-0000-0900-000000000000
00000000-0000-0000-0a00-000000000000
00000000-0000-0000-0b00-000000000000
00000000-0000-0000-0c00-000000000000
00000000-0000-0000-0d00-000000000000
00000000-0000-0000-0e00-000000000000
00000000-0000-0000-0f00-000000000000
00000000-0000-0001-0000-000000000000
00000000-0000-0002-0000-000000000000
00000000-0000-0003-0000-000000000000
00000000-0000-0004-0000-000000000000
00000000-0000-0005-0000-000000000000
00000000-0000-0006-0000-000000000000
00000000-0000-0007-0000-000000000000
00000000-0000-0008-0000-000000000000
00000000-0000-0009-0000-000000000000
00000000-0000-000a-0000-000000000000
00000000-0000-000b-0000-000000000000
00000000-0000-000c-0000-000000000000
00000000-0000-000d-0000-000000000000
00000000-0000-000e-0000-000000000000
00000000-0000-000f-0000-000000000000
00000000-0000-0100-0000-000000000000
00000000-0000-0200-0000-000000000000
00000000-0000-0300-0000-000000000000
00000000-0000-0400-0000-000000000000
00000000-0000-0500-0000-000000000000
00000000-0000-0600-0000-000000000000
00000000-0000-0700-0000-000000000000
00000000-0000-0800-0000-000000000000
00000000-0000-0900-0000-000000000000
00000000-0000-0a00-0000-000000000000
00000000-0000-0b00-0000-000000000000
00000000-0000-0c00-0000-000000000000
00000000-0000-0d00-0000-000000000000
00000000-0000-0e00-0000-000000000000
00000000-0000-0f00-0000-000000000000
00000000-0001-0000-0000-000000000000
00000000-0002-0000-0000-000000000000
00000000-0003-0000-0000-000000000000
00000000-0004-0000-0000-000000000000
00000000-0005-0000-0000-000000000000
00000000-0006-0000-0000-000000000000
00000000-0007-0000-0000-000000000000
00000000-0008-0000-0000-000000000000
00000000-0009-0000-0000-000000000000
00000000-000a-0000-0000-000000000000
00000000-000b-0000-0000-000000000000
00000000-000c-0000-0000-000000000000
00000000-000d-0000-0000-000000000000
00000000-000e-0000-0000-000000000000
00000000-000f-0000-0000-000000000000
00000000-0100-0000-0000-000000000000
00000000-0200-0000-0000-000000000000
00000000-0300-0000-0000-000000000000
00000000-0400-0000-0000-000000000000
00000000-0500-0000-0000-000000000000
00000000-0600-0000-0000-000000000000
00000000-0700-0000-0000-000000000000
00000000-0800-0000-0000-000000000000
00000000-0900-0000-0000-000000000000
00000000-0a00-0000-0000-000000000000
00000000-0b00-0000-0000-000000000000
00000000-0c00-0000-0000-000000000000
00000000-0d00-0000-0000-000000000000
00000000-0e00-0000-0000-000000000000
00000000-0f00-0000-0000-000000000000
00000001-0000-0000-0000-000000000000
00000002-0000-0000-0000-000000000000
00000003-0000-0000-0000-000000000000
00000004-0000-0000-0000-000000000000
00000005-0000-0000-0000-000000000000
00000006-0000-0000-0000-000000000000
00000007-0000-0000-0000-000000000000
00000008-0000-0000-0000-000000000000
00000009-0000-0000-0000-000000000000
0000000a-0000-0000-0000-000000000000
0000000b-0000-0000-0000-000000000000
0000000c-0000-0000-0000-000000000000
0000000d-0000-0000-0000-000000000000
0000000e-0000-0000-0000-000000000000
0000000f-0000-0000-0000-000000000000
00000100-0000-0000-0000-000000000000
00000200-0000-0000-0000-000000000000
00000300-0000-0000-0000-000000000000
00000400-0000-0000-0000-000000000000
00000500-0000-0000-0000-000000000000
00000600-0000-0000-0000-000000000000
00000700-0000-0000-0000-000000000000
00000800-0000-0000-0000-000000000000
00000900-0000-0000-0000-000000000000
00000a00-0000-0000-0000-000000000000
00000b00-0000-0000-0000-000000000000
00000c00-0000-0000-0000-000000000000
00000d00-0000-0000-0000-000000000000
00000e00-0000-0000-0000-000000000000
00000f00-0000-0000-0000-000000000000
00010000-0000-0000-0000-000000000000
00020000-0000-0000-0000-000000000000
00030000-0000-0000-0000-000000000000
00040000-0000-0000-0000-000000000000
00050000-0000-0000-0000-000000000000
00060000-0000-0000-0000-000000000000
00070000-0000-0000-0000-000000000000
00080000-0000-0000-0000-000000000000
00090000-0000-0000-0000-000000000000
000a0000-0000-0000-0000-000000000000
000b0000-0000-0000-0000-000000000000
000c0000-0000-0000-0000-000000000000
000d0000-0000-0000-0000-000000000000
000e0000-0000-0000-0000-000000000000
000f0000-0000-0000-0000-000000000000
01000000-0000-0000-0000-000000000000
02000000-0000-0000-0000-000000000000
03000000-0000-0000-0000-000000000000
04000000-0000-0000-0000-000000000000
05000000-0000-0000-0000-000000000000
06000000-0000-0000-0000-000000000000
07000000-0000-0000-0000-000000000000
08000000-0000-0000-0000-000000000000
09000000-0000-0000-0000-000000000000
0a000000-0000-0000-0000-000000000000
0b000000-0000-0000-0000-000000000000
0c000000-0000-0000-0000-000000000000
0d000000-0000-0000-0000-000000000000
0e000000-0000-0000-0000-000000000000
0f000000-0000-0000-0000-000000000000
SELECT COALESCE(NULL, a) FROM t1 ORDER BY a;
COALESCE(NULL, a)
00000000-0000-0000-0000-000000000000
@ -671,156 +671,6 @@ COALESCE(NULL, a)
00000000-0000-0000-0000-000000000000
00000000-0000-0000-0000-000000000000
00000000-0000-0000-0000-000000000000
00000001-0000-0000-0000-000000000000
00000002-0000-0000-0000-000000000000
00000003-0000-0000-0000-000000000000
00000004-0000-0000-0000-000000000000
00000005-0000-0000-0000-000000000000
00000006-0000-0000-0000-000000000000
00000007-0000-0000-0000-000000000000
00000008-0000-0000-0000-000000000000
00000009-0000-0000-0000-000000000000
0000000a-0000-0000-0000-000000000000
0000000b-0000-0000-0000-000000000000
0000000c-0000-0000-0000-000000000000
0000000d-0000-0000-0000-000000000000
0000000e-0000-0000-0000-000000000000
0000000f-0000-0000-0000-000000000000
00000100-0000-0000-0000-000000000000
00000200-0000-0000-0000-000000000000
00000300-0000-0000-0000-000000000000
00000400-0000-0000-0000-000000000000
00000500-0000-0000-0000-000000000000
00000600-0000-0000-0000-000000000000
00000700-0000-0000-0000-000000000000
00000800-0000-0000-0000-000000000000
00000900-0000-0000-0000-000000000000
00000a00-0000-0000-0000-000000000000
00000b00-0000-0000-0000-000000000000
00000c00-0000-0000-0000-000000000000
00000d00-0000-0000-0000-000000000000
00000e00-0000-0000-0000-000000000000
00000f00-0000-0000-0000-000000000000
00010000-0000-0000-0000-000000000000
00020000-0000-0000-0000-000000000000
00030000-0000-0000-0000-000000000000
00040000-0000-0000-0000-000000000000
00050000-0000-0000-0000-000000000000
00060000-0000-0000-0000-000000000000
00070000-0000-0000-0000-000000000000
00080000-0000-0000-0000-000000000000
00090000-0000-0000-0000-000000000000
000a0000-0000-0000-0000-000000000000
000b0000-0000-0000-0000-000000000000
000c0000-0000-0000-0000-000000000000
000d0000-0000-0000-0000-000000000000
000e0000-0000-0000-0000-000000000000
000f0000-0000-0000-0000-000000000000
01000000-0000-0000-0000-000000000000
02000000-0000-0000-0000-000000000000
03000000-0000-0000-0000-000000000000
04000000-0000-0000-0000-000000000000
05000000-0000-0000-0000-000000000000
06000000-0000-0000-0000-000000000000
07000000-0000-0000-0000-000000000000
08000000-0000-0000-0000-000000000000
09000000-0000-0000-0000-000000000000
0a000000-0000-0000-0000-000000000000
0b000000-0000-0000-0000-000000000000
0c000000-0000-0000-0000-000000000000
0d000000-0000-0000-0000-000000000000
0e000000-0000-0000-0000-000000000000
0f000000-0000-0000-0000-000000000000
00000000-0001-0000-0000-000000000000
00000000-0002-0000-0000-000000000000
00000000-0003-0000-0000-000000000000
00000000-0004-0000-0000-000000000000
00000000-0005-0000-0000-000000000000
00000000-0006-0000-0000-000000000000
00000000-0007-0000-0000-000000000000
00000000-0008-0000-0000-000000000000
00000000-0009-0000-0000-000000000000
00000000-000a-0000-0000-000000000000
00000000-000b-0000-0000-000000000000
00000000-000c-0000-0000-000000000000
00000000-000d-0000-0000-000000000000
00000000-000e-0000-0000-000000000000
00000000-000f-0000-0000-000000000000
00000000-0100-0000-0000-000000000000
00000000-0200-0000-0000-000000000000
00000000-0300-0000-0000-000000000000
00000000-0400-0000-0000-000000000000
00000000-0500-0000-0000-000000000000
00000000-0600-0000-0000-000000000000
00000000-0700-0000-0000-000000000000
00000000-0800-0000-0000-000000000000
00000000-0900-0000-0000-000000000000
00000000-0a00-0000-0000-000000000000
00000000-0b00-0000-0000-000000000000
00000000-0c00-0000-0000-000000000000
00000000-0d00-0000-0000-000000000000
00000000-0e00-0000-0000-000000000000
00000000-0f00-0000-0000-000000000000
00000000-0000-0001-0000-000000000000
00000000-0000-0002-0000-000000000000
00000000-0000-0003-0000-000000000000
00000000-0000-0004-0000-000000000000
00000000-0000-0005-0000-000000000000
00000000-0000-0006-0000-000000000000
00000000-0000-0007-0000-000000000000
00000000-0000-0008-0000-000000000000
00000000-0000-0009-0000-000000000000
00000000-0000-000a-0000-000000000000
00000000-0000-000b-0000-000000000000
00000000-0000-000c-0000-000000000000
00000000-0000-000d-0000-000000000000
00000000-0000-000e-0000-000000000000
00000000-0000-000f-0000-000000000000
00000000-0000-0100-0000-000000000000
00000000-0000-0200-0000-000000000000
00000000-0000-0300-0000-000000000000
00000000-0000-0400-0000-000000000000
00000000-0000-0500-0000-000000000000
00000000-0000-0600-0000-000000000000
00000000-0000-0700-0000-000000000000
00000000-0000-0800-0000-000000000000
00000000-0000-0900-0000-000000000000
00000000-0000-0a00-0000-000000000000
00000000-0000-0b00-0000-000000000000
00000000-0000-0c00-0000-000000000000
00000000-0000-0d00-0000-000000000000
00000000-0000-0e00-0000-000000000000
00000000-0000-0f00-0000-000000000000
00000000-0000-0000-0001-000000000000
00000000-0000-0000-0002-000000000000
00000000-0000-0000-0003-000000000000
00000000-0000-0000-0004-000000000000
00000000-0000-0000-0005-000000000000
00000000-0000-0000-0006-000000000000
00000000-0000-0000-0007-000000000000
00000000-0000-0000-0008-000000000000
00000000-0000-0000-0009-000000000000
00000000-0000-0000-000a-000000000000
00000000-0000-0000-000b-000000000000
00000000-0000-0000-000c-000000000000
00000000-0000-0000-000d-000000000000
00000000-0000-0000-000e-000000000000
00000000-0000-0000-000f-000000000000
00000000-0000-0000-0100-000000000000
00000000-0000-0000-0200-000000000000
00000000-0000-0000-0300-000000000000
00000000-0000-0000-0400-000000000000
00000000-0000-0000-0500-000000000000
00000000-0000-0000-0600-000000000000
00000000-0000-0000-0700-000000000000
00000000-0000-0000-0800-000000000000
00000000-0000-0000-0900-000000000000
00000000-0000-0000-0a00-000000000000
00000000-0000-0000-0b00-000000000000
00000000-0000-0000-0c00-000000000000
00000000-0000-0000-0d00-000000000000
00000000-0000-0000-0e00-000000000000
00000000-0000-0000-0f00-000000000000
00000000-0000-0000-0000-000000000001
00000000-0000-0000-0000-000000000002
00000000-0000-0000-0000-000000000003
@ -911,6 +761,156 @@ COALESCE(NULL, a)
00000000-0000-0000-0000-0d0000000000
00000000-0000-0000-0000-0e0000000000
00000000-0000-0000-0000-0f0000000000
00000000-0000-0000-0001-000000000000
00000000-0000-0000-0002-000000000000
00000000-0000-0000-0003-000000000000
00000000-0000-0000-0004-000000000000
00000000-0000-0000-0005-000000000000
00000000-0000-0000-0006-000000000000
00000000-0000-0000-0007-000000000000
00000000-0000-0000-0008-000000000000
00000000-0000-0000-0009-000000000000
00000000-0000-0000-000a-000000000000
00000000-0000-0000-000b-000000000000
00000000-0000-0000-000c-000000000000
00000000-0000-0000-000d-000000000000
00000000-0000-0000-000e-000000000000
00000000-0000-0000-000f-000000000000
00000000-0000-0000-0100-000000000000
00000000-0000-0000-0200-000000000000
00000000-0000-0000-0300-000000000000
00000000-0000-0000-0400-000000000000
00000000-0000-0000-0500-000000000000
00000000-0000-0000-0600-000000000000
00000000-0000-0000-0700-000000000000
00000000-0000-0000-0800-000000000000
00000000-0000-0000-0900-000000000000
00000000-0000-0000-0a00-000000000000
00000000-0000-0000-0b00-000000000000
00000000-0000-0000-0c00-000000000000
00000000-0000-0000-0d00-000000000000
00000000-0000-0000-0e00-000000000000
00000000-0000-0000-0f00-000000000000
00000000-0000-0001-0000-000000000000
00000000-0000-0002-0000-000000000000
00000000-0000-0003-0000-000000000000
00000000-0000-0004-0000-000000000000
00000000-0000-0005-0000-000000000000
00000000-0000-0006-0000-000000000000
00000000-0000-0007-0000-000000000000
00000000-0000-0008-0000-000000000000
00000000-0000-0009-0000-000000000000
00000000-0000-000a-0000-000000000000
00000000-0000-000b-0000-000000000000
00000000-0000-000c-0000-000000000000
00000000-0000-000d-0000-000000000000
00000000-0000-000e-0000-000000000000
00000000-0000-000f-0000-000000000000
00000000-0000-0100-0000-000000000000
00000000-0000-0200-0000-000000000000
00000000-0000-0300-0000-000000000000
00000000-0000-0400-0000-000000000000
00000000-0000-0500-0000-000000000000
00000000-0000-0600-0000-000000000000
00000000-0000-0700-0000-000000000000
00000000-0000-0800-0000-000000000000
00000000-0000-0900-0000-000000000000
00000000-0000-0a00-0000-000000000000
00000000-0000-0b00-0000-000000000000
00000000-0000-0c00-0000-000000000000
00000000-0000-0d00-0000-000000000000
00000000-0000-0e00-0000-000000000000
00000000-0000-0f00-0000-000000000000
00000000-0001-0000-0000-000000000000
00000000-0002-0000-0000-000000000000
00000000-0003-0000-0000-000000000000
00000000-0004-0000-0000-000000000000
00000000-0005-0000-0000-000000000000
00000000-0006-0000-0000-000000000000
00000000-0007-0000-0000-000000000000
00000000-0008-0000-0000-000000000000
00000000-0009-0000-0000-000000000000
00000000-000a-0000-0000-000000000000
00000000-000b-0000-0000-000000000000
00000000-000c-0000-0000-000000000000
00000000-000d-0000-0000-000000000000
00000000-000e-0000-0000-000000000000
00000000-000f-0000-0000-000000000000
00000000-0100-0000-0000-000000000000
00000000-0200-0000-0000-000000000000
00000000-0300-0000-0000-000000000000
00000000-0400-0000-0000-000000000000
00000000-0500-0000-0000-000000000000
00000000-0600-0000-0000-000000000000
00000000-0700-0000-0000-000000000000
00000000-0800-0000-0000-000000000000
00000000-0900-0000-0000-000000000000
00000000-0a00-0000-0000-000000000000
00000000-0b00-0000-0000-000000000000
00000000-0c00-0000-0000-000000000000
00000000-0d00-0000-0000-000000000000
00000000-0e00-0000-0000-000000000000
00000000-0f00-0000-0000-000000000000
00000001-0000-0000-0000-000000000000
00000002-0000-0000-0000-000000000000
00000003-0000-0000-0000-000000000000
00000004-0000-0000-0000-000000000000
00000005-0000-0000-0000-000000000000
00000006-0000-0000-0000-000000000000
00000007-0000-0000-0000-000000000000
00000008-0000-0000-0000-000000000000
00000009-0000-0000-0000-000000000000
0000000a-0000-0000-0000-000000000000
0000000b-0000-0000-0000-000000000000
0000000c-0000-0000-0000-000000000000
0000000d-0000-0000-0000-000000000000
0000000e-0000-0000-0000-000000000000
0000000f-0000-0000-0000-000000000000
00000100-0000-0000-0000-000000000000
00000200-0000-0000-0000-000000000000
00000300-0000-0000-0000-000000000000
00000400-0000-0000-0000-000000000000
00000500-0000-0000-0000-000000000000
00000600-0000-0000-0000-000000000000
00000700-0000-0000-0000-000000000000
00000800-0000-0000-0000-000000000000
00000900-0000-0000-0000-000000000000
00000a00-0000-0000-0000-000000000000
00000b00-0000-0000-0000-000000000000
00000c00-0000-0000-0000-000000000000
00000d00-0000-0000-0000-000000000000
00000e00-0000-0000-0000-000000000000
00000f00-0000-0000-0000-000000000000
00010000-0000-0000-0000-000000000000
00020000-0000-0000-0000-000000000000
00030000-0000-0000-0000-000000000000
00040000-0000-0000-0000-000000000000
00050000-0000-0000-0000-000000000000
00060000-0000-0000-0000-000000000000
00070000-0000-0000-0000-000000000000
00080000-0000-0000-0000-000000000000
00090000-0000-0000-0000-000000000000
000a0000-0000-0000-0000-000000000000
000b0000-0000-0000-0000-000000000000
000c0000-0000-0000-0000-000000000000
000d0000-0000-0000-0000-000000000000
000e0000-0000-0000-0000-000000000000
000f0000-0000-0000-0000-000000000000
01000000-0000-0000-0000-000000000000
02000000-0000-0000-0000-000000000000
03000000-0000-0000-0000-000000000000
04000000-0000-0000-0000-000000000000
05000000-0000-0000-0000-000000000000
06000000-0000-0000-0000-000000000000
07000000-0000-0000-0000-000000000000
08000000-0000-0000-0000-000000000000
09000000-0000-0000-0000-000000000000
0a000000-0000-0000-0000-000000000000
0b000000-0000-0000-0000-000000000000
0c000000-0000-0000-0000-000000000000
0d000000-0000-0000-0000-000000000000
0e000000-0000-0000-0000-000000000000
0f000000-0000-0000-0000-000000000000
#
# Lexicographical ORDER BY
#
@ -1659,10 +1659,10 @@ INSERT INTO t1 VALUES (CAST(CONCAT('2','0000000-0000-0000-0000-000000000003') AS
SELECT * FROM t1 ORDER BY a;
a
10000000-0000-0000-0000-000000000001
20000000-0000-0000-0000-000000000001
10000000-0000-0000-0000-000000000002
20000000-0000-0000-0000-000000000002
10000000-0000-0000-0000-000000000003
20000000-0000-0000-0000-000000000001
20000000-0000-0000-0000-000000000002
20000000-0000-0000-0000-000000000003
DROP TABLE t1;
#
@ -3178,8 +3178,8 @@ CREATE TABLE t1 (d UUID);
INSERT INTO t1 VALUES ('00000000-0000-0000-0000-111111111111'), ('11111111-0000-0000-0000-000000000000');
SELECT * FROM t1 ORDER BY d;
d
11111111-0000-0000-0000-000000000000
00000000-0000-0000-0000-111111111111
11111111-0000-0000-0000-000000000000
SELECT * FROM t1 WHERE d <= ALL (SELECT * FROM t1);
d
11111111-0000-0000-0000-000000000000

View file

@ -25,7 +25,7 @@ a
00000000-0000-0000-0000-0000000000ff
EXPLAIN SELECT * FROM t1 WHERE a='00000000-0000-0000-0000-0000000000ff';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref a a 17 const 4 Using where
1 SIMPLE t1 ref a a 17 const 2 Using where
SELECT * FROM t1 WHERE a='garbage';
a
Warnings:
@ -66,7 +66,7 @@ EXPLAIN SELECT * FROM t1 WHERE a IN
'00000000-0000-0000-0000-0000000000f0'
);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 17 NULL 12 Using where
1 SIMPLE t1 range a a 17 NULL 6 Using where
SELECT * FROM t1 WHERE a IN
(
'00000000-0000-0000-0000-000000000080',
@ -85,7 +85,7 @@ EXPLAIN SELECT * FROM t1 WHERE a IN
'garbage'
);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 17 NULL 8 Using where
1 SIMPLE t1 range a a 17 NULL 4 Using where
Warnings:
Warning 1292 Incorrect uuid value: 'garbage'
SELECT * FROM t1 WHERE a BETWEEN
@ -178,7 +178,7 @@ a
00000000-0000-0000-0000-0000000000ff
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=CAST('00000000-0000-0000-0000-0000000000ff' AS UUID);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ref a a 17 const 4 100.00 Using where
1 SIMPLE t1 ref a a 17 const 2 100.00 Using where
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = UUID'00000000-0000-0000-0000-0000000000ff'
DROP TABLE t1;

View file

@ -25,7 +25,7 @@ a
00000000-0000-0000-0000-0000000000ff
EXPLAIN SELECT * FROM t1 WHERE a='00000000-0000-0000-0000-0000000000ff';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref a a 17 const 1 Using where; Using index
1 SIMPLE t1 ref a a 17 const 7 Using where; Using index
SELECT * FROM t1 WHERE a='garbage';
a
Warnings:
@ -41,7 +41,7 @@ a
00000000-0000-0000-0000-0000000000ff
EXPLAIN SELECT * FROM t1 WHERE a>='00000000-0000-0000-0000-0000000000fe';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 17 NULL 3 Using where; Using index
1 SIMPLE t1 range a a 17 NULL 28 Using where; Using index
SELECT * FROM t1 WHERE a>='garbage';
a
EXPLAIN SELECT * FROM t1 WHERE a>='garbage';
@ -64,7 +64,7 @@ EXPLAIN SELECT * FROM t1 WHERE a IN
'00000000-0000-0000-0000-0000000000f0'
);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 17 NULL 4 Using where; Using index
1 SIMPLE t1 range a a 17 NULL 3 Using where; Using index
SELECT * FROM t1 WHERE a IN
(
'00000000-0000-0000-0000-000000000080',
@ -96,7 +96,7 @@ EXPLAIN SELECT * FROM t1 WHERE a BETWEEN
'00000000-0000-0000-0000-000000000080' AND
'00000000-0000-0000-0000-000000000081';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 17 NULL 2 Using where; Using index
1 SIMPLE t1 range a a 17 NULL 1 Using where; Using index
SELECT * FROM t1 WHERE a BETWEEN
'00000000-0000-0000-0000-000000000080' AND
'garbage';
@ -111,7 +111,7 @@ a
00000000-0000-0000-0000-0000000000ff
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=CAST('00000000-0000-0000-0000-0000000000ff' AS UUID);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ref a a 17 const 1 100.00 Using where; Using index
1 SIMPLE t1 ref a a 17 const 7 100.00 Using where; Using index
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = UUID'00000000-0000-0000-0000-0000000000ff'
DROP TABLE t1;

View file

@ -21,12 +21,83 @@
#include <mysql/plugin_data_type.h>
#include <mysql/plugin_function.h>
/*
The whole purpose of this Type_handler_uuid_dispatcher is to choose
whether the field should use Type_handler_uuid_new or Type_handler_uuid_old
based on the version of MariaDB that created the table.
When created every field will use either Type_handler_uuid_new or _old.
Literals and functions always use _new.
*/
class Type_handler_uuid_dispatcher: public Type_handler_uuid_new
{
public:
Field *make_table_field_from_def(TABLE_SHARE *share, MEM_ROOT *root,
const LEX_CSTRING *name, const Record_addr &addr,
const Bit_addr &bit,
const Column_definition_attributes *attr,
uint32 flags) const override
{
bool new_uuid= share->mysql_version == 0 ||
(share->mysql_version >= 100908 && share->mysql_version < 100999) ||
(share->mysql_version >= 101006 && share->mysql_version < 101099) ||
(share->mysql_version >= 101105 && share->mysql_version < 101199) ||
(share->mysql_version >= 110003 && share->mysql_version < 110099) ||
(share->mysql_version >= 110102 && share->mysql_version < 110199) ||
share->mysql_version >= 110201;
static Type_handler *th[]= {
Type_handler_uuid_old::singleton(), Type_handler_uuid_new::singleton()
};
return th[new_uuid]->
make_table_field_from_def(share, root, name, addr, bit, attr, flags);
}
};
static Type_handler_uuid_dispatcher type_handler_uuid_dispatcher;
static struct st_mariadb_data_type plugin_descriptor_type_uuid=
{
MariaDB_DATA_TYPE_INTERFACE_VERSION,
UUIDBundle::singleton()
&type_handler_uuid_dispatcher
};
const Type_handler *Type_collection_uuid::find_in_array(const Type_handler *a,
const Type_handler *b,
bool for_cmp) const
{
if (a == b) return a;
/*
in the search below we'll find if we can convert `b` to `a`.
So, if one of the arguments is uuid and the other is not,
we should put uuid type in `a` and not-uuid in `b`. And if one type is
new uuid and the other is old uuid, new uuid should be in `a`
*/
if (a != Type_handler_uuid_new::singleton() && b->type_collection() == this)
std::swap(a, b);
DBUG_ASSERT(a != &type_handler_uuid_dispatcher);
DBUG_ASSERT(b != &type_handler_uuid_dispatcher);
/*
Search in the array for an element, equal to `b`.
If found - return `a`, if not found - return NULL.
Array is terminated by `a`.
*/
static const Type_handler *arr[]={ &type_handler_varchar,
&type_handler_string, &type_handler_tiny_blob, &type_handler_blob,
&type_handler_medium_blob, &type_handler_hex_hybrid,
// in aggregate_for_comparison() all types above cannot happen,
// so we'll start the search from here:
&type_handler_null, &type_handler_long_blob,
Type_handler_uuid_old::singleton(), Type_handler_uuid_new::singleton() };
for (int i= for_cmp ? 6 : 0; arr[i] != a; i++)
if (arr[i] == b)
return a;
return NULL;
}
/*************************************************************************/
class Create_func_uuid : public Create_func_arg0
@ -71,17 +142,26 @@ static Plugin_function
plugin_descriptor_function_uuid(&Create_func_uuid::s_singleton),
plugin_descriptor_function_sys_guid(&Create_func_sys_guid::s_singleton);
static constexpr Name type_name={STRING_WITH_LEN("uuid")};
int uuid_init(void*)
{
Type_handler_uuid_new::singleton()->set_name(type_name);
Type_handler_uuid_old::singleton()->set_name(type_name);
return 0;
}
/*************************************************************************/
maria_declare_plugin(type_uuid)
{
MariaDB_DATA_TYPE_PLUGIN, // the plugin type (see include/mysql/plugin.h)
&plugin_descriptor_type_uuid, // pointer to type-specific plugin descriptor
"uuid", // plugin name
type_name.ptr(), // plugin name
"MariaDB Corporation", // plugin author
"Data type UUID", // the plugin description
PLUGIN_LICENSE_GPL, // the plugin license (see include/mysql/plugin.h)
0, // Pointer to plugin initialization function
uuid_init, // Pointer to plugin initialization function
0, // Pointer to plugin deinitialization function
0x0100, // Numeric version 0xAABB means AA.BB version
NULL, // Status variables

View file

@ -17,6 +17,8 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
#include "sql_type_fixedbin_storage.h"
template <bool force_swap>
class UUID: public FixedBinTypeStorage<MY_UUID_SIZE, MY_UUID_STRING_LENGTH>
{
bool get_digit(char ch, uint *val)
@ -93,6 +95,8 @@ public:
}
if (str < end)
goto err; // Some input left
if (m_buffer[6] < 0 && m_buffer[8] > 0)
goto err; // impossible combination: version >= 8, variant = 0
return false;
err:
bzero(m_buffer, sizeof(m_buffer));
@ -172,21 +176,31 @@ public:
// Convert the in-memory representation to the in-record representation
static void memory_to_record(char *to, const char *from)
{
segment(0).memory_to_record(to, from);
segment(1).memory_to_record(to, from);
segment(2).memory_to_record(to, from);
segment(3).memory_to_record(to, from);
segment(4).memory_to_record(to, from);
if (force_swap || (from[6] > 0 && from[6] < 0x60 && from[8] < 0))
{
segment(0).memory_to_record(to, from);
segment(1).memory_to_record(to, from);
segment(2).memory_to_record(to, from);
segment(3).memory_to_record(to, from);
segment(4).memory_to_record(to, from);
}
else
memcpy(to, from, binary_length());
}
// Convert the in-record representation to the in-memory representation
static void record_to_memory(char *to, const char *from)
{
segment(0).record_to_memory(to, from);
segment(1).record_to_memory(to, from);
segment(2).record_to_memory(to, from);
segment(3).record_to_memory(to, from);
segment(4).record_to_memory(to, from);
if (force_swap || (from[6] < 0 && from[8] > 0))
{
segment(0).record_to_memory(to, from);
segment(1).record_to_memory(to, from);
segment(2).record_to_memory(to, from);
segment(3).record_to_memory(to, from);
segment(4).record_to_memory(to, from);
}
else
memcpy(to, from, binary_length());
}
/*
@ -265,8 +279,38 @@ public:
};
class Type_collection_uuid: public Type_collection
{
const Type_handler *find_in_array(const Type_handler *what,
const Type_handler *stop,
bool for_comparison) const;
public:
const Type_handler *aggregate_for_result(const Type_handler *a,
const Type_handler *b)
const override
{ return find_in_array(a, b, false); }
const Type_handler *aggregate_for_min_max(const Type_handler *a,
const Type_handler *b)
const override
{ return find_in_array(a, b, false); }
const Type_handler *aggregate_for_comparison(const Type_handler *a,
const Type_handler *b)
const override
{ return find_in_array(a, b, true); }
const Type_handler *aggregate_for_num_op(const Type_handler *a,
const Type_handler *b)
const override
{ return NULL; }
static Type_collection_uuid *singleton()
{
static Type_collection_uuid tc;
return &tc;
}
};
#include "sql_type_fixedbin.h"
typedef Type_handler_fbt<UUID> UUIDBundle;
typedef Type_handler_fbt<UUID<1>, Type_collection_uuid> Type_handler_uuid_old;
typedef Type_handler_fbt<UUID<0>, Type_collection_uuid> Type_handler_uuid_new;
#endif // SQL_TYPE_UUID_INCLUDED

View file

@ -631,7 +631,8 @@ public:
*/
DBUG_ASSERT(item->type_handler()->type_handler_base_or_self()->
is_traditional_scalar_type() ||
item->type_handler() == type_handler());
item->type_handler()->type_collection() ==
type_handler()->type_collection());
return true;
}
/**
@ -646,7 +647,8 @@ public:
// See the DBUG_ASSERT comment in can_optimize_keypart_ref()
DBUG_ASSERT(item->type_handler()->type_handler_base_or_self()->
is_traditional_scalar_type() ||
item->type_handler() == type_handler());
item->type_handler()->type_collection() ==
type_handler()->type_collection());
return true;
}
void hash_not_null(Hasher *hasher) override