Skip to content

Commit

Permalink
MDEV-21841 CONV() function doesn't truncate its output to 21 when use…
Browse files Browse the repository at this point in the history
…s default charset.
  • Loading branch information
drrtuy committed Feb 29, 2020
1 parent e837a35 commit 1ad8693
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
15 changes: 15 additions & 0 deletions mysql-test/main/func_str.result
Original file line number Diff line number Diff line change
Expand Up @@ -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( '<a>new year</a>', '/a', '2019-01-01 00:00:00' ), ENCODE('text','pass') ) AS f;
Expand Down
11 changes: 11 additions & 0 deletions mysql-test/main/func_str.test
Original file line number Diff line number Diff line change
Expand Up @@ -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 #
Expand Down
2 changes: 1 addition & 1 deletion sql/item_strfunc.h
Original file line number Diff line number Diff line change
Expand Up @@ -1205,7 +1205,7 @@ class Item_func_conv :public Item_str_func
bool fix_length_and_dec()
{
collation.set(default_charset());
max_length=64;
fix_char_length(64);
maybe_null= 1;
return FALSE;
}
Expand Down

0 comments on commit 1ad8693

Please sign in to comment.