Commit 6beb08c7 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-15624 Changing the default character set to utf8mb4 changes query...

MDEV-15624 Changing the default character set to utf8mb4 changes query evaluation in a very surprising way
parent f5369faf
......@@ -4397,5 +4397,36 @@ Field Type Null Key Default Extra
c1 mediumtext YES NULL
DROP TABLE t1;
#
# MDEV-15624 Changing the default character set to utf8mb4 changes query evaluation in a very surprising way
#
SET NAMES utf8;
CREATE TABLE t1 (id INT);
INSERT INTO t1 VALUES (1),(2),(3);
SELECT COUNT(DISTINCT c) FROM (SELECT id, REPLACE(uuid_short(), '0', CAST('o' AS CHAR CHARACTER SET ucs2)) AS c FROM t1) AS d1;
COUNT(DISTINCT c)
3
SELECT DISTINCT REPLACE(uuid_short(), '0', CAST('o' AS CHAR CHARACTER SET ucs2)) AS c FROM t1;
c
xxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxx
SELECT COUNT(DISTINCT c) FROM (SELECT id, INSERT(uuid_short(), 1, 1, CAST('0' AS CHAR CHARACTER SET ucs2)) AS c FROM t1) AS d1;
COUNT(DISTINCT c)
3
SELECT DISTINCT INSERT(uuid_short(), 1, 1, CAST('0' AS CHAR CHARACTER SET ucs2)) AS c FROM t1;
c
xxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxx
SELECT COUNT(DISTINCT c) FROM (SELECT id, CONCAT(uuid_short(), CAST('0' AS CHAR CHARACTER SET ucs2)) AS c FROM t1) AS d1;
COUNT(DISTINCT c)
3
SELECT DISTINCT CONCAT(uuid_short(), CAST('0' AS CHAR CHARACTER SET ucs2)) AS c FROM t1;
c
xxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxx
DROP TABLE t1;
#
# End of 5.5 tests
#
......@@ -2656,6 +2656,29 @@ SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 65536) AS data ) AS sub;
len
196608
#
# MDEV-15624 Changing the default character set to utf8mb4 changes query evaluation in a very surprising way
#
SET NAMES utf8mb4;
CREATE TABLE t1 (id INT);
INSERT INTO t1 VALUES (1),(2),(3);
SELECT COUNT(DISTINCT c) FROM (SELECT id, REPLACE(UUID(), "-", "") AS c FROM t1) AS d1;
COUNT(DISTINCT c)
3
SELECT DISTINCT INSERT(uuid(), 9, 1, "X") AS c FROM t1;
c
xxxxxxxxxxxxx-xxxx-xxxx-xxxxxxxxxxxx
xxxxxxxxxxxxx-xxxx-xxxx-xxxxxxxxxxxx
xxxxxxxxxxxxx-xxxx-xxxx-xxxxxxxxxxxx
SELECT COUNT(DISTINCT c) FROM (SELECT id, INSERT(UUID(), 9, 1, "X") AS c FROM t1) AS d1;
COUNT(DISTINCT c)
3
SELECT DISTINCT INSERT(UUID(), 9, 1, "X") AS c FROM t1;
c
xxxxxxxxxxxxx-xxxx-xxxx-xxxxxxxxxxxx
xxxxxxxxxxxxx-xxxx-xxxx-xxxxxxxxxxxx
xxxxxxxxxxxxx-xxxx-xxxx-xxxxxxxxxxxx
DROP TABLE t1;
#
# End of 5.5 tests
#
#
......
......@@ -885,6 +885,28 @@ DESCRIBE t1;
DROP TABLE t1;
--echo #
--echo # MDEV-15624 Changing the default character set to utf8mb4 changes query evaluation in a very surprising way
--echo #
SET NAMES utf8;
CREATE TABLE t1 (id INT);
INSERT INTO t1 VALUES (1),(2),(3);
SELECT COUNT(DISTINCT c) FROM (SELECT id, REPLACE(uuid_short(), '0', CAST('o' AS CHAR CHARACTER SET ucs2)) AS c FROM t1) AS d1;
--replace_column 1 xxxxxxxxxxxxxxxxx
SELECT DISTINCT REPLACE(uuid_short(), '0', CAST('o' AS CHAR CHARACTER SET ucs2)) AS c FROM t1;
SELECT COUNT(DISTINCT c) FROM (SELECT id, INSERT(uuid_short(), 1, 1, CAST('0' AS CHAR CHARACTER SET ucs2)) AS c FROM t1) AS d1;
--replace_column 1 xxxxxxxxxxxxxxxxx
SELECT DISTINCT INSERT(uuid_short(), 1, 1, CAST('0' AS CHAR CHARACTER SET ucs2)) AS c FROM t1;
SELECT COUNT(DISTINCT c) FROM (SELECT id, CONCAT(uuid_short(), CAST('0' AS CHAR CHARACTER SET ucs2)) AS c FROM t1) AS d1;
--replace_column 1 xxxxxxxxxxxxxxxxx
SELECT DISTINCT CONCAT(uuid_short(), CAST('0' AS CHAR CHARACTER SET ucs2)) AS c FROM t1;
DROP TABLE t1;
--echo #
--echo # End of 5.5 tests
--echo #
......@@ -1858,6 +1858,25 @@ SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 21846) AS data ) AS sub;
SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 65535) AS data ) AS sub;
SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 65536) AS data ) AS sub;
--echo #
--echo # MDEV-15624 Changing the default character set to utf8mb4 changes query evaluation in a very surprising way
--echo #
SET NAMES utf8mb4;
CREATE TABLE t1 (id INT);
INSERT INTO t1 VALUES (1),(2),(3);
SELECT COUNT(DISTINCT c) FROM (SELECT id, REPLACE(UUID(), "-", "") AS c FROM t1) AS d1;
--replace_column 1 xxxxxxxxxxxxx-xxxx-xxxx-xxxxxxxxxxxx
SELECT DISTINCT INSERT(uuid(), 9, 1, "X") AS c FROM t1;
SELECT COUNT(DISTINCT c) FROM (SELECT id, INSERT(UUID(), 9, 1, "X") AS c FROM t1) AS d1;
--replace_column 1 xxxxxxxxxxxxx-xxxx-xxxx-xxxxxxxxxxxx
SELECT DISTINCT INSERT(UUID(), 9, 1, "X") AS c FROM t1;
DROP TABLE t1;
--echo #
--echo # End of 5.5 tests
--echo #
......
......@@ -2133,6 +2133,8 @@ class Item_func_uuid_short :public Item_int_func
Item_func_uuid_short() :Item_int_func() {}
const char *func_name() const { return "uuid_short"; }
longlong val_int();
bool const_item() const { return false; }
table_map used_tables() const { return RAND_TABLE_BIT; }
void fix_length_and_dec()
{ max_length= 21; unsigned_flag=1; }
bool check_vcol_func_processor(uchar *int_arg)
......
......@@ -997,6 +997,7 @@ class Item_func_uuid: public Item_str_func
DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII);
fix_char_length(MY_UUID_STRING_LENGTH);
}
bool const_item() const { return false; }
table_map used_tables() const { return RAND_TABLE_BIT; }
const char *func_name() const{ return "uuid"; }
String *val_str(String *);
......
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