Commit 8ba5af7e authored by Alexander Barkov's avatar Alexander Barkov

MDEV-20890 Illegal mix of collations with UUID()

parent 88cdfc5c
...@@ -807,12 +807,12 @@ create table t1 as select concat(uuid()) as c1; ...@@ -807,12 +807,12 @@ create table t1 as select concat(uuid()) as c1;
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`c1` varchar(36) CHARACTER SET utf8 DEFAULT NULL `c1` varbinary(36) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1; drop table t1;
select coercibility(uuid()), coercibility(cast('a' as char character set latin1)); select coercibility(uuid()), coercibility(cast('a' as char character set latin1));
coercibility(uuid()) coercibility(cast('a' as char character set latin1)) coercibility(uuid()) coercibility(cast('a' as char character set latin1))
4 2 5 2
select charset(concat(uuid(), cast('a' as char character set latin1))); select charset(concat(uuid(), cast('a' as char character set latin1)));
charset(concat(uuid(), cast('a' as char character set latin1))) charset(concat(uuid(), cast('a' as char character set latin1)))
latin1 latin1
......
...@@ -1216,12 +1216,12 @@ create table t1 as select concat(uuid()) as c1; ...@@ -1216,12 +1216,12 @@ create table t1 as select concat(uuid()) as c1;
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`c1` varchar(36) CHARACTER SET utf8 DEFAULT NULL `c1` varchar(36) CHARACTER SET cp1251 DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1; drop table t1;
select coercibility(uuid()), coercibility(cast('a' as char character set latin1)); select coercibility(uuid()), coercibility(cast('a' as char character set latin1));
coercibility(uuid()) coercibility(cast('a' as char character set latin1)) coercibility(uuid()) coercibility(cast('a' as char character set latin1))
4 2 5 2
select charset(concat(uuid(), cast('a' as char character set latin1))); select charset(concat(uuid(), cast('a' as char character set latin1)));
charset(concat(uuid(), cast('a' as char character set latin1))) charset(concat(uuid(), cast('a' as char character set latin1)))
latin1 latin1
......
...@@ -1525,12 +1525,12 @@ create table t1 as select concat(uuid()) as c1; ...@@ -1525,12 +1525,12 @@ create table t1 as select concat(uuid()) as c1;
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`c1` varchar(36) CHARACTER SET utf8 DEFAULT NULL `c1` varchar(36) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1; drop table t1;
select coercibility(uuid()), coercibility(cast('a' as char character set latin1)); select coercibility(uuid()), coercibility(cast('a' as char character set latin1));
coercibility(uuid()) coercibility(cast('a' as char character set latin1)) coercibility(uuid()) coercibility(cast('a' as char character set latin1))
4 2 5 2
select charset(concat(uuid(), cast('a' as char character set latin1))); select charset(concat(uuid(), cast('a' as char character set latin1)));
charset(concat(uuid(), cast('a' as char character set latin1))) charset(concat(uuid(), cast('a' as char character set latin1)))
latin1 latin1
......
...@@ -2409,12 +2409,12 @@ create table t1 as select concat(uuid()) as c1; ...@@ -2409,12 +2409,12 @@ create table t1 as select concat(uuid()) as c1;
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`c1` varchar(36) CHARACTER SET utf8 DEFAULT NULL `c1` varchar(36) CHARACTER SET ucs2 DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1; drop table t1;
select coercibility(uuid()), coercibility(cast('a' as char character set latin1)); select coercibility(uuid()), coercibility(cast('a' as char character set latin1));
coercibility(uuid()) coercibility(cast('a' as char character set latin1)) coercibility(uuid()) coercibility(cast('a' as char character set latin1))
4 2 5 2
select charset(concat(uuid(), cast('a' as char character set latin1))); select charset(concat(uuid(), cast('a' as char character set latin1)));
charset(concat(uuid(), cast('a' as char character set latin1))) charset(concat(uuid(), cast('a' as char character set latin1)))
latin1 latin1
......
...@@ -3281,7 +3281,7 @@ t1 CREATE TABLE `t1` ( ...@@ -3281,7 +3281,7 @@ t1 CREATE TABLE `t1` (
drop table t1; drop table t1;
select coercibility(uuid()), coercibility(cast('a' as char character set latin1)); select coercibility(uuid()), coercibility(cast('a' as char character set latin1));
coercibility(uuid()) coercibility(cast('a' as char character set latin1)) coercibility(uuid()) coercibility(cast('a' as char character set latin1))
4 2 5 2
select charset(concat(uuid(), cast('a' as char character set latin1))); select charset(concat(uuid(), cast('a' as char character set latin1)));
charset(concat(uuid(), cast('a' as char character set latin1))) charset(concat(uuid(), cast('a' as char character set latin1)))
latin1 latin1
...@@ -11341,5 +11341,12 @@ t1 CREATE TABLE `t1` ( ...@@ -11341,5 +11341,12 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1; DROP TABLE t1;
# #
# MDEV-20890 Illegal mix of collations with UUID()
#
SET NAMES utf8 COLLATE utf8_unicode_ci;
SELECT uuid()>'';
uuid()>''
1
#
# End of 10.5 tests # End of 10.5 tests
# #
...@@ -2276,6 +2276,13 @@ CREATE OR REPLACE TABLE t1 AS SELECT CAST(1 AS BINARY), CAST(@a AS BINARY), CAST ...@@ -2276,6 +2276,13 @@ CREATE OR REPLACE TABLE t1 AS SELECT CAST(1 AS BINARY), CAST(@a AS BINARY), CAST
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # MDEV-20890 Illegal mix of collations with UUID()
--echo #
SET NAMES utf8 COLLATE utf8_unicode_ci;
SELECT uuid()>'';
--echo # --echo #
--echo # End of 10.5 tests --echo # End of 10.5 tests
--echo # --echo #
...@@ -22,7 +22,7 @@ hex(inet_aton('127.1.1')) ...@@ -22,7 +22,7 @@ hex(inet_aton('127.1.1'))
7F010001 7F010001
select length(uuid()), charset(uuid()), length(unhex(replace(uuid(),_utf8'-',_utf8''))); select length(uuid()), charset(uuid()), length(unhex(replace(uuid(),_utf8'-',_utf8'')));
length(uuid()) charset(uuid()) length(unhex(replace(uuid(),_utf8'-',_utf8''))) length(uuid()) charset(uuid()) length(unhex(replace(uuid(),_utf8'-',_utf8'')))
36 utf8 16 36 latin1 16
set @a= uuid_short(); set @a= uuid_short();
set @b= uuid_short(); set @b= uuid_short();
select @b - @a; select @b - @a;
...@@ -107,7 +107,7 @@ create table t1 as select uuid(), length(uuid()); ...@@ -107,7 +107,7 @@ 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) CHARACTER SET utf8 DEFAULT NULL, `uuid()` varchar(36) DEFAULT NULL,
`length(uuid())` int(10) DEFAULT NULL `length(uuid())` int(10) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1; drop table t1;
......
...@@ -1663,8 +1663,7 @@ class Item_func_uuid: public Item_str_func ...@@ -1663,8 +1663,7 @@ class Item_func_uuid: public Item_str_func
Item_func_uuid(THD *thd): Item_str_func(thd) {} Item_func_uuid(THD *thd): Item_str_func(thd) {}
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
collation.set(system_charset_info, collation.set(DTCollation_numeric());
DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII);
fix_char_length(MY_UUID_STRING_LENGTH); fix_char_length(MY_UUID_STRING_LENGTH);
return FALSE; return FALSE;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment