Skip to content

Commit b1fab9b

Browse files
committed
UUID() function should return UUID, not VARCHAR(36)
1 parent 7ab11f2 commit b1fab9b

20 files changed

+204
-182
lines changed

mysql-test/main/ctype_utf8.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11392,8 +11392,8 @@ DROP TABLE t1;
1139211392
# MDEV-20890 Illegal mix of collations with UUID()
1139311393
#
1139411394
SET NAMES utf8 COLLATE utf8_unicode_ci;
11395-
SELECT uuid()>'';
11396-
uuid()>''
11395+
SELECT sys_guid()>'';
11396+
sys_guid()>''
1139711397
1
1139811398
#
1139911399
# MDEV-8844 Unreadable control characters printed as is in warnings

mysql-test/main/ctype_utf8.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2319,7 +2319,7 @@ DROP TABLE t1;
23192319
--echo #
23202320

23212321
SET NAMES utf8 COLLATE utf8_unicode_ci;
2322-
SELECT uuid()>'';
2322+
SELECT sys_guid()>'';
23232323

23242324

23252325
--echo #

mysql-test/main/func_json.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -765,8 +765,8 @@ DROP TABLE t1;
765765
#
766766
# MDEV-16054 simple json functions flatline cpu on garbage input.
767767
#
768-
select json_array(1,uuid(),compress(5.140264e+307));
769-
json_array(1,uuid(),compress(5.140264e+307))
768+
select json_array(1,user(),compress(5.140264e+307));
769+
json_array(1,user(),compress(5.140264e+307))
770770
NULL
771771
#
772772
# MDEV-16869 String functions don't respect character set of JSON_VALUE.

mysql-test/main/func_json.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ DROP TABLE t1;
429429
--echo # MDEV-16054 simple json functions flatline cpu on garbage input.
430430
--echo #
431431

432-
select json_array(1,uuid(),compress(5.140264e+307));
432+
select json_array(1,user(),compress(5.140264e+307));
433433

434434
--echo #
435435
--echo # MDEV-16869 String functions don't respect character set of JSON_VALUE.

mysql-test/main/func_misc.result

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,12 @@ create table t1 as select uuid(), length(uuid());
118118
show create table t1;
119119
Table Create Table
120120
t1 CREATE TABLE `t1` (
121-
`uuid()` varchar(36) DEFAULT NULL,
121+
`uuid()` uuid DEFAULT NULL,
122122
`length(uuid())` int(10) DEFAULT NULL
123123
) ENGINE=MyISAM DEFAULT CHARSET=latin1
124+
select length(`uuid()`) from t1;
125+
length(`uuid()`)
126+
36
124127
drop table t1;
125128
create table t1 select INET_ATON('255.255.0.1') as `a`;
126129
show create table t1;

mysql-test/main/func_misc.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ select export_set(3, _latin1'foo', _utf8'bar', ',', 4);
106106
create table t1 as select uuid(), length(uuid());
107107
--enable_warnings
108108
show create table t1;
109+
select length(`uuid()`) from t1;
109110
drop table t1;
110111

111112
#

mysql-test/main/func_time.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2792,7 +2792,7 @@ SET sql_mode=DEFAULT;
27922792
#
27932793
# MDEV-13972 crash in Item_func_sec_to_time::get_date
27942794
#
2795-
DO TO_DAYS(SEC_TO_TIME(TIME(CEILING(UUID()))));
2795+
DO TO_DAYS(SEC_TO_TIME(TIME(CEILING(SYS_GUID()))));
27962796
DO TO_DAYS(SEC_TO_TIME(MAKEDATE('',RAND(~('')))));
27972797
Warnings:
27982798
Warning 1292 Truncated incorrect DECIMAL value: ''

mysql-test/main/func_time.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1701,7 +1701,7 @@ SET sql_mode=DEFAULT;
17011701

17021702
# The below query can return warning sporadically
17031703
--disable_warnings
1704-
DO TO_DAYS(SEC_TO_TIME(TIME(CEILING(UUID()))));
1704+
DO TO_DAYS(SEC_TO_TIME(TIME(CEILING(SYS_GUID()))));
17051705
--enable_warnings
17061706

17071707
DO TO_DAYS(SEC_TO_TIME(MAKEDATE('',RAND(~('')))));

mysql-test/suite/binlog_encryption/rpl_switch_stm_row_mixed.result

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,16 @@ select @@global.binlog_format, @@session.binlog_format;
4141
@@global.binlog_format @@session.binlog_format
4242
ROW ROW
4343
CREATE TABLE t1 (a varchar(100));
44-
prepare stmt1 from 'insert into t1 select concat(UUID(),?)';
44+
prepare stmt1 from 'insert into t1 select concat(SYS_GUID(),?)';
4545
set @string="emergency_1_";
4646
insert into t1 values("work_2_");
4747
execute stmt1 using @string;
4848
deallocate prepare stmt1;
4949
prepare stmt1 from 'insert into t1 select ?';
50-
insert into t1 values(concat(UUID(),"work_3_"));
50+
insert into t1 values(concat(SYS_GUID(),"work_3_"));
5151
execute stmt1 using @string;
5252
deallocate prepare stmt1;
53-
insert into t1 values(concat("for_4_",UUID()));
53+
insert into t1 values(concat("for_4_",SYS_GUID()));
5454
insert into t1 select "yesterday_5_";
5555
create temporary table tmp(a char(100));
5656
insert into tmp values("see_6_");
@@ -116,43 +116,43 @@ set binlog_format=default;
116116
select @@global.binlog_format, @@session.binlog_format;
117117
@@global.binlog_format @@session.binlog_format
118118
MIXED MIXED
119-
prepare stmt1 from 'insert into t1 select concat(UUID(),?)';
119+
prepare stmt1 from 'insert into t1 select concat(SYS_GUID(),?)';
120120
set @string="emergency_17_";
121121
insert into t1 values("work_18_");
122122
execute stmt1 using @string;
123123
deallocate prepare stmt1;
124124
prepare stmt1 from 'insert into t1 select ?';
125-
insert into t1 values(concat(UUID(),"work_19_"));
125+
insert into t1 values(concat(SYS_GUID(),"work_19_"));
126126
execute stmt1 using @string;
127127
deallocate prepare stmt1;
128-
insert into t1 values(concat("for_20_",UUID()));
128+
insert into t1 values(concat("for_20_",SYS_GUID()));
129129
insert into t1 select "yesterday_21_";
130130
prepare stmt1 from 'insert into t1 select ?';
131-
insert into t1 values(concat(UUID(),"work_22_"));
131+
insert into t1 values(concat(SYS_GUID(),"work_22_"));
132132
execute stmt1 using @string;
133133
deallocate prepare stmt1;
134-
insert into t1 values(concat("for_23_",UUID()));
134+
insert into t1 values(concat("for_23_",SYS_GUID()));
135135
insert into t1 select "yesterday_24_";
136-
create table t2 ENGINE=MyISAM select rpad(UUID(),100,' ');
137-
create table t3 select 1 union select UUID();
136+
create table t2 ENGINE=MyISAM select rpad(SYS_GUID(),100,' ');
137+
create table t3 select 1 union select SYS_GUID();
138138
SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR
139-
create table t4 select * from t1 where 3 in (select 1 union select 2 union select UUID() union select 3);
139+
create table t4 select * from t1 where 3 in (select 1 union select 2 union select SYS_GUID() union select 3);
140140
SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR
141141
create table t5 select * from t1 where 3 in (select 1 union select 2 union select curdate() union select 3);
142142
Warnings:
143143
Warning 1292 Truncated incorrect datetime value: '3'
144-
insert ignore into t5 select UUID() from t1 where 3 in (select 1 union select 2 union select 3 union select * from t4);
144+
insert ignore into t5 select SYS_GUID() from t1 where 3 in (select 1 union select 2 union select 3 union select * from t4);
145145
create procedure foo()
146146
begin
147147
insert into t1 values("work_25_");
148-
insert into t1 values(concat("for_26_",UUID()));
148+
insert into t1 values(concat("for_26_",SYS_GUID()));
149149
insert into t1 select "yesterday_27_";
150150
end|
151151
create procedure foo2()
152152
begin
153-
insert into t1 values(concat("emergency_28_",UUID()));
153+
insert into t1 values(concat("emergency_28_",SYS_GUID()));
154154
insert into t1 values("work_29_");
155-
insert into t1 values(concat("for_30_",UUID()));
155+
insert into t1 values(concat("for_30_",SYS_GUID()));
156156
set session binlog_format=row; # accepted for stored procs
157157
insert into t1 values("more work_31_");
158158
set session binlog_format=mixed;
@@ -171,7 +171,7 @@ end|
171171
call foo();
172172
call foo2();
173173
call foo4("hello");
174-
call foo4(UUID());
174+
call foo4(SYS_GUID());
175175
call foo4("world");
176176
select foo3();
177177
ERROR HY000: Cannot change the binary logging format inside a stored function or trigger
@@ -207,7 +207,7 @@ foo4()
207207
deallocate prepare stmt1;
208208
create function foo5() returns bigint unsigned
209209
begin
210-
insert into t2 select UUID();
210+
insert into t2 select SYS_GUID();
211211
return 100;
212212
end|
213213
select foo5();
@@ -229,18 +229,18 @@ end|
229229
select foo6("foo6_1_");
230230
foo6("foo6_1_")
231231
100
232-
select foo6(concat("foo6_2_",UUID()));
233-
foo6(concat("foo6_2_",UUID()))
232+
select foo6(concat("foo6_2_",SYS_GUID()));
233+
foo6(concat("foo6_2_",SYS_GUID()))
234234
100
235-
prepare stmt1 from 'select foo6(concat("foo6_3_",UUID()))';
235+
prepare stmt1 from 'select foo6(concat("foo6_3_",SYS_GUID()))';
236236
execute stmt1;
237-
foo6(concat("foo6_3_",UUID()))
237+
foo6(concat("foo6_3_",SYS_GUID()))
238238
100
239239
execute stmt1;
240-
foo6(concat("foo6_3_",UUID()))
240+
foo6(concat("foo6_3_",SYS_GUID()))
241241
100
242242
deallocate prepare stmt1;
243-
create view v1 as select uuid();
243+
create view v1 as select SYS_GUID();
244244
create table t11 (data varchar(255));
245245
insert into t11 select * from v1;
246246
insert into t11 select TABLE_NAME from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='mysqltest1' and TABLE_NAME IN ('v1','t11');
@@ -250,11 +250,11 @@ execute stmt1;
250250
deallocate prepare stmt1;
251251
create trigger t11_bi before insert on t11 for each row
252252
begin
253-
set NEW.data = concat(NEW.data,UUID());
253+
set NEW.data = concat(NEW.data,SYS_GUID());
254254
end|
255255
insert into t11 values("try_560_");
256256
insert delayed into t2 values("delay_1_");
257-
insert delayed into t2 values(concat("delay_2_",UUID()));
257+
insert delayed into t2 values(concat("delay_2_",SYS_GUID()));
258258
insert delayed into t2 values("delay_6_");
259259
insert delayed into t2 values(rand());
260260
set @a=2.345;
@@ -356,7 +356,7 @@ alter table t1 modify a int, drop primary key;
356356
insert into t1 values(null,"try_57_");
357357
connection slave;
358358
connection master;
359-
CREATE TEMPORARY TABLE t15 SELECT UUID();
359+
CREATE TEMPORARY TABLE t15 SELECT SYS_GUID();
360360
create table t16 like t15;
361361
INSERT INTO t16 SELECT * FROM t15;
362362
insert into t16 values("try_65_");
@@ -427,7 +427,7 @@ DROP TABLE IF EXISTS t12;
427427
SET SESSION BINLOG_FORMAT=MIXED;
428428
CREATE TABLE t12 (data LONG);
429429
LOCK TABLES t12 WRITE;
430-
INSERT INTO t12 VALUES(UUID());
430+
INSERT INTO t12 VALUES(SYS_GUID());
431431
UNLOCK TABLES;
432432
connection slave;
433433
connection master;

mysql-test/suite/engines/funcs/r/rpl_switch_stm_row_mixed.result

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,16 @@ select @@global.binlog_format, @@session.binlog_format;
4141
@@global.binlog_format @@session.binlog_format
4242
ROW ROW
4343
CREATE TABLE t1 (a varchar(100));
44-
prepare stmt1 from 'insert into t1 select concat(UUID(),?)';
44+
prepare stmt1 from 'insert into t1 select concat(SYS_GUID(),?)';
4545
set @string="emergency_1_";
4646
insert into t1 values("work_2_");
4747
execute stmt1 using @string;
4848
deallocate prepare stmt1;
4949
prepare stmt1 from 'insert into t1 select ?';
50-
insert into t1 values(concat(UUID(),"work_3_"));
50+
insert into t1 values(concat(SYS_GUID(),"work_3_"));
5151
execute stmt1 using @string;
5252
deallocate prepare stmt1;
53-
insert into t1 values(concat("for_4_",UUID()));
53+
insert into t1 values(concat("for_4_",SYS_GUID()));
5454
insert into t1 select "yesterday_5_";
5555
create temporary table tmp(a char(100));
5656
insert into tmp values("see_6_");
@@ -116,43 +116,43 @@ set binlog_format=default;
116116
select @@global.binlog_format, @@session.binlog_format;
117117
@@global.binlog_format @@session.binlog_format
118118
MIXED MIXED
119-
prepare stmt1 from 'insert into t1 select concat(UUID(),?)';
119+
prepare stmt1 from 'insert into t1 select concat(SYS_GUID(),?)';
120120
set @string="emergency_17_";
121121
insert into t1 values("work_18_");
122122
execute stmt1 using @string;
123123
deallocate prepare stmt1;
124124
prepare stmt1 from 'insert into t1 select ?';
125-
insert into t1 values(concat(UUID(),"work_19_"));
125+
insert into t1 values(concat(SYS_GUID(),"work_19_"));
126126
execute stmt1 using @string;
127127
deallocate prepare stmt1;
128-
insert into t1 values(concat("for_20_",UUID()));
128+
insert into t1 values(concat("for_20_",SYS_GUID()));
129129
insert into t1 select "yesterday_21_";
130130
prepare stmt1 from 'insert into t1 select ?';
131-
insert into t1 values(concat(UUID(),"work_22_"));
131+
insert into t1 values(concat(SYS_GUID(),"work_22_"));
132132
execute stmt1 using @string;
133133
deallocate prepare stmt1;
134-
insert into t1 values(concat("for_23_",UUID()));
134+
insert into t1 values(concat("for_23_",SYS_GUID()));
135135
insert into t1 select "yesterday_24_";
136-
create table t2 ENGINE=MyISAM select rpad(UUID(),100,' ');
137-
create table t3 select 1 union select UUID();
136+
create table t2 ENGINE=MyISAM select rpad(SYS_GUID(),100,' ');
137+
create table t3 select 1 union select SYS_GUID();
138138
SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR
139-
create table t4 select * from t1 where 3 in (select 1 union select 2 union select UUID() union select 3);
139+
create table t4 select * from t1 where 3 in (select 1 union select 2 union select SYS_GUID() union select 3);
140140
SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR
141141
create table t5 select * from t1 where 3 in (select 1 union select 2 union select curdate() union select 3);
142142
Warnings:
143143
Warning 1292 Truncated incorrect datetime value: '3'
144-
insert ignore into t5 select UUID() from t1 where 3 in (select 1 union select 2 union select 3 union select * from t4);
144+
insert ignore into t5 select SYS_GUID() from t1 where 3 in (select 1 union select 2 union select 3 union select * from t4);
145145
create procedure foo()
146146
begin
147147
insert into t1 values("work_25_");
148-
insert into t1 values(concat("for_26_",UUID()));
148+
insert into t1 values(concat("for_26_",SYS_GUID()));
149149
insert into t1 select "yesterday_27_";
150150
end|
151151
create procedure foo2()
152152
begin
153-
insert into t1 values(concat("emergency_28_",UUID()));
153+
insert into t1 values(concat("emergency_28_",SYS_GUID()));
154154
insert into t1 values("work_29_");
155-
insert into t1 values(concat("for_30_",UUID()));
155+
insert into t1 values(concat("for_30_",SYS_GUID()));
156156
set session binlog_format=row; # accepted for stored procs
157157
insert into t1 values("more work_31_");
158158
set session binlog_format=mixed;
@@ -171,7 +171,7 @@ end|
171171
call foo();
172172
call foo2();
173173
call foo4("hello");
174-
call foo4(UUID());
174+
call foo4(SYS_GUID());
175175
call foo4("world");
176176
select foo3();
177177
ERROR HY000: Cannot change the binary logging format inside a stored function or trigger
@@ -207,7 +207,7 @@ foo4()
207207
deallocate prepare stmt1;
208208
create function foo5() returns bigint unsigned
209209
begin
210-
insert into t2 select UUID();
210+
insert into t2 select SYS_GUID();
211211
return 100;
212212
end|
213213
select foo5();
@@ -229,18 +229,18 @@ end|
229229
select foo6("foo6_1_");
230230
foo6("foo6_1_")
231231
100
232-
select foo6(concat("foo6_2_",UUID()));
233-
foo6(concat("foo6_2_",UUID()))
232+
select foo6(concat("foo6_2_",SYS_GUID()));
233+
foo6(concat("foo6_2_",SYS_GUID()))
234234
100
235-
prepare stmt1 from 'select foo6(concat("foo6_3_",UUID()))';
235+
prepare stmt1 from 'select foo6(concat("foo6_3_",SYS_GUID()))';
236236
execute stmt1;
237-
foo6(concat("foo6_3_",UUID()))
237+
foo6(concat("foo6_3_",SYS_GUID()))
238238
100
239239
execute stmt1;
240-
foo6(concat("foo6_3_",UUID()))
240+
foo6(concat("foo6_3_",SYS_GUID()))
241241
100
242242
deallocate prepare stmt1;
243-
create view v1 as select uuid();
243+
create view v1 as select SYS_GUID();
244244
create table t11 (data varchar(255));
245245
insert into t11 select * from v1;
246246
insert into t11 select TABLE_NAME from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='mysqltest1' and TABLE_NAME IN ('v1','t11');
@@ -250,11 +250,11 @@ execute stmt1;
250250
deallocate prepare stmt1;
251251
create trigger t11_bi before insert on t11 for each row
252252
begin
253-
set NEW.data = concat(NEW.data,UUID());
253+
set NEW.data = concat(NEW.data,SYS_GUID());
254254
end|
255255
insert into t11 values("try_560_");
256256
insert delayed into t2 values("delay_1_");
257-
insert delayed into t2 values(concat("delay_2_",UUID()));
257+
insert delayed into t2 values(concat("delay_2_",SYS_GUID()));
258258
insert delayed into t2 values("delay_6_");
259259
insert delayed into t2 values(rand());
260260
set @a=2.345;
@@ -356,7 +356,7 @@ alter table t1 modify a int, drop primary key;
356356
insert into t1 values(null,"try_57_");
357357
connection slave;
358358
connection master;
359-
CREATE TEMPORARY TABLE t15 SELECT UUID();
359+
CREATE TEMPORARY TABLE t15 SELECT SYS_GUID();
360360
create table t16 like t15;
361361
INSERT INTO t16 SELECT * FROM t15;
362362
insert into t16 values("try_65_");
@@ -427,7 +427,7 @@ DROP TABLE IF EXISTS t12;
427427
SET SESSION BINLOG_FORMAT=MIXED;
428428
CREATE TABLE t12 (data LONG);
429429
LOCK TABLES t12 WRITE;
430-
INSERT INTO t12 VALUES(UUID());
430+
INSERT INTO t12 VALUES(SYS_GUID());
431431
UNLOCK TABLES;
432432
connection slave;
433433
connection master;

0 commit comments

Comments
 (0)