Loading mysql-test/r/ctype_utf8.result +37 −0 Original line number Diff line number Diff line Loading @@ -1657,3 +1657,40 @@ colA colB colA colB 1 foo 1 foo 2 foo bar 2 foo bar DROP TABLE t1, t2; SELECT 'н1234567890' UNION SELECT _binary '1'; н1234567890 н1234567890 1 SELECT 'н1234567890' UNION SELECT 1; н1234567890 н1234567890 1 SELECT '1' UNION SELECT 'н1234567890'; 1 1 н1234567890 SELECT 1 UNION SELECT 'н1234567890'; 1 1 н1234567890 CREATE TABLE t1 (c VARCHAR(11)) CHARACTER SET utf8; CREATE TABLE t2 (b CHAR(1) CHARACTER SET binary, i INT); INSERT INTO t1 (c) VALUES ('н1234567890'); INSERT INTO t2 (b, i) VALUES ('1', 1); SELECT c FROM t1 UNION SELECT b FROM t2; c н1234567890 1 SELECT c FROM t1 UNION SELECT i FROM t2; c н1234567890 1 SELECT b FROM t2 UNION SELECT c FROM t1; b 1 н1234567890 SELECT i FROM t2 UNION SELECT c FROM t1; i 1 н1234567890 DROP TABLE t1, t2; mysql-test/t/ctype_utf8.test +25 −0 Original line number Diff line number Diff line Loading @@ -1338,3 +1338,28 @@ INSERT INTO t2 (colA, colB) VALUES (1, 'foo'),(2, 'foo bar'); SELECT * FROM t1 JOIN t2 ON t1.colA=t2.colA AND t1.colB=t2.colB WHERE t1.colA < 3; DROP TABLE t1, t2; # # Bug#29205: truncation of UTF8 values when the UNION statement # forces collation to the binary charset # SELECT 'н1234567890' UNION SELECT _binary '1'; SELECT 'н1234567890' UNION SELECT 1; SELECT '1' UNION SELECT 'н1234567890'; SELECT 1 UNION SELECT 'н1234567890'; CREATE TABLE t1 (c VARCHAR(11)) CHARACTER SET utf8; CREATE TABLE t2 (b CHAR(1) CHARACTER SET binary, i INT); INSERT INTO t1 (c) VALUES ('н1234567890'); INSERT INTO t2 (b, i) VALUES ('1', 1); SELECT c FROM t1 UNION SELECT b FROM t2; SELECT c FROM t1 UNION SELECT i FROM t2; SELECT b FROM t2 UNION SELECT c FROM t1; SELECT i FROM t2 UNION SELECT c FROM t1; DROP TABLE t1, t2; sql/item.cc +9 −3 Original line number Diff line number Diff line Loading @@ -6595,9 +6595,15 @@ bool Item_type_holder::join_types(THD *thd, Item *item) expansion of the size of the values because of character set conversions. */ if (collation.collation != &my_charset_bin) { max_length= max(old_max_chars * collation.collation->mbmaxlen, display_length(item) / item->collation.collation->mbmaxlen * display_length(item) / item->collation.collation->mbmaxlen * collation.collation->mbmaxlen); } else set_if_bigger(max_length, display_length(item)); break; } case REAL_RESULT: Loading Loading
mysql-test/r/ctype_utf8.result +37 −0 Original line number Diff line number Diff line Loading @@ -1657,3 +1657,40 @@ colA colB colA colB 1 foo 1 foo 2 foo bar 2 foo bar DROP TABLE t1, t2; SELECT 'н1234567890' UNION SELECT _binary '1'; н1234567890 н1234567890 1 SELECT 'н1234567890' UNION SELECT 1; н1234567890 н1234567890 1 SELECT '1' UNION SELECT 'н1234567890'; 1 1 н1234567890 SELECT 1 UNION SELECT 'н1234567890'; 1 1 н1234567890 CREATE TABLE t1 (c VARCHAR(11)) CHARACTER SET utf8; CREATE TABLE t2 (b CHAR(1) CHARACTER SET binary, i INT); INSERT INTO t1 (c) VALUES ('н1234567890'); INSERT INTO t2 (b, i) VALUES ('1', 1); SELECT c FROM t1 UNION SELECT b FROM t2; c н1234567890 1 SELECT c FROM t1 UNION SELECT i FROM t2; c н1234567890 1 SELECT b FROM t2 UNION SELECT c FROM t1; b 1 н1234567890 SELECT i FROM t2 UNION SELECT c FROM t1; i 1 н1234567890 DROP TABLE t1, t2;
mysql-test/t/ctype_utf8.test +25 −0 Original line number Diff line number Diff line Loading @@ -1338,3 +1338,28 @@ INSERT INTO t2 (colA, colB) VALUES (1, 'foo'),(2, 'foo bar'); SELECT * FROM t1 JOIN t2 ON t1.colA=t2.colA AND t1.colB=t2.colB WHERE t1.colA < 3; DROP TABLE t1, t2; # # Bug#29205: truncation of UTF8 values when the UNION statement # forces collation to the binary charset # SELECT 'н1234567890' UNION SELECT _binary '1'; SELECT 'н1234567890' UNION SELECT 1; SELECT '1' UNION SELECT 'н1234567890'; SELECT 1 UNION SELECT 'н1234567890'; CREATE TABLE t1 (c VARCHAR(11)) CHARACTER SET utf8; CREATE TABLE t2 (b CHAR(1) CHARACTER SET binary, i INT); INSERT INTO t1 (c) VALUES ('н1234567890'); INSERT INTO t2 (b, i) VALUES ('1', 1); SELECT c FROM t1 UNION SELECT b FROM t2; SELECT c FROM t1 UNION SELECT i FROM t2; SELECT b FROM t2 UNION SELECT c FROM t1; SELECT i FROM t2 UNION SELECT c FROM t1; DROP TABLE t1, t2;
sql/item.cc +9 −3 Original line number Diff line number Diff line Loading @@ -6595,9 +6595,15 @@ bool Item_type_holder::join_types(THD *thd, Item *item) expansion of the size of the values because of character set conversions. */ if (collation.collation != &my_charset_bin) { max_length= max(old_max_chars * collation.collation->mbmaxlen, display_length(item) / item->collation.collation->mbmaxlen * display_length(item) / item->collation.collation->mbmaxlen * collation.collation->mbmaxlen); } else set_if_bigger(max_length, display_length(item)); break; } case REAL_RESULT: Loading