1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

UUID() function should return UUID, not VARCHAR(36)

This commit is contained in:
Sergei Golubchik
2021-09-14 12:08:01 +02:00
parent 7ab11f2bda
commit b1fab9bf4e
20 changed files with 204 additions and 182 deletions

View File

@ -11392,8 +11392,8 @@ DROP TABLE t1;
# MDEV-20890 Illegal mix of collations with UUID() # MDEV-20890 Illegal mix of collations with UUID()
# #
SET NAMES utf8 COLLATE utf8_unicode_ci; SET NAMES utf8 COLLATE utf8_unicode_ci;
SELECT uuid()>''; SELECT sys_guid()>'';
uuid()>'' sys_guid()>''
1 1
# #
# MDEV-8844 Unreadable control characters printed as is in warnings # MDEV-8844 Unreadable control characters printed as is in warnings

View File

@ -2319,7 +2319,7 @@ DROP TABLE t1;
--echo # --echo #
SET NAMES utf8 COLLATE utf8_unicode_ci; SET NAMES utf8 COLLATE utf8_unicode_ci;
SELECT uuid()>''; SELECT sys_guid()>'';
--echo # --echo #

View File

@ -765,8 +765,8 @@ DROP TABLE t1;
# #
# MDEV-16054 simple json functions flatline cpu on garbage input. # MDEV-16054 simple json functions flatline cpu on garbage input.
# #
select json_array(1,uuid(),compress(5.140264e+307)); select json_array(1,user(),compress(5.140264e+307));
json_array(1,uuid(),compress(5.140264e+307)) json_array(1,user(),compress(5.140264e+307))
NULL NULL
# #
# MDEV-16869 String functions don't respect character set of JSON_VALUE. # MDEV-16869 String functions don't respect character set of JSON_VALUE.

View File

@ -429,7 +429,7 @@ DROP TABLE t1;
--echo # MDEV-16054 simple json functions flatline cpu on garbage input. --echo # MDEV-16054 simple json functions flatline cpu on garbage input.
--echo # --echo #
select json_array(1,uuid(),compress(5.140264e+307)); select json_array(1,user(),compress(5.140264e+307));
--echo # --echo #
--echo # MDEV-16869 String functions don't respect character set of JSON_VALUE. --echo # MDEV-16869 String functions don't respect character set of JSON_VALUE.

View File

@ -118,9 +118,12 @@ create table t1 as select uuid(), length(uuid());
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`uuid()` varchar(36) DEFAULT NULL, `uuid()` uuid DEFAULT NULL,
`length(uuid())` int(10) DEFAULT NULL `length(uuid())` int(10) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
select length(`uuid()`) from t1;
length(`uuid()`)
36
drop table t1; drop table t1;
create table t1 select INET_ATON('255.255.0.1') as `a`; create table t1 select INET_ATON('255.255.0.1') as `a`;
show create table t1; show create table t1;

View File

@ -106,6 +106,7 @@ select export_set(3, _latin1'foo', _utf8'bar', ',', 4);
create table t1 as select uuid(), length(uuid()); create table t1 as select uuid(), length(uuid());
--enable_warnings --enable_warnings
show create table t1; show create table t1;
select length(`uuid()`) from t1;
drop table t1; drop table t1;
# #

View File

@ -2792,7 +2792,7 @@ SET sql_mode=DEFAULT;
# #
# MDEV-13972 crash in Item_func_sec_to_time::get_date # MDEV-13972 crash in Item_func_sec_to_time::get_date
# #
DO TO_DAYS(SEC_TO_TIME(TIME(CEILING(UUID())))); DO TO_DAYS(SEC_TO_TIME(TIME(CEILING(SYS_GUID()))));
DO TO_DAYS(SEC_TO_TIME(MAKEDATE('',RAND(~(''))))); DO TO_DAYS(SEC_TO_TIME(MAKEDATE('',RAND(~('')))));
Warnings: Warnings:
Warning 1292 Truncated incorrect DECIMAL value: '' Warning 1292 Truncated incorrect DECIMAL value: ''

View File

@ -1701,7 +1701,7 @@ SET sql_mode=DEFAULT;
# The below query can return warning sporadically # The below query can return warning sporadically
--disable_warnings --disable_warnings
DO TO_DAYS(SEC_TO_TIME(TIME(CEILING(UUID())))); DO TO_DAYS(SEC_TO_TIME(TIME(CEILING(SYS_GUID()))));
--enable_warnings --enable_warnings
DO TO_DAYS(SEC_TO_TIME(MAKEDATE('',RAND(~(''))))); DO TO_DAYS(SEC_TO_TIME(MAKEDATE('',RAND(~('')))));

View File

@ -41,16 +41,16 @@ select @@global.binlog_format, @@session.binlog_format;
@@global.binlog_format @@session.binlog_format @@global.binlog_format @@session.binlog_format
ROW ROW ROW ROW
CREATE TABLE t1 (a varchar(100)); CREATE TABLE t1 (a varchar(100));
prepare stmt1 from 'insert into t1 select concat(UUID(),?)'; prepare stmt1 from 'insert into t1 select concat(SYS_GUID(),?)';
set @string="emergency_1_"; set @string="emergency_1_";
insert into t1 values("work_2_"); insert into t1 values("work_2_");
execute stmt1 using @string; execute stmt1 using @string;
deallocate prepare stmt1; deallocate prepare stmt1;
prepare stmt1 from 'insert into t1 select ?'; prepare stmt1 from 'insert into t1 select ?';
insert into t1 values(concat(UUID(),"work_3_")); insert into t1 values(concat(SYS_GUID(),"work_3_"));
execute stmt1 using @string; execute stmt1 using @string;
deallocate prepare stmt1; deallocate prepare stmt1;
insert into t1 values(concat("for_4_",UUID())); insert into t1 values(concat("for_4_",SYS_GUID()));
insert into t1 select "yesterday_5_"; insert into t1 select "yesterday_5_";
create temporary table tmp(a char(100)); create temporary table tmp(a char(100));
insert into tmp values("see_6_"); insert into tmp values("see_6_");
@ -116,43 +116,43 @@ set binlog_format=default;
select @@global.binlog_format, @@session.binlog_format; select @@global.binlog_format, @@session.binlog_format;
@@global.binlog_format @@session.binlog_format @@global.binlog_format @@session.binlog_format
MIXED MIXED MIXED MIXED
prepare stmt1 from 'insert into t1 select concat(UUID(),?)'; prepare stmt1 from 'insert into t1 select concat(SYS_GUID(),?)';
set @string="emergency_17_"; set @string="emergency_17_";
insert into t1 values("work_18_"); insert into t1 values("work_18_");
execute stmt1 using @string; execute stmt1 using @string;
deallocate prepare stmt1; deallocate prepare stmt1;
prepare stmt1 from 'insert into t1 select ?'; prepare stmt1 from 'insert into t1 select ?';
insert into t1 values(concat(UUID(),"work_19_")); insert into t1 values(concat(SYS_GUID(),"work_19_"));
execute stmt1 using @string; execute stmt1 using @string;
deallocate prepare stmt1; deallocate prepare stmt1;
insert into t1 values(concat("for_20_",UUID())); insert into t1 values(concat("for_20_",SYS_GUID()));
insert into t1 select "yesterday_21_"; insert into t1 select "yesterday_21_";
prepare stmt1 from 'insert into t1 select ?'; prepare stmt1 from 'insert into t1 select ?';
insert into t1 values(concat(UUID(),"work_22_")); insert into t1 values(concat(SYS_GUID(),"work_22_"));
execute stmt1 using @string; execute stmt1 using @string;
deallocate prepare stmt1; deallocate prepare stmt1;
insert into t1 values(concat("for_23_",UUID())); insert into t1 values(concat("for_23_",SYS_GUID()));
insert into t1 select "yesterday_24_"; insert into t1 select "yesterday_24_";
create table t2 ENGINE=MyISAM select rpad(UUID(),100,' '); create table t2 ENGINE=MyISAM select rpad(SYS_GUID(),100,' ');
create table t3 select 1 union select UUID(); create table t3 select 1 union select SYS_GUID();
SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR
create table t4 select * from t1 where 3 in (select 1 union select 2 union select UUID() union select 3); create table t4 select * from t1 where 3 in (select 1 union select 2 union select SYS_GUID() union select 3);
SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR
create table t5 select * from t1 where 3 in (select 1 union select 2 union select curdate() union select 3); create table t5 select * from t1 where 3 in (select 1 union select 2 union select curdate() union select 3);
Warnings: Warnings:
Warning 1292 Truncated incorrect datetime value: '3' Warning 1292 Truncated incorrect datetime value: '3'
insert ignore into t5 select UUID() from t1 where 3 in (select 1 union select 2 union select 3 union select * from t4); insert ignore into t5 select SYS_GUID() from t1 where 3 in (select 1 union select 2 union select 3 union select * from t4);
create procedure foo() create procedure foo()
begin begin
insert into t1 values("work_25_"); insert into t1 values("work_25_");
insert into t1 values(concat("for_26_",UUID())); insert into t1 values(concat("for_26_",SYS_GUID()));
insert into t1 select "yesterday_27_"; insert into t1 select "yesterday_27_";
end| end|
create procedure foo2() create procedure foo2()
begin begin
insert into t1 values(concat("emergency_28_",UUID())); insert into t1 values(concat("emergency_28_",SYS_GUID()));
insert into t1 values("work_29_"); insert into t1 values("work_29_");
insert into t1 values(concat("for_30_",UUID())); insert into t1 values(concat("for_30_",SYS_GUID()));
set session binlog_format=row; # accepted for stored procs set session binlog_format=row; # accepted for stored procs
insert into t1 values("more work_31_"); insert into t1 values("more work_31_");
set session binlog_format=mixed; set session binlog_format=mixed;
@ -171,7 +171,7 @@ end|
call foo(); call foo();
call foo2(); call foo2();
call foo4("hello"); call foo4("hello");
call foo4(UUID()); call foo4(SYS_GUID());
call foo4("world"); call foo4("world");
select foo3(); select foo3();
ERROR HY000: Cannot change the binary logging format inside a stored function or trigger ERROR HY000: Cannot change the binary logging format inside a stored function or trigger
@ -207,7 +207,7 @@ foo4()
deallocate prepare stmt1; deallocate prepare stmt1;
create function foo5() returns bigint unsigned create function foo5() returns bigint unsigned
begin begin
insert into t2 select UUID(); insert into t2 select SYS_GUID();
return 100; return 100;
end| end|
select foo5(); select foo5();
@ -229,18 +229,18 @@ end|
select foo6("foo6_1_"); select foo6("foo6_1_");
foo6("foo6_1_") foo6("foo6_1_")
100 100
select foo6(concat("foo6_2_",UUID())); select foo6(concat("foo6_2_",SYS_GUID()));
foo6(concat("foo6_2_",UUID())) foo6(concat("foo6_2_",SYS_GUID()))
100 100
prepare stmt1 from 'select foo6(concat("foo6_3_",UUID()))'; prepare stmt1 from 'select foo6(concat("foo6_3_",SYS_GUID()))';
execute stmt1; execute stmt1;
foo6(concat("foo6_3_",UUID())) foo6(concat("foo6_3_",SYS_GUID()))
100 100
execute stmt1; execute stmt1;
foo6(concat("foo6_3_",UUID())) foo6(concat("foo6_3_",SYS_GUID()))
100 100
deallocate prepare stmt1; deallocate prepare stmt1;
create view v1 as select uuid(); create view v1 as select SYS_GUID();
create table t11 (data varchar(255)); create table t11 (data varchar(255));
insert into t11 select * from v1; insert into t11 select * from v1;
insert into t11 select TABLE_NAME from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='mysqltest1' and TABLE_NAME IN ('v1','t11'); 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;
deallocate prepare stmt1; deallocate prepare stmt1;
create trigger t11_bi before insert on t11 for each row create trigger t11_bi before insert on t11 for each row
begin begin
set NEW.data = concat(NEW.data,UUID()); set NEW.data = concat(NEW.data,SYS_GUID());
end| end|
insert into t11 values("try_560_"); insert into t11 values("try_560_");
insert delayed into t2 values("delay_1_"); insert delayed into t2 values("delay_1_");
insert delayed into t2 values(concat("delay_2_",UUID())); insert delayed into t2 values(concat("delay_2_",SYS_GUID()));
insert delayed into t2 values("delay_6_"); insert delayed into t2 values("delay_6_");
insert delayed into t2 values(rand()); insert delayed into t2 values(rand());
set @a=2.345; set @a=2.345;
@ -356,7 +356,7 @@ alter table t1 modify a int, drop primary key;
insert into t1 values(null,"try_57_"); insert into t1 values(null,"try_57_");
connection slave; connection slave;
connection master; connection master;
CREATE TEMPORARY TABLE t15 SELECT UUID(); CREATE TEMPORARY TABLE t15 SELECT SYS_GUID();
create table t16 like t15; create table t16 like t15;
INSERT INTO t16 SELECT * FROM t15; INSERT INTO t16 SELECT * FROM t15;
insert into t16 values("try_65_"); insert into t16 values("try_65_");
@ -427,7 +427,7 @@ DROP TABLE IF EXISTS t12;
SET SESSION BINLOG_FORMAT=MIXED; SET SESSION BINLOG_FORMAT=MIXED;
CREATE TABLE t12 (data LONG); CREATE TABLE t12 (data LONG);
LOCK TABLES t12 WRITE; LOCK TABLES t12 WRITE;
INSERT INTO t12 VALUES(UUID()); INSERT INTO t12 VALUES(SYS_GUID());
UNLOCK TABLES; UNLOCK TABLES;
connection slave; connection slave;
connection master; connection master;

View File

@ -41,16 +41,16 @@ select @@global.binlog_format, @@session.binlog_format;
@@global.binlog_format @@session.binlog_format @@global.binlog_format @@session.binlog_format
ROW ROW ROW ROW
CREATE TABLE t1 (a varchar(100)); CREATE TABLE t1 (a varchar(100));
prepare stmt1 from 'insert into t1 select concat(UUID(),?)'; prepare stmt1 from 'insert into t1 select concat(SYS_GUID(),?)';
set @string="emergency_1_"; set @string="emergency_1_";
insert into t1 values("work_2_"); insert into t1 values("work_2_");
execute stmt1 using @string; execute stmt1 using @string;
deallocate prepare stmt1; deallocate prepare stmt1;
prepare stmt1 from 'insert into t1 select ?'; prepare stmt1 from 'insert into t1 select ?';
insert into t1 values(concat(UUID(),"work_3_")); insert into t1 values(concat(SYS_GUID(),"work_3_"));
execute stmt1 using @string; execute stmt1 using @string;
deallocate prepare stmt1; deallocate prepare stmt1;
insert into t1 values(concat("for_4_",UUID())); insert into t1 values(concat("for_4_",SYS_GUID()));
insert into t1 select "yesterday_5_"; insert into t1 select "yesterday_5_";
create temporary table tmp(a char(100)); create temporary table tmp(a char(100));
insert into tmp values("see_6_"); insert into tmp values("see_6_");
@ -116,43 +116,43 @@ set binlog_format=default;
select @@global.binlog_format, @@session.binlog_format; select @@global.binlog_format, @@session.binlog_format;
@@global.binlog_format @@session.binlog_format @@global.binlog_format @@session.binlog_format
MIXED MIXED MIXED MIXED
prepare stmt1 from 'insert into t1 select concat(UUID(),?)'; prepare stmt1 from 'insert into t1 select concat(SYS_GUID(),?)';
set @string="emergency_17_"; set @string="emergency_17_";
insert into t1 values("work_18_"); insert into t1 values("work_18_");
execute stmt1 using @string; execute stmt1 using @string;
deallocate prepare stmt1; deallocate prepare stmt1;
prepare stmt1 from 'insert into t1 select ?'; prepare stmt1 from 'insert into t1 select ?';
insert into t1 values(concat(UUID(),"work_19_")); insert into t1 values(concat(SYS_GUID(),"work_19_"));
execute stmt1 using @string; execute stmt1 using @string;
deallocate prepare stmt1; deallocate prepare stmt1;
insert into t1 values(concat("for_20_",UUID())); insert into t1 values(concat("for_20_",SYS_GUID()));
insert into t1 select "yesterday_21_"; insert into t1 select "yesterday_21_";
prepare stmt1 from 'insert into t1 select ?'; prepare stmt1 from 'insert into t1 select ?';
insert into t1 values(concat(UUID(),"work_22_")); insert into t1 values(concat(SYS_GUID(),"work_22_"));
execute stmt1 using @string; execute stmt1 using @string;
deallocate prepare stmt1; deallocate prepare stmt1;
insert into t1 values(concat("for_23_",UUID())); insert into t1 values(concat("for_23_",SYS_GUID()));
insert into t1 select "yesterday_24_"; insert into t1 select "yesterday_24_";
create table t2 ENGINE=MyISAM select rpad(UUID(),100,' '); create table t2 ENGINE=MyISAM select rpad(SYS_GUID(),100,' ');
create table t3 select 1 union select UUID(); create table t3 select 1 union select SYS_GUID();
SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR
create table t4 select * from t1 where 3 in (select 1 union select 2 union select UUID() union select 3); create table t4 select * from t1 where 3 in (select 1 union select 2 union select SYS_GUID() union select 3);
SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR
create table t5 select * from t1 where 3 in (select 1 union select 2 union select curdate() union select 3); create table t5 select * from t1 where 3 in (select 1 union select 2 union select curdate() union select 3);
Warnings: Warnings:
Warning 1292 Truncated incorrect datetime value: '3' Warning 1292 Truncated incorrect datetime value: '3'
insert ignore into t5 select UUID() from t1 where 3 in (select 1 union select 2 union select 3 union select * from t4); insert ignore into t5 select SYS_GUID() from t1 where 3 in (select 1 union select 2 union select 3 union select * from t4);
create procedure foo() create procedure foo()
begin begin
insert into t1 values("work_25_"); insert into t1 values("work_25_");
insert into t1 values(concat("for_26_",UUID())); insert into t1 values(concat("for_26_",SYS_GUID()));
insert into t1 select "yesterday_27_"; insert into t1 select "yesterday_27_";
end| end|
create procedure foo2() create procedure foo2()
begin begin
insert into t1 values(concat("emergency_28_",UUID())); insert into t1 values(concat("emergency_28_",SYS_GUID()));
insert into t1 values("work_29_"); insert into t1 values("work_29_");
insert into t1 values(concat("for_30_",UUID())); insert into t1 values(concat("for_30_",SYS_GUID()));
set session binlog_format=row; # accepted for stored procs set session binlog_format=row; # accepted for stored procs
insert into t1 values("more work_31_"); insert into t1 values("more work_31_");
set session binlog_format=mixed; set session binlog_format=mixed;
@ -171,7 +171,7 @@ end|
call foo(); call foo();
call foo2(); call foo2();
call foo4("hello"); call foo4("hello");
call foo4(UUID()); call foo4(SYS_GUID());
call foo4("world"); call foo4("world");
select foo3(); select foo3();
ERROR HY000: Cannot change the binary logging format inside a stored function or trigger ERROR HY000: Cannot change the binary logging format inside a stored function or trigger
@ -207,7 +207,7 @@ foo4()
deallocate prepare stmt1; deallocate prepare stmt1;
create function foo5() returns bigint unsigned create function foo5() returns bigint unsigned
begin begin
insert into t2 select UUID(); insert into t2 select SYS_GUID();
return 100; return 100;
end| end|
select foo5(); select foo5();
@ -229,18 +229,18 @@ end|
select foo6("foo6_1_"); select foo6("foo6_1_");
foo6("foo6_1_") foo6("foo6_1_")
100 100
select foo6(concat("foo6_2_",UUID())); select foo6(concat("foo6_2_",SYS_GUID()));
foo6(concat("foo6_2_",UUID())) foo6(concat("foo6_2_",SYS_GUID()))
100 100
prepare stmt1 from 'select foo6(concat("foo6_3_",UUID()))'; prepare stmt1 from 'select foo6(concat("foo6_3_",SYS_GUID()))';
execute stmt1; execute stmt1;
foo6(concat("foo6_3_",UUID())) foo6(concat("foo6_3_",SYS_GUID()))
100 100
execute stmt1; execute stmt1;
foo6(concat("foo6_3_",UUID())) foo6(concat("foo6_3_",SYS_GUID()))
100 100
deallocate prepare stmt1; deallocate prepare stmt1;
create view v1 as select uuid(); create view v1 as select SYS_GUID();
create table t11 (data varchar(255)); create table t11 (data varchar(255));
insert into t11 select * from v1; insert into t11 select * from v1;
insert into t11 select TABLE_NAME from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='mysqltest1' and TABLE_NAME IN ('v1','t11'); 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;
deallocate prepare stmt1; deallocate prepare stmt1;
create trigger t11_bi before insert on t11 for each row create trigger t11_bi before insert on t11 for each row
begin begin
set NEW.data = concat(NEW.data,UUID()); set NEW.data = concat(NEW.data,SYS_GUID());
end| end|
insert into t11 values("try_560_"); insert into t11 values("try_560_");
insert delayed into t2 values("delay_1_"); insert delayed into t2 values("delay_1_");
insert delayed into t2 values(concat("delay_2_",UUID())); insert delayed into t2 values(concat("delay_2_",SYS_GUID()));
insert delayed into t2 values("delay_6_"); insert delayed into t2 values("delay_6_");
insert delayed into t2 values(rand()); insert delayed into t2 values(rand());
set @a=2.345; set @a=2.345;
@ -356,7 +356,7 @@ alter table t1 modify a int, drop primary key;
insert into t1 values(null,"try_57_"); insert into t1 values(null,"try_57_");
connection slave; connection slave;
connection master; connection master;
CREATE TEMPORARY TABLE t15 SELECT UUID(); CREATE TEMPORARY TABLE t15 SELECT SYS_GUID();
create table t16 like t15; create table t16 like t15;
INSERT INTO t16 SELECT * FROM t15; INSERT INTO t16 SELECT * FROM t15;
insert into t16 values("try_65_"); insert into t16 values("try_65_");
@ -427,7 +427,7 @@ DROP TABLE IF EXISTS t12;
SET SESSION BINLOG_FORMAT=MIXED; SET SESSION BINLOG_FORMAT=MIXED;
CREATE TABLE t12 (data LONG); CREATE TABLE t12 (data LONG);
LOCK TABLES t12 WRITE; LOCK TABLES t12 WRITE;
INSERT INTO t12 VALUES(UUID()); INSERT INTO t12 VALUES(SYS_GUID());
UNLOCK TABLES; UNLOCK TABLES;
connection slave; connection slave;
connection master; connection master;

View File

@ -29,7 +29,7 @@ INSERT INTO t2 VALUES(1, 't2, text 1');
--echo --echo
--echo ******************** DELETE ******************** --echo ******************** DELETE ********************
DELETE FROM t1 WHERE a = 1; DELETE FROM t1 WHERE a = 1;
DELETE FROM t2 WHERE b <> UUID(); DELETE FROM t2 WHERE b <> SYS_GUID();
--source suite/rpl/include/rpl_mixed_check_select.inc --source suite/rpl/include/rpl_mixed_check_select.inc
--source suite/rpl/include/rpl_mixed_clear_tables.inc --source suite/rpl/include/rpl_mixed_clear_tables.inc
@ -37,7 +37,7 @@ DELETE FROM t2 WHERE b <> UUID();
--echo --echo
--echo ******************** INSERT ******************** --echo ******************** INSERT ********************
INSERT INTO t1 VALUES(1, 't1, text 1'); INSERT INTO t1 VALUES(1, 't1, text 1');
INSERT INTO t1 VALUES(2, UUID()); INSERT INTO t1 VALUES(2, SYS_GUID());
INSERT INTO t2 SELECT * FROM t1; INSERT INTO t2 SELECT * FROM t1;
INSERT INTO t2 VALUES (1, 't1, text 1') ON DUPLICATE KEY UPDATE b = 't2, text 1'; INSERT INTO t2 VALUES (1, 't1, text 1') ON DUPLICATE KEY UPDATE b = 't2, text 1';
DELETE FROM t1 WHERE a = 2; DELETE FROM t1 WHERE a = 2;
@ -60,7 +60,7 @@ INSERT INTO t1 VALUES(1, 't1, text 1');
INSERT INTO t1 VALUES(2, 't1, text 2'); INSERT INTO t1 VALUES(2, 't1, text 2');
INSERT INTO t1 VALUES(3, 't1, text 3'); INSERT INTO t1 VALUES(3, 't1, text 3');
REPLACE INTO t1 VALUES(1, 't1, text 11'); REPLACE INTO t1 VALUES(1, 't1, text 11');
REPLACE INTO t1 VALUES(2, UUID()); REPLACE INTO t1 VALUES(2, SYS_GUID());
REPLACE INTO t1 SET a=3, b='t1, text 33'; REPLACE INTO t1 SET a=3, b='t1, text 33';
DELETE FROM t1 WHERE a = 2; DELETE FROM t1 WHERE a = 2;
--source suite/rpl/include/rpl_mixed_check_select.inc --source suite/rpl/include/rpl_mixed_check_select.inc
@ -70,7 +70,7 @@ DELETE FROM t1 WHERE a = 2;
--echo --echo
--echo ******************** SELECT ******************** --echo ******************** SELECT ********************
INSERT INTO t1 VALUES(1, 't1, text 1'); INSERT INTO t1 VALUES(1, 't1, text 1');
SELECT * FROM t1 WHERE b <> UUID() ORDER BY a; SELECT * FROM t1 WHERE b <> SYS_GUID() ORDER BY a;
--source suite/rpl/include/rpl_mixed_clear_tables.inc --source suite/rpl/include/rpl_mixed_clear_tables.inc
# JOIN # JOIN
@ -89,7 +89,7 @@ SELECT * FROM t1 INNER JOIN t2 ON t1.b = t2.b ORDER BY t1.a,t2.a;
--echo ******************** UNION ******************** --echo ******************** UNION ********************
INSERT INTO t1 VALUES(1, 't1, text 1'); INSERT INTO t1 VALUES(1, 't1, text 1');
INSERT INTO t2 VALUES(1, 't2, text 1'); INSERT INTO t2 VALUES(1, 't2, text 1');
SELECT * FROM t1 UNION SELECT * FROM t2 WHERE t2.b <> UUID(); SELECT * FROM t1 UNION SELECT * FROM t2 WHERE t2.b <> SYS_GUID();
--source suite/rpl/include/rpl_mixed_clear_tables.inc --source suite/rpl/include/rpl_mixed_clear_tables.inc
# TRUNCATE # TRUNCATE
@ -144,7 +144,7 @@ START TRANSACTION;
INSERT INTO t1 VALUES (5, 'before savepoint s2'); INSERT INTO t1 VALUES (5, 'before savepoint s2');
SAVEPOINT s2; SAVEPOINT s2;
INSERT INTO t1 VALUES (6, 'after savepoint s2'); INSERT INTO t1 VALUES (6, 'after savepoint s2');
INSERT INTO t1 VALUES (7, CONCAT('with UUID() ',UUID())); INSERT INTO t1 VALUES (7, CONCAT('with SYS_GUID() ',SYS_GUID()));
RELEASE SAVEPOINT s2; RELEASE SAVEPOINT s2;
COMMIT; COMMIT;
DELETE FROM t1 WHERE a = 7; DELETE FROM t1 WHERE a = 7;
@ -257,7 +257,7 @@ BEGIN
END| END|
CREATE PROCEDURE p2 () CREATE PROCEDURE p2 ()
BEGIN BEGIN
UPDATE t1 SET b = UUID() WHERE a = 202; UPDATE t1 SET b = SYS_GUID() WHERE a = 202;
END| END|
DELIMITER ;| DELIMITER ;|
INSERT INTO t1 VALUES(201, 'test 201'); INSERT INTO t1 VALUES(201, 'test 201');
@ -309,7 +309,7 @@ DROP EVENT e2;
INSERT INTO t1 VALUES(1, 'test1'); INSERT INTO t1 VALUES(1, 'test1');
INSERT INTO t1 VALUES(2, 'test2'); INSERT INTO t1 VALUES(2, 'test2');
CREATE VIEW v1 AS SELECT * FROM t1 WHERE a = 1; CREATE VIEW v1 AS SELECT * FROM t1 WHERE a = 1;
CREATE VIEW v2 AS SELECT * FROM t1 WHERE b <> UUID(); CREATE VIEW v2 AS SELECT * FROM t1 WHERE b <> SYS_GUID();
--source suite/rpl/include/rpl_mixed_check_view.inc --source suite/rpl/include/rpl_mixed_check_view.inc
ALTER VIEW v1 AS SELECT * FROM t1 WHERE a = 2; ALTER VIEW v1 AS SELECT * FROM t1 WHERE a = 2;
--source suite/rpl/include/rpl_mixed_check_view.inc --source suite/rpl/include/rpl_mixed_check_view.inc
@ -323,7 +323,7 @@ DROP VIEW v2;
--echo ******************** SHOW BINLOG EVENTS ******************** --echo ******************** SHOW BINLOG EVENTS ********************
--source include/show_binlog_events.inc --source include/show_binlog_events.inc
sync_slave_with_master; sync_slave_with_master;
# as we're using UUID we don't SELECT but use "diff" like in rpl_row_UUID # as we're using SYS_GUID we don't SELECT but use "diff" like in rpl_row_SYS_GUID
--exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test_rpl > $MYSQLTEST_VARDIR/tmp/rpl_switch_stm_row_mixed_master.sql --exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test_rpl > $MYSQLTEST_VARDIR/tmp/rpl_switch_stm_row_mixed_master.sql
--exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test_rpl > $MYSQLTEST_VARDIR/tmp/rpl_switch_stm_row_mixed_slave.sql --exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test_rpl > $MYSQLTEST_VARDIR/tmp/rpl_switch_stm_row_mixed_slave.sql

View File

@ -10,7 +10,7 @@
# - Master is switching explicitly between STATEMENT, ROW, and MIXED # - Master is switching explicitly between STATEMENT, ROW, and MIXED
# binlog format showing when it is possible and when not. # binlog format showing when it is possible and when not.
# - Master switching from MIXED to RBR implicitly listing all use # - Master switching from MIXED to RBR implicitly listing all use
# cases, e.g a query invokes UUID(), thereafter to serve as the # cases, e.g a query invokes SYS_GUID(), thereafter to serve as the
# definition of MIXED binlog format # definition of MIXED binlog format
# - correctness of execution # - correctness of execution
@ -56,18 +56,18 @@ select @@global.binlog_format, @@session.binlog_format;
CREATE TABLE t1 (a varchar(100)); CREATE TABLE t1 (a varchar(100));
prepare stmt1 from 'insert into t1 select concat(UUID(),?)'; prepare stmt1 from 'insert into t1 select concat(SYS_GUID(),?)';
set @string="emergency_1_"; set @string="emergency_1_";
insert into t1 values("work_2_"); insert into t1 values("work_2_");
execute stmt1 using @string; execute stmt1 using @string;
deallocate prepare stmt1; deallocate prepare stmt1;
prepare stmt1 from 'insert into t1 select ?'; prepare stmt1 from 'insert into t1 select ?';
insert into t1 values(concat(UUID(),"work_3_")); insert into t1 values(concat(SYS_GUID(),"work_3_"));
execute stmt1 using @string; execute stmt1 using @string;
deallocate prepare stmt1; deallocate prepare stmt1;
insert into t1 values(concat("for_4_",UUID())); insert into t1 values(concat("for_4_",SYS_GUID()));
insert into t1 select "yesterday_5_"; insert into t1 select "yesterday_5_";
# verify that temp tables prevent a switch to SBR # verify that temp tables prevent a switch to SBR
@ -129,41 +129,41 @@ select @@global.binlog_format, @@session.binlog_format;
set binlog_format=default; set binlog_format=default;
select @@global.binlog_format, @@session.binlog_format; select @@global.binlog_format, @@session.binlog_format;
prepare stmt1 from 'insert into t1 select concat(UUID(),?)'; prepare stmt1 from 'insert into t1 select concat(SYS_GUID(),?)';
set @string="emergency_17_"; set @string="emergency_17_";
insert into t1 values("work_18_"); insert into t1 values("work_18_");
execute stmt1 using @string; execute stmt1 using @string;
deallocate prepare stmt1; deallocate prepare stmt1;
prepare stmt1 from 'insert into t1 select ?'; prepare stmt1 from 'insert into t1 select ?';
insert into t1 values(concat(UUID(),"work_19_")); insert into t1 values(concat(SYS_GUID(),"work_19_"));
execute stmt1 using @string; execute stmt1 using @string;
deallocate prepare stmt1; deallocate prepare stmt1;
insert into t1 values(concat("for_20_",UUID())); insert into t1 values(concat("for_20_",SYS_GUID()));
insert into t1 select "yesterday_21_"; insert into t1 select "yesterday_21_";
prepare stmt1 from 'insert into t1 select ?'; prepare stmt1 from 'insert into t1 select ?';
insert into t1 values(concat(UUID(),"work_22_")); insert into t1 values(concat(SYS_GUID(),"work_22_"));
execute stmt1 using @string; execute stmt1 using @string;
deallocate prepare stmt1; deallocate prepare stmt1;
insert into t1 values(concat("for_23_",UUID())); insert into t1 values(concat("for_23_",SYS_GUID()));
insert into t1 select "yesterday_24_"; insert into t1 select "yesterday_24_";
# Test of CREATE TABLE SELECT # Test of CREATE TABLE SELECT
create table t2 ENGINE=MyISAM select rpad(UUID(),100,' '); create table t2 ENGINE=MyISAM select rpad(SYS_GUID(),100,' ');
create table t3 select 1 union select UUID(); create table t3 select 1 union select SYS_GUID();
--disable_warnings --disable_warnings
SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR
create table t4 select * from t1 where 3 in (select 1 union select 2 union select UUID() union select 3); create table t4 select * from t1 where 3 in (select 1 union select 2 union select SYS_GUID() union select 3);
--enable_warnings --enable_warnings
SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR
create table t5 select * from t1 where 3 in (select 1 union select 2 union select curdate() union select 3); create table t5 select * from t1 where 3 in (select 1 union select 2 union select curdate() union select 3);
# what if UUID() is first: # what if SYS_GUID() is first:
--disable_warnings --disable_warnings
insert ignore into t5 select UUID() from t1 where 3 in (select 1 union select 2 union select 3 union select * from t4); insert ignore into t5 select SYS_GUID() from t1 where 3 in (select 1 union select 2 union select 3 union select * from t4);
--enable_warnings --enable_warnings
# inside a stored procedure # inside a stored procedure
@ -172,14 +172,14 @@ delimiter |;
create procedure foo() create procedure foo()
begin begin
insert into t1 values("work_25_"); insert into t1 values("work_25_");
insert into t1 values(concat("for_26_",UUID())); insert into t1 values(concat("for_26_",SYS_GUID()));
insert into t1 select "yesterday_27_"; insert into t1 select "yesterday_27_";
end| end|
create procedure foo2() create procedure foo2()
begin begin
insert into t1 values(concat("emergency_28_",UUID())); insert into t1 values(concat("emergency_28_",SYS_GUID()));
insert into t1 values("work_29_"); insert into t1 values("work_29_");
insert into t1 values(concat("for_30_",UUID())); insert into t1 values(concat("for_30_",SYS_GUID()));
set session binlog_format=row; # accepted for stored procs set session binlog_format=row; # accepted for stored procs
insert into t1 values("more work_31_"); insert into t1 values("more work_31_");
set session binlog_format=mixed; set session binlog_format=mixed;
@ -199,7 +199,7 @@ delimiter ;|
call foo(); call foo();
call foo2(); call foo2();
call foo4("hello"); call foo4("hello");
call foo4(UUID()); call foo4(SYS_GUID());
call foo4("world"); call foo4("world");
# test that can't SET in a stored function # test that can't SET in a stored function
@ -249,7 +249,7 @@ deallocate prepare stmt1;
delimiter |; delimiter |;
create function foo5() returns bigint unsigned create function foo5() returns bigint unsigned
begin begin
insert into t2 select UUID(); insert into t2 select SYS_GUID();
return 100; return 100;
end| end|
delimiter ;| delimiter ;|
@ -260,7 +260,7 @@ execute stmt1;
execute stmt1; execute stmt1;
deallocate prepare stmt1; deallocate prepare stmt1;
# A simple stored function where UUID() is in the argument # A simple stored function where SYS_GUID() is in the argument
delimiter |; delimiter |;
create function foo6(x varchar(100)) returns bigint unsigned create function foo6(x varchar(100)) returns bigint unsigned
begin begin
@ -269,17 +269,17 @@ begin
end| end|
delimiter ;| delimiter ;|
select foo6("foo6_1_"); select foo6("foo6_1_");
select foo6(concat("foo6_2_",UUID())); select foo6(concat("foo6_2_",SYS_GUID()));
prepare stmt1 from 'select foo6(concat("foo6_3_",UUID()))'; prepare stmt1 from 'select foo6(concat("foo6_3_",SYS_GUID()))';
execute stmt1; execute stmt1;
execute stmt1; execute stmt1;
deallocate prepare stmt1; deallocate prepare stmt1;
# Test of views using UUID() # Test of views using SYS_GUID()
create view v1 as select uuid(); create view v1 as select SYS_GUID();
create table t11 (data varchar(255)); create table t11 (data varchar(255));
insert into t11 select * from v1; insert into t11 select * from v1;
# Test of querying INFORMATION_SCHEMA which parses the view's body, # Test of querying INFORMATION_SCHEMA which parses the view's body,
@ -291,18 +291,18 @@ execute stmt1;
execute stmt1; execute stmt1;
deallocate prepare stmt1; deallocate prepare stmt1;
# Test of triggers with UUID() # Test of triggers with SYS_GUID()
delimiter |; delimiter |;
create trigger t11_bi before insert on t11 for each row create trigger t11_bi before insert on t11 for each row
begin begin
set NEW.data = concat(NEW.data,UUID()); set NEW.data = concat(NEW.data,SYS_GUID());
end| end|
delimiter ;| delimiter ;|
insert into t11 values("try_560_"); insert into t11 values("try_560_");
# Test that INSERT DELAYED works in mixed mode (BUG#20649) # Test that INSERT DELAYED works in mixed mode (BUG#20649)
insert delayed into t2 values("delay_1_"); insert delayed into t2 values("delay_1_");
insert delayed into t2 values(concat("delay_2_",UUID())); insert delayed into t2 values(concat("delay_2_",SYS_GUID()));
insert delayed into t2 values("delay_6_"); insert delayed into t2 values("delay_6_");
# Test for BUG#20633 (INSERT DELAYED RAND()/user_variable does not # Test for BUG#20633 (INSERT DELAYED RAND()/user_variable does not
@ -482,7 +482,7 @@ sync_slave_with_master;
# Test for BUG#20499 "mixed mode with temporary table breaks binlog" # Test for BUG#20499 "mixed mode with temporary table breaks binlog"
# Slave used to have only 2 rows instead of 3. # Slave used to have only 2 rows instead of 3.
connection master; connection master;
CREATE TEMPORARY TABLE t15 SELECT UUID(); CREATE TEMPORARY TABLE t15 SELECT SYS_GUID();
create table t16 like t15; create table t16 like t15;
INSERT INTO t16 SELECT * FROM t15; INSERT INTO t16 SELECT * FROM t15;
# we'll verify that this one is done RBB # we'll verify that this one is done RBB
@ -546,7 +546,7 @@ DROP TABLE IF EXISTS t12;
SET SESSION BINLOG_FORMAT=MIXED; SET SESSION BINLOG_FORMAT=MIXED;
CREATE TABLE t12 (data LONG); CREATE TABLE t12 (data LONG);
LOCK TABLES t12 WRITE; LOCK TABLES t12 WRITE;
INSERT INTO t12 VALUES(UUID()); INSERT INTO t12 VALUES(SYS_GUID());
UNLOCK TABLES; UNLOCK TABLES;
sync_slave_with_master; sync_slave_with_master;
@ -587,7 +587,7 @@ INSERT INTO t13 VALUES (my_current_user());
sync_slave_with_master; sync_slave_with_master;
# as we're using UUID we don't SELECT but use "diff" like in rpl_row_UUID # as we're using SYS_GUID we don't SELECT but use "diff" like in rpl_row_UUID
--exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info mysqltest1 > $MYSQLTEST_VARDIR/tmp/rpl_switch_stm_row_mixed_master.sql --exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info mysqltest1 > $MYSQLTEST_VARDIR/tmp/rpl_switch_stm_row_mixed_master.sql
--exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info mysqltest1 > $MYSQLTEST_VARDIR/tmp/rpl_switch_stm_row_mixed_slave.sql --exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info mysqltest1 > $MYSQLTEST_VARDIR/tmp/rpl_switch_stm_row_mixed_slave.sql

View File

@ -33,7 +33,7 @@ INSERT INTO t2 VALUES(1, 't2, text 1');
******************** DELETE ******************** ******************** DELETE ********************
DELETE FROM t1 WHERE a = 1; DELETE FROM t1 WHERE a = 1;
DELETE FROM t2 WHERE b <> UUID(); DELETE FROM t2 WHERE b <> SYS_GUID();
SELECT COUNT(*) FROM t1; SELECT COUNT(*) FROM t1;
COUNT(*) COUNT(*)
1 1
@ -64,7 +64,7 @@ DELETE FROM t2;
******************** INSERT ******************** ******************** INSERT ********************
INSERT INTO t1 VALUES(1, 't1, text 1'); INSERT INTO t1 VALUES(1, 't1, text 1');
INSERT INTO t1 VALUES(2, UUID()); INSERT INTO t1 VALUES(2, SYS_GUID());
INSERT INTO t2 SELECT * FROM t1; INSERT INTO t2 SELECT * FROM t1;
INSERT INTO t2 VALUES (1, 't1, text 1') ON DUPLICATE KEY UPDATE b = 't2, text 1'; INSERT INTO t2 VALUES (1, 't1, text 1') ON DUPLICATE KEY UPDATE b = 't2, text 1';
DELETE FROM t1 WHERE a = 2; DELETE FROM t1 WHERE a = 2;
@ -143,7 +143,7 @@ INSERT INTO t1 VALUES(1, 't1, text 1');
INSERT INTO t1 VALUES(2, 't1, text 2'); INSERT INTO t1 VALUES(2, 't1, text 2');
INSERT INTO t1 VALUES(3, 't1, text 3'); INSERT INTO t1 VALUES(3, 't1, text 3');
REPLACE INTO t1 VALUES(1, 't1, text 11'); REPLACE INTO t1 VALUES(1, 't1, text 11');
REPLACE INTO t1 VALUES(2, UUID()); REPLACE INTO t1 VALUES(2, SYS_GUID());
REPLACE INTO t1 SET a=3, b='t1, text 33'; REPLACE INTO t1 SET a=3, b='t1, text 33';
DELETE FROM t1 WHERE a = 2; DELETE FROM t1 WHERE a = 2;
SELECT COUNT(*) FROM t1; SELECT COUNT(*) FROM t1;
@ -178,7 +178,7 @@ DELETE FROM t2;
******************** SELECT ******************** ******************** SELECT ********************
INSERT INTO t1 VALUES(1, 't1, text 1'); INSERT INTO t1 VALUES(1, 't1, text 1');
SELECT * FROM t1 WHERE b <> UUID() ORDER BY a; SELECT * FROM t1 WHERE b <> SYS_GUID() ORDER BY a;
a b a b
1 t1, text 1 1 t1, text 1
DELETE FROM t1; DELETE FROM t1;
@ -203,7 +203,7 @@ DELETE FROM t2;
******************** UNION ******************** ******************** UNION ********************
INSERT INTO t1 VALUES(1, 't1, text 1'); INSERT INTO t1 VALUES(1, 't1, text 1');
INSERT INTO t2 VALUES(1, 't2, text 1'); INSERT INTO t2 VALUES(1, 't2, text 1');
SELECT * FROM t1 UNION SELECT * FROM t2 WHERE t2.b <> UUID(); SELECT * FROM t1 UNION SELECT * FROM t2 WHERE t2.b <> SYS_GUID();
a b a b
1 t1, text 1 1 t1, text 1
1 t2, text 1 1 t2, text 1
@ -430,7 +430,7 @@ START TRANSACTION;
INSERT INTO t1 VALUES (5, 'before savepoint s2'); INSERT INTO t1 VALUES (5, 'before savepoint s2');
SAVEPOINT s2; SAVEPOINT s2;
INSERT INTO t1 VALUES (6, 'after savepoint s2'); INSERT INTO t1 VALUES (6, 'after savepoint s2');
INSERT INTO t1 VALUES (7, CONCAT('with UUID() ',UUID())); INSERT INTO t1 VALUES (7, CONCAT('with SYS_GUID() ',SYS_GUID()));
RELEASE SAVEPOINT s2; RELEASE SAVEPOINT s2;
COMMIT; COMMIT;
DELETE FROM t1 WHERE a = 7; DELETE FROM t1 WHERE a = 7;
@ -598,7 +598,7 @@ UPDATE t1 SET b = 'test' WHERE a = 201;
END| END|
CREATE PROCEDURE p2 () CREATE PROCEDURE p2 ()
BEGIN BEGIN
UPDATE t1 SET b = UUID() WHERE a = 202; UPDATE t1 SET b = SYS_GUID() WHERE a = 202;
END| END|
INSERT INTO t1 VALUES(201, 'test 201'); INSERT INTO t1 VALUES(201, 'test 201');
CALL p1(); CALL p1();
@ -790,7 +790,7 @@ DELETE FROM t2;
INSERT INTO t1 VALUES(1, 'test1'); INSERT INTO t1 VALUES(1, 'test1');
INSERT INTO t1 VALUES(2, 'test2'); INSERT INTO t1 VALUES(2, 'test2');
CREATE VIEW v1 AS SELECT * FROM t1 WHERE a = 1; CREATE VIEW v1 AS SELECT * FROM t1 WHERE a = 1;
CREATE VIEW v2 AS SELECT * FROM t1 WHERE b <> UUID(); CREATE VIEW v2 AS SELECT * FROM t1 WHERE b <> SYS_GUID();
SHOW CREATE VIEW v1; SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a`,`t1`.`b` AS `b` from `t1` where `t1`.`a` = 1 latin1 latin1_swedish_ci v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a`,`t1`.`b` AS `b` from `t1` where `t1`.`a` = 1 latin1 latin1_swedish_ci
@ -850,7 +850,7 @@ master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Query # # use `test_rpl`; DELETE FROM t1 WHERE a = 1 master-bin.000001 # Query # # use `test_rpl`; DELETE FROM t1 WHERE a = 1
master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Annotate_rows # # DELETE FROM t2 WHERE b <> UUID() master-bin.000001 # Annotate_rows # # DELETE FROM t2 WHERE b <> SYS_GUID()
master-bin.000001 # Table_map # # table_id: # (test_rpl.t2) master-bin.000001 # Table_map # # table_id: # (test_rpl.t2)
master-bin.000001 # Delete_rows_v1 # # table_id: # flags: STMT_END_F master-bin.000001 # Delete_rows_v1 # # table_id: # flags: STMT_END_F
master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Xid # # COMMIT /* XID */
@ -864,7 +864,7 @@ master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Query # # use `test_rpl`; INSERT INTO t1 VALUES(1, 't1, text 1') master-bin.000001 # Query # # use `test_rpl`; INSERT INTO t1 VALUES(1, 't1, text 1')
master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Annotate_rows # # INSERT INTO t1 VALUES(2, UUID()) master-bin.000001 # Annotate_rows # # INSERT INTO t1 VALUES(2, SYS_GUID())
master-bin.000001 # Table_map # # table_id: # (test_rpl.t1) master-bin.000001 # Table_map # # table_id: # (test_rpl.t1)
master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Xid # # COMMIT /* XID */
@ -912,7 +912,7 @@ master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Query # # use `test_rpl`; REPLACE INTO t1 VALUES(1, 't1, text 11') master-bin.000001 # Query # # use `test_rpl`; REPLACE INTO t1 VALUES(1, 't1, text 11')
master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Annotate_rows # # REPLACE INTO t1 VALUES(2, UUID()) master-bin.000001 # Annotate_rows # # REPLACE INTO t1 VALUES(2, SYS_GUID())
master-bin.000001 # Table_map # # table_id: # (test_rpl.t1) master-bin.000001 # Table_map # # table_id: # (test_rpl.t1)
master-bin.000001 # Update_rows_v1 # # table_id: # flags: STMT_END_F master-bin.000001 # Update_rows_v1 # # table_id: # flags: STMT_END_F
master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Xid # # COMMIT /* XID */
@ -1007,7 +1007,7 @@ master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Query # # use `test_rpl`; INSERT INTO t1 VALUES (5, 'before savepoint s2') master-bin.000001 # Query # # use `test_rpl`; INSERT INTO t1 VALUES (5, 'before savepoint s2')
master-bin.000001 # Query # # SAVEPOINT `s2` master-bin.000001 # Query # # SAVEPOINT `s2`
master-bin.000001 # Query # # use `test_rpl`; INSERT INTO t1 VALUES (6, 'after savepoint s2') master-bin.000001 # Query # # use `test_rpl`; INSERT INTO t1 VALUES (6, 'after savepoint s2')
master-bin.000001 # Annotate_rows # # INSERT INTO t1 VALUES (7, CONCAT('with UUID() ',UUID())) master-bin.000001 # Annotate_rows # # INSERT INTO t1 VALUES (7, CONCAT('with SYS_GUID() ',SYS_GUID()))
master-bin.000001 # Table_map # # table_id: # (test_rpl.t1) master-bin.000001 # Table_map # # table_id: # (test_rpl.t1)
master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Xid # # COMMIT /* XID */
@ -1049,7 +1049,7 @@ END
master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Gtid # # GTID #-#-#
master-bin.000001 # Query # # use `test_rpl`; CREATE DEFINER=`root`@`localhost` PROCEDURE `p2`() master-bin.000001 # Query # # use `test_rpl`; CREATE DEFINER=`root`@`localhost` PROCEDURE `p2`()
BEGIN BEGIN
UPDATE t1 SET b = UUID() WHERE a = 202; UPDATE t1 SET b = SYS_GUID() WHERE a = 202;
END END
master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Query # # use `test_rpl`; INSERT INTO t1 VALUES(201, 'test 201') master-bin.000001 # Query # # use `test_rpl`; INSERT INTO t1 VALUES(201, 'test 201')
@ -1061,7 +1061,7 @@ master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Query # # use `test_rpl`; INSERT INTO t1 VALUES(202, 'test 202') master-bin.000001 # Query # # use `test_rpl`; INSERT INTO t1 VALUES(202, 'test 202')
master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Annotate_rows # # UPDATE t1 SET b = UUID() WHERE a = 202 master-bin.000001 # Annotate_rows # # UPDATE t1 SET b = SYS_GUID() WHERE a = 202
master-bin.000001 # Table_map # # table_id: # (test_rpl.t1) master-bin.000001 # Table_map # # table_id: # (test_rpl.t1)
master-bin.000001 # Update_rows_v1 # # table_id: # flags: STMT_END_F master-bin.000001 # Update_rows_v1 # # table_id: # flags: STMT_END_F
master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Xid # # COMMIT /* XID */
@ -1124,7 +1124,7 @@ master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Gtid # # GTID #-#-#
master-bin.000001 # Query # # use `test_rpl`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS SELECT * FROM t1 WHERE a = 1 master-bin.000001 # Query # # use `test_rpl`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS SELECT * FROM t1 WHERE a = 1
master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Gtid # # GTID #-#-#
master-bin.000001 # Query # # use `test_rpl`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS SELECT * FROM t1 WHERE b <> UUID() master-bin.000001 # Query # # use `test_rpl`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS SELECT * FROM t1 WHERE b <> SYS_GUID()
master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Gtid # # GTID #-#-#
master-bin.000001 # Query # # use `test_rpl`; ALTER ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS SELECT * FROM t1 WHERE a = 2 master-bin.000001 # Query # # use `test_rpl`; ALTER ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS SELECT * FROM t1 WHERE a = 2
master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Gtid # # GTID #-#-#

View File

@ -41,16 +41,16 @@ select @@global.binlog_format, @@session.binlog_format;
@@global.binlog_format @@session.binlog_format @@global.binlog_format @@session.binlog_format
ROW ROW ROW ROW
CREATE TABLE t1 (a varchar(100)); CREATE TABLE t1 (a varchar(100));
prepare stmt1 from 'insert into t1 select concat(UUID(),?)'; prepare stmt1 from 'insert into t1 select concat(SYS_GUID(),?)';
set @string="emergency_1_"; set @string="emergency_1_";
insert into t1 values("work_2_"); insert into t1 values("work_2_");
execute stmt1 using @string; execute stmt1 using @string;
deallocate prepare stmt1; deallocate prepare stmt1;
prepare stmt1 from 'insert into t1 select ?'; prepare stmt1 from 'insert into t1 select ?';
insert into t1 values(concat(UUID(),"work_3_")); insert into t1 values(concat(SYS_GUID(),"work_3_"));
execute stmt1 using @string; execute stmt1 using @string;
deallocate prepare stmt1; deallocate prepare stmt1;
insert into t1 values(concat("for_4_",UUID())); insert into t1 values(concat("for_4_",SYS_GUID()));
insert into t1 select "yesterday_5_"; insert into t1 select "yesterday_5_";
create temporary table tmp(a char(100)); create temporary table tmp(a char(100));
insert into tmp values("see_6_"); insert into tmp values("see_6_");
@ -116,43 +116,43 @@ set binlog_format=default;
select @@global.binlog_format, @@session.binlog_format; select @@global.binlog_format, @@session.binlog_format;
@@global.binlog_format @@session.binlog_format @@global.binlog_format @@session.binlog_format
MIXED MIXED MIXED MIXED
prepare stmt1 from 'insert into t1 select concat(UUID(),?)'; prepare stmt1 from 'insert into t1 select concat(SYS_GUID(),?)';
set @string="emergency_17_"; set @string="emergency_17_";
insert into t1 values("work_18_"); insert into t1 values("work_18_");
execute stmt1 using @string; execute stmt1 using @string;
deallocate prepare stmt1; deallocate prepare stmt1;
prepare stmt1 from 'insert into t1 select ?'; prepare stmt1 from 'insert into t1 select ?';
insert into t1 values(concat(UUID(),"work_19_")); insert into t1 values(concat(SYS_GUID(),"work_19_"));
execute stmt1 using @string; execute stmt1 using @string;
deallocate prepare stmt1; deallocate prepare stmt1;
insert into t1 values(concat("for_20_",UUID())); insert into t1 values(concat("for_20_",SYS_GUID()));
insert into t1 select "yesterday_21_"; insert into t1 select "yesterday_21_";
prepare stmt1 from 'insert into t1 select ?'; prepare stmt1 from 'insert into t1 select ?';
insert into t1 values(concat(UUID(),"work_22_")); insert into t1 values(concat(SYS_GUID(),"work_22_"));
execute stmt1 using @string; execute stmt1 using @string;
deallocate prepare stmt1; deallocate prepare stmt1;
insert into t1 values(concat("for_23_",UUID())); insert into t1 values(concat("for_23_",SYS_GUID()));
insert into t1 select "yesterday_24_"; insert into t1 select "yesterday_24_";
create table t2 ENGINE=MyISAM select rpad(UUID(),100,' '); create table t2 ENGINE=MyISAM select rpad(SYS_GUID(),100,' ');
create table t3 select 1 union select UUID(); create table t3 select 1 union select SYS_GUID();
SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR
create table t4 select * from t1 where 3 in (select 1 union select 2 union select UUID() union select 3); create table t4 select * from t1 where 3 in (select 1 union select 2 union select SYS_GUID() union select 3);
SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR
create table t5 select * from t1 where 3 in (select 1 union select 2 union select curdate() union select 3); create table t5 select * from t1 where 3 in (select 1 union select 2 union select curdate() union select 3);
Warnings: Warnings:
Warning 1292 Truncated incorrect datetime value: '3' Warning 1292 Truncated incorrect datetime value: '3'
insert ignore into t5 select UUID() from t1 where 3 in (select 1 union select 2 union select 3 union select * from t4); insert ignore into t5 select SYS_GUID() from t1 where 3 in (select 1 union select 2 union select 3 union select * from t4);
create procedure foo() create procedure foo()
begin begin
insert into t1 values("work_25_"); insert into t1 values("work_25_");
insert into t1 values(concat("for_26_",UUID())); insert into t1 values(concat("for_26_",SYS_GUID()));
insert into t1 select "yesterday_27_"; insert into t1 select "yesterday_27_";
end| end|
create procedure foo2() create procedure foo2()
begin begin
insert into t1 values(concat("emergency_28_",UUID())); insert into t1 values(concat("emergency_28_",SYS_GUID()));
insert into t1 values("work_29_"); insert into t1 values("work_29_");
insert into t1 values(concat("for_30_",UUID())); insert into t1 values(concat("for_30_",SYS_GUID()));
set session binlog_format=row; # accepted for stored procs set session binlog_format=row; # accepted for stored procs
insert into t1 values("more work_31_"); insert into t1 values("more work_31_");
set session binlog_format=mixed; set session binlog_format=mixed;
@ -171,7 +171,7 @@ end|
call foo(); call foo();
call foo2(); call foo2();
call foo4("hello"); call foo4("hello");
call foo4(UUID()); call foo4(SYS_GUID());
call foo4("world"); call foo4("world");
select foo3(); select foo3();
ERROR HY000: Cannot change the binary logging format inside a stored function or trigger ERROR HY000: Cannot change the binary logging format inside a stored function or trigger
@ -207,7 +207,7 @@ foo4()
deallocate prepare stmt1; deallocate prepare stmt1;
create function foo5() returns bigint unsigned create function foo5() returns bigint unsigned
begin begin
insert into t2 select UUID(); insert into t2 select SYS_GUID();
return 100; return 100;
end| end|
select foo5(); select foo5();
@ -229,18 +229,18 @@ end|
select foo6("foo6_1_"); select foo6("foo6_1_");
foo6("foo6_1_") foo6("foo6_1_")
100 100
select foo6(concat("foo6_2_",UUID())); select foo6(concat("foo6_2_",SYS_GUID()));
foo6(concat("foo6_2_",UUID())) foo6(concat("foo6_2_",SYS_GUID()))
100 100
prepare stmt1 from 'select foo6(concat("foo6_3_",UUID()))'; prepare stmt1 from 'select foo6(concat("foo6_3_",SYS_GUID()))';
execute stmt1; execute stmt1;
foo6(concat("foo6_3_",UUID())) foo6(concat("foo6_3_",SYS_GUID()))
100 100
execute stmt1; execute stmt1;
foo6(concat("foo6_3_",UUID())) foo6(concat("foo6_3_",SYS_GUID()))
100 100
deallocate prepare stmt1; deallocate prepare stmt1;
create view v1 as select uuid(); create view v1 as select SYS_GUID();
create table t11 (data varchar(255)); create table t11 (data varchar(255));
insert into t11 select * from v1; insert into t11 select * from v1;
insert into t11 select TABLE_NAME from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='mysqltest1' and TABLE_NAME IN ('v1','t11'); 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;
deallocate prepare stmt1; deallocate prepare stmt1;
create trigger t11_bi before insert on t11 for each row create trigger t11_bi before insert on t11 for each row
begin begin
set NEW.data = concat(NEW.data,UUID()); set NEW.data = concat(NEW.data,SYS_GUID());
end| end|
insert into t11 values("try_560_"); insert into t11 values("try_560_");
insert delayed into t2 values("delay_1_"); insert delayed into t2 values("delay_1_");
insert delayed into t2 values(concat("delay_2_",UUID())); insert delayed into t2 values(concat("delay_2_",SYS_GUID()));
insert delayed into t2 values("delay_6_"); insert delayed into t2 values("delay_6_");
insert delayed into t2 values(rand()); insert delayed into t2 values(rand());
set @a=2.345; set @a=2.345;
@ -356,7 +356,7 @@ alter table t1 modify a int, drop primary key;
insert into t1 values(null,"try_57_"); insert into t1 values(null,"try_57_");
connection slave; connection slave;
connection master; connection master;
CREATE TEMPORARY TABLE t15 SELECT UUID(); CREATE TEMPORARY TABLE t15 SELECT SYS_GUID();
create table t16 like t15; create table t16 like t15;
INSERT INTO t16 SELECT * FROM t15; INSERT INTO t16 SELECT * FROM t15;
insert into t16 values("try_65_"); insert into t16 values("try_65_");
@ -427,7 +427,7 @@ DROP TABLE IF EXISTS t12;
SET SESSION BINLOG_FORMAT=MIXED; SET SESSION BINLOG_FORMAT=MIXED;
CREATE TABLE t12 (data LONG); CREATE TABLE t12 (data LONG);
LOCK TABLES t12 WRITE; LOCK TABLES t12 WRITE;
INSERT INTO t12 VALUES(UUID()); INSERT INTO t12 VALUES(SYS_GUID());
UNLOCK TABLES; UNLOCK TABLES;
connection slave; connection slave;
connection master; connection master;

View File

@ -4,7 +4,7 @@ include/master-slave.inc
connection master; connection master;
CREATE TABLE t1 (a CHAR(48)); CREATE TABLE t1 (a CHAR(48));
CREATE TEMPORARY TABLE t1_tmp1(a INT); CREATE TEMPORARY TABLE t1_tmp1(a INT);
INSERT INTO t1 VALUES (UUID()); INSERT INTO t1 VALUES (SYS_GUID());
connection slave; connection slave;
==== Verify results on slave ==== ==== Verify results on slave ====
SHOW STATUS LIKE "Slave_open_temp_tables"; SHOW STATUS LIKE "Slave_open_temp_tables";
@ -119,12 +119,12 @@ master-bin.000001 # Query # # COMMIT
BEGIN; BEGIN;
DROP TEMPORARY TABLE t1; DROP TEMPORARY TABLE t1;
# The rows event will binlogged after 'INSERT INTO t1 VALUES(1)' # The rows event will binlogged after 'INSERT INTO t1 VALUES(1)'
INSERT IGNORE INTO t1 VALUES(uuid()+0); INSERT IGNORE INTO t1 VALUES(SYS_GUID()+0);
COMMIT; COMMIT;
include/show_binlog_events.inc include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Annotate_rows # # INSERT IGNORE INTO t1 VALUES(uuid()+0) master-bin.000001 # Annotate_rows # # INSERT IGNORE INTO t1 VALUES(SYS_GUID()+0)
master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Table_map # # table_id: # (test.t1)
master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # COMMIT

View File

@ -4,7 +4,7 @@
# This test case will test the condition of the bug#40013. # This test case will test the condition of the bug#40013.
# The test step is: # The test step is:
# 1: create temp table on connection 'master'; # 1: create temp table on connection 'master';
# 2: switch to ROW format using 'INSERT INTO t1 VALUES (UUID());' # 2: switch to ROW format using 'INSERT INTO t1 VALUES (SYS_GUID());'
# 3: disconnect 'master' and connect to a new connection 'master1'; # 3: disconnect 'master' and connect to a new connection 'master1';
# 4: sync to slave and check the number of temp tables on slave. # 4: sync to slave and check the number of temp tables on slave.
# #
@ -19,7 +19,7 @@ source include/master-slave.inc;
CREATE TABLE t1 (a CHAR(48)); CREATE TABLE t1 (a CHAR(48));
CREATE TEMPORARY TABLE t1_tmp1(a INT); CREATE TEMPORARY TABLE t1_tmp1(a INT);
INSERT INTO t1 VALUES (UUID()); INSERT INTO t1 VALUES (SYS_GUID());
sync_slave_with_master; sync_slave_with_master;
@ -187,7 +187,7 @@ DROP TEMPORARY TABLE t1;
--echo # The rows event will binlogged after 'INSERT INTO t1 VALUES(1)' --echo # The rows event will binlogged after 'INSERT INTO t1 VALUES(1)'
--disable_warnings --disable_warnings
INSERT IGNORE INTO t1 VALUES(uuid()+0); INSERT IGNORE INTO t1 VALUES(SYS_GUID()+0);
--enable_warnings --enable_warnings
COMMIT; COMMIT;

View File

@ -88,7 +88,7 @@ CREATE TEMPORARY TABLE t1 SELECT UUID();
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TEMPORARY TABLE `t1` ( t1 CREATE TEMPORARY TABLE `t1` (
`UUID()` varchar(36) DEFAULT NULL `UUID()` uuid DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
CREATE TABLE t2 (a INT PRIMARY KEY, b TEXT, c INT GENERATED ALWAYS AS(b)); CREATE TABLE t2 (a INT PRIMARY KEY, b TEXT, c INT GENERATED ALWAYS AS(b));
INSERT INTO t2 (a,b) VALUES (1,1); INSERT INTO t2 (a,b) VALUES (1,1);

View File

@ -18,26 +18,29 @@
#include "item_uuidfunc.h" #include "item_uuidfunc.h"
#include "sql_type_uuid.h" #include "sql_type_uuid.h"
class UUID_generated : public UUIDBundle::Fbt String *Item_func_sys_guid::val_str(String *str)
{
public:
UUID_generated() { my_uuid((uchar *) m_buffer); }
bool to_string(String *to, bool with_separators) const
{
if (to->alloc(max_char_length() + 1))
return true;
to->set_charset(system_charset_info);
to->length(MY_UUID_BARE_STRING_LENGTH + with_separators*MY_UUID_SEPARATORS);
my_uuid2str((const uchar *) m_buffer, (char *) to->ptr(), with_separators);
return false;
}
};
String *Item_func_uuid::val_str(String *str)
{ {
DBUG_ASSERT(fixed()); DBUG_ASSERT(fixed());
if (!UUID_generated().to_string(str, with_separators)) str->alloc(uuid_len()+1);
return str; str->length(uuid_len());
str->set("", 0, collation.collation); str->set_charset(collation.collation);
uchar buf[MY_UUID_SIZE];
my_uuid(buf);
my_uuid2str(buf, const_cast<char*>(str->ptr()), with_dashes);
return str; return str;
} }
const Type_handler *Item_func_uuid::type_handler() const
{
return UUIDBundle::type_handler_fbt();
}
bool Item_func_uuid::val_native(THD *, Native *to)
{
DBUG_ASSERT(fixed());
to->alloc(MY_UUID_SIZE);
to->length(MY_UUID_SIZE);
my_uuid((uchar*)to->ptr());
return 0;
}

View File

@ -19,33 +19,48 @@
#include "item.h" #include "item.h"
class Item_func_uuid: public Item_str_func class Item_func_sys_guid: public Item_str_func
{ {
bool with_separators; protected:
bool with_dashes;
size_t uuid_len() const
{ return MY_UUID_BARE_STRING_LENGTH + with_dashes*MY_UUID_SEPARATORS; }
public: public:
Item_func_uuid(THD *thd, bool with_separators_arg): Item_func_sys_guid(THD *thd): Item_str_func(thd), with_dashes(false) {}
Item_str_func(thd), with_separators(with_separators_arg) {}
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
collation.set(DTCollation_numeric()); collation.set(DTCollation_numeric());
fix_char_length(with_separators ? MY_UUID_STRING_LENGTH fix_char_length(uuid_len());
: MY_UUID_BARE_STRING_LENGTH);
return FALSE; return FALSE;
} }
bool const_item() const { return false; } bool const_item() const { return false; }
table_map used_tables() const { return RAND_TABLE_BIT; } table_map used_tables() const { return RAND_TABLE_BIT; }
LEX_CSTRING func_name_cstring() const override LEX_CSTRING func_name_cstring() const override
{ {
static LEX_CSTRING name1= {STRING_WITH_LEN("uuid") }; static LEX_CSTRING name= {STRING_WITH_LEN("sys_guid") };
static LEX_CSTRING name2= {STRING_WITH_LEN("sys_guid") }; return name;
return with_separators ? name1 : name2;
} }
String *val_str(String *); String *val_str(String *) override;
bool check_vcol_func_processor(void *arg) bool check_vcol_func_processor(void *arg)
{ {
return mark_unsupported_function(func_name(), "()", arg, VCOL_NON_DETERMINISTIC); return mark_unsupported_function(func_name(), "()", arg, VCOL_NON_DETERMINISTIC);
} }
Item *get_copy(THD *thd) Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_sys_guid>(thd, this); }
};
class Item_func_uuid: public Item_func_sys_guid
{
public:
Item_func_uuid(THD *thd): Item_func_sys_guid(thd) { with_dashes= true; }
const Type_handler *type_handler() const override;
LEX_CSTRING func_name_cstring() const override
{
static LEX_CSTRING name= {STRING_WITH_LEN("uuid") };
return name;
}
bool val_native(THD *thd, Native *to) override;
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_uuid>(thd, this); } { return get_item_copy<Item_func_uuid>(thd, this); }
}; };

View File

@ -37,7 +37,7 @@ public:
DBUG_ENTER("Create_func_uuid::create"); DBUG_ENTER("Create_func_uuid::create");
thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION); thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
thd->lex->safe_to_cache_query= 0; thd->lex->safe_to_cache_query= 0;
DBUG_RETURN(new (thd->mem_root) Item_func_uuid(thd, true)); DBUG_RETURN(new (thd->mem_root) Item_func_uuid(thd));
} }
static Create_func_uuid s_singleton; static Create_func_uuid s_singleton;
@ -55,7 +55,7 @@ public:
DBUG_ENTER("Create_func_sys_guid::create"); DBUG_ENTER("Create_func_sys_guid::create");
thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION); thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
thd->lex->safe_to_cache_query= 0; thd->lex->safe_to_cache_query= 0;
DBUG_RETURN(new (thd->mem_root) Item_func_uuid(thd, false)); DBUG_RETURN(new (thd->mem_root) Item_func_sys_guid(thd));
} }
static Create_func_sys_guid s_singleton; static Create_func_sys_guid s_singleton;