From 424149e3282e0ff4950726458d006528f5dc187e Mon Sep 17 00:00:00 2001 From: Roman Nozdrin Date: Fri, 28 Feb 2020 15:44:56 +0000 Subject: MDEV-21841 CONV() function doesn't truncate its output to 21 when uses default charset. --- mysql-test/main/func_str.result | 15 +++++++++++++++ mysql-test/main/func_str.test | 11 +++++++++++ sql/item_strfunc.h | 2 +- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/mysql-test/main/func_str.result b/mysql-test/main/func_str.result index b4e3f27eda6..4a01935785c 100644 --- a/mysql-test/main/func_str.result +++ b/mysql-test/main/func_str.result @@ -5159,6 +5159,21 @@ DROP TABLE t1, t2; # Start of 10.4 tests # # +# MDEV-21841 CONV() function truncates the result type to 21 symbol. +# +CREATE TABLE t1(i BIGINT); +INSERT INTO t1 VALUES (-1); +CREATE TABLE t2 AS SELECT conv(i,16,2) from t1; +SELECT * FROM t2; +conv(i,16,2) +1111111111111111111111111111111111111111111111111111111111111111 +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `conv(i,16,2)` varchar(64) CHARACTER SET utf8 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1,t2; +# # MDEV-18205 Assertion `str_length < len' failed in Binary_string::realloc_raw # SELECT GROUP_CONCAT( UpdateXML( 'new year', '/a', '2019-01-01 00:00:00' ), ENCODE('text','pass') ) AS f; diff --git a/mysql-test/main/func_str.test b/mysql-test/main/func_str.test index a01b3942209..ba5b671ca4f 100644 --- a/mysql-test/main/func_str.test +++ b/mysql-test/main/func_str.test @@ -2099,6 +2099,17 @@ DROP TABLE t1, t2; --echo # Start of 10.4 tests --echo # +--echo # +--echo # MDEV-21841 CONV() function truncates the result type to 21 symbol. +--echo # + +CREATE TABLE t1(i BIGINT); +INSERT INTO t1 VALUES (-1); +CREATE TABLE t2 AS SELECT conv(i,16,2) from t1; +SELECT * FROM t2; +SHOW CREATE TABLE t2; +DROP TABLE t1,t2; + --echo # --echo # MDEV-18205 Assertion `str_length < len' failed in Binary_string::realloc_raw --echo # diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index 42b5b4f2aeb..ae0afeabeae 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -1205,7 +1205,7 @@ public: bool fix_length_and_dec() { collation.set(default_charset()); - max_length=64; + fix_char_length(64); maybe_null= 1; return FALSE; } -- cgit v1.2.1