Bug#54916 GROUP_CONCAT + IFNULL truncates output
Problem: a few functions did not calculate their max_length correctly. This is an after-fix for WL#2649 Number-to-string conversions". Fix: changing the buggy functions to calculate max_length using fix_char_length() introduced in WL#2649, instead of setting max_length directly mysql-test/include/ctype_numconv.inc Adding new tests mysql-test/r/ctype_binary.result Adding new tests mysql-test/r/ctype_cp1251.result Adding new tests mysql-test/r/ctype_latin1.result Adding new tests mysql-test/r/ctype_ucs.result Adding new tests mysql-test/r/ctype_utf8.result Adding new tests mysql-test/t/ctype_utf8.test Including ctype_numconv sql/item.h - Introducing new method fix_char_length_ulonglong(), for the cases when length is potentially greater than UINT_MAX32. This method removes a few instances of duplicate code, e.g. in item_strfunc.cc. - Setting collation in Item_copy properly. This change fixes wrong metadata on client side in some cases, when "binary" instead of the real character set was reported. sql/item_cmpfunc.cc - Using fix_char_length() and max_char_length() methods, instead of direct access to max_length, to calculate item length properly. - Moving count_only_length() in COALESCE after agg_arg_charsets_for_string_result(). The old order was incorrect and led to wrong length calucation in case of multi-byte character sets. sql/item_func.cc Fixing that count_only_length() didn't work properly for multi-byte character sets. Using fix_char_length() and max_char_length() instead of direct access to max_length. sql/item_strfunc.cc - Using fix_char_length(), fix_char_length_ulonglong(), max_char_length() instead of direct access to max_length. - Removing wierd condition: "if (collation.collation->mbmaxlen > 0)", which is never FALSE.
This commit is contained in:
parent
67d895d499
commit
6e9298bddc
@ -1625,6 +1625,108 @@ SET @x=aswkt(point(1,2));
|
||||
SELECT charset(@x), collation(@x);
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # Bug#54916 GROUP_CONCAT + IFNULL truncates output
|
||||
--echo #
|
||||
SELECT @@collation_connection;
|
||||
# ENGINE=MYISAM is very important to make sure "SYSTEM" join type
|
||||
# is in use, which will create instances of Item_copy.
|
||||
CREATE TABLE t1 (a MEDIUMINT NULL) ENGINE=MYISAM;
|
||||
INSERT INTO t1 VALUES (1234567);
|
||||
SELECT GROUP_CONCAT(IFNULL(a,'')) FROM t1;
|
||||
SELECT GROUP_CONCAT(IF(a,a,'')) FROM t1;
|
||||
if (`SELECT @@character_set_connection != 'ucs2'`)
|
||||
{
|
||||
# Temporarily disable for ucs2
|
||||
# For details, see Bug#55744 GROUP_CONCAT + CASE + ucs return garbage
|
||||
SELECT GROUP_CONCAT(CASE WHEN a THEN a ELSE '' END) FROM t1;
|
||||
}
|
||||
--enable_metadata
|
||||
SELECT COALESCE(a,'') FROM t1 GROUP BY 1;
|
||||
--disable_metadata
|
||||
--echo # All columns must be VARCHAR(9) with the same length:
|
||||
--disable_warnings
|
||||
CREATE TABLE t2 AS
|
||||
SELECT
|
||||
CONCAT(a),
|
||||
IFNULL(a,''),
|
||||
IF(a,a,''),
|
||||
CASE WHEN a THEN a ELSE '' END,
|
||||
COALESCE(a,'')
|
||||
FROM t1;
|
||||
--enable_warnings
|
||||
# The above query is expected to send a warning
|
||||
# in case of ucs2 character set, until Bug#55744 is fixed.
|
||||
SHOW CREATE TABLE t2;
|
||||
DROP TABLE t2;
|
||||
|
||||
CREATE TABLE t2 AS SELECT CONCAT_WS(1,2,3) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
DROP TABLE t2;
|
||||
|
||||
CREATE TABLE t2 AS SELECT INSERT(1133,3,0,22) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
DROP TABLE t2;
|
||||
|
||||
CREATE TABLE t2 AS SELECT LCASE(a) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
DROP TABLE t2;
|
||||
|
||||
CREATE TABLE t2 AS SELECT UCASE(a) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
DROP TABLE t2;
|
||||
|
||||
CREATE TABLE t2 AS SELECT REPEAT(1,2) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
DROP TABLE t2;
|
||||
|
||||
CREATE TABLE t2 AS SELECT LEFT(123,2) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
DROP TABLE t2;
|
||||
|
||||
CREATE TABLE t2 AS SELECT RIGHT(123,2) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
DROP TABLE t2;
|
||||
|
||||
CREATE TABLE t2 AS SELECT LTRIM(123) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
DROP TABLE t2;
|
||||
|
||||
CREATE TABLE t2 AS SELECT RTRIM(123) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
DROP TABLE t2;
|
||||
|
||||
CREATE TABLE t2 AS SELECT ELT(1,111,222,333) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
DROP TABLE t2;
|
||||
|
||||
CREATE TABLE t2 AS SELECT REPLACE(111,2,3) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
DROP TABLE t2;
|
||||
|
||||
CREATE TABLE t2 AS SELECT SUBSTRING_INDEX(111,111,1) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
DROP TABLE t2;
|
||||
|
||||
CREATE TABLE t2 AS SELECT MAKE_SET(111,222,3) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
DROP TABLE t2;
|
||||
|
||||
CREATE TABLE t2 AS SELECT SOUNDEX(1) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
DROP TABLE t2;
|
||||
|
||||
CREATE TABLE t2 AS SELECT EXPORT_SET(1,'Y','N','',8);
|
||||
SHOW CREATE TABLE t2;
|
||||
DROP TABLE t2;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo #
|
||||
--echo # End of Bug#54916
|
||||
--echo #
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # Bug#52159 returning time type from function and empty left join causes debug assertion
|
||||
--echo #
|
||||
|
@ -160,6 +160,8 @@ t1 CREATE TABLE `t1` (
|
||||
`COALESCE('a' COLLATE latin1_bin,'b')` varchar(1) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 SELECT IFNULL('a' COLLATE latin1_swedish_ci, 'b' COLLATE latin1_bin);
|
||||
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,EXPLICIT) and (latin1_bin,EXPLICIT) for operation 'ifnull'
|
||||
SELECT 'case+union+test'
|
||||
UNION
|
||||
SELECT CASE LOWER('1') WHEN LOWER('2') THEN 'BUG' ELSE 'nobug' END;
|
||||
|
@ -2598,6 +2598,156 @@ SELECT charset(@x), collation(@x);
|
||||
charset(@x) collation(@x)
|
||||
binary binary
|
||||
#
|
||||
# Bug#54916 GROUP_CONCAT + IFNULL truncates output
|
||||
#
|
||||
SELECT @@collation_connection;
|
||||
@@collation_connection
|
||||
binary
|
||||
CREATE TABLE t1 (a MEDIUMINT NULL) ENGINE=MYISAM;
|
||||
INSERT INTO t1 VALUES (1234567);
|
||||
SELECT GROUP_CONCAT(IFNULL(a,'')) FROM t1;
|
||||
GROUP_CONCAT(IFNULL(a,''))
|
||||
1234567
|
||||
SELECT GROUP_CONCAT(IF(a,a,'')) FROM t1;
|
||||
GROUP_CONCAT(IF(a,a,''))
|
||||
1234567
|
||||
SELECT GROUP_CONCAT(CASE WHEN a THEN a ELSE '' END) FROM t1;
|
||||
GROUP_CONCAT(CASE WHEN a THEN a ELSE '' END)
|
||||
1234567
|
||||
SELECT COALESCE(a,'') FROM t1 GROUP BY 1;
|
||||
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
|
||||
def COALESCE(a,'') 253 9 7 Y 128 31 63
|
||||
COALESCE(a,'')
|
||||
1234567
|
||||
# All columns must be VARCHAR(9) with the same length:
|
||||
CREATE TABLE t2 AS
|
||||
SELECT
|
||||
CONCAT(a),
|
||||
IFNULL(a,''),
|
||||
IF(a,a,''),
|
||||
CASE WHEN a THEN a ELSE '' END,
|
||||
COALESCE(a,'')
|
||||
FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`CONCAT(a)` varbinary(9) DEFAULT NULL,
|
||||
`IFNULL(a,'')` varbinary(9) NOT NULL DEFAULT '',
|
||||
`IF(a,a,'')` varbinary(9) DEFAULT NULL,
|
||||
`CASE WHEN a THEN a ELSE '' END` varbinary(9) DEFAULT NULL,
|
||||
`COALESCE(a,'')` varbinary(9) DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT CONCAT_WS(1,2,3) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`CONCAT_WS(1,2,3)` varbinary(3) NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT INSERT(1133,3,0,22) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`INSERT(1133,3,0,22)` varbinary(6) NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT LCASE(a) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`LCASE(a)` varbinary(9) DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT UCASE(a) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`UCASE(a)` varbinary(9) DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT REPEAT(1,2) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`REPEAT(1,2)` varbinary(2) NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT LEFT(123,2) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`LEFT(123,2)` varbinary(2) NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT RIGHT(123,2) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`RIGHT(123,2)` varbinary(2) NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT LTRIM(123) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`LTRIM(123)` varbinary(3) NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT RTRIM(123) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`RTRIM(123)` varbinary(3) NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT ELT(1,111,222,333) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`ELT(1,111,222,333)` varbinary(3) DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT REPLACE(111,2,3) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`REPLACE(111,2,3)` varbinary(3) NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT SUBSTRING_INDEX(111,111,1) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`SUBSTRING_INDEX(111,111,1)` varbinary(3) NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT MAKE_SET(111,222,3) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`MAKE_SET(111,222,3)` varbinary(5) NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT SOUNDEX(1) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`SOUNDEX(1)` varbinary(4) NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT EXPORT_SET(1,'Y','N','',8);
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`EXPORT_SET(1,'Y','N','',8)` varbinary(64) NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# End of Bug#54916
|
||||
#
|
||||
#
|
||||
# Bug#52159 returning time type from function and empty left join causes debug assertion
|
||||
#
|
||||
CREATE FUNCTION f1() RETURNS TIME RETURN 1;
|
||||
|
@ -2680,6 +2680,156 @@ SELECT charset(@x), collation(@x);
|
||||
charset(@x) collation(@x)
|
||||
cp1251 cp1251_general_ci
|
||||
#
|
||||
# Bug#54916 GROUP_CONCAT + IFNULL truncates output
|
||||
#
|
||||
SELECT @@collation_connection;
|
||||
@@collation_connection
|
||||
cp1251_general_ci
|
||||
CREATE TABLE t1 (a MEDIUMINT NULL) ENGINE=MYISAM;
|
||||
INSERT INTO t1 VALUES (1234567);
|
||||
SELECT GROUP_CONCAT(IFNULL(a,'')) FROM t1;
|
||||
GROUP_CONCAT(IFNULL(a,''))
|
||||
1234567
|
||||
SELECT GROUP_CONCAT(IF(a,a,'')) FROM t1;
|
||||
GROUP_CONCAT(IF(a,a,''))
|
||||
1234567
|
||||
SELECT GROUP_CONCAT(CASE WHEN a THEN a ELSE '' END) FROM t1;
|
||||
GROUP_CONCAT(CASE WHEN a THEN a ELSE '' END)
|
||||
1234567
|
||||
SELECT COALESCE(a,'') FROM t1 GROUP BY 1;
|
||||
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
|
||||
def COALESCE(a,'') 253 9 7 Y 0 31 51
|
||||
COALESCE(a,'')
|
||||
1234567
|
||||
# All columns must be VARCHAR(9) with the same length:
|
||||
CREATE TABLE t2 AS
|
||||
SELECT
|
||||
CONCAT(a),
|
||||
IFNULL(a,''),
|
||||
IF(a,a,''),
|
||||
CASE WHEN a THEN a ELSE '' END,
|
||||
COALESCE(a,'')
|
||||
FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`CONCAT(a)` varchar(9) CHARACTER SET cp1251 DEFAULT NULL,
|
||||
`IFNULL(a,'')` varchar(9) CHARACTER SET cp1251 NOT NULL DEFAULT '',
|
||||
`IF(a,a,'')` varchar(9) CHARACTER SET cp1251 DEFAULT NULL,
|
||||
`CASE WHEN a THEN a ELSE '' END` varchar(9) CHARACTER SET cp1251 DEFAULT NULL,
|
||||
`COALESCE(a,'')` varchar(9) CHARACTER SET cp1251 DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT CONCAT_WS(1,2,3) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`CONCAT_WS(1,2,3)` varchar(3) CHARACTER SET cp1251 NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT INSERT(1133,3,0,22) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`INSERT(1133,3,0,22)` varchar(6) CHARACTER SET cp1251 NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT LCASE(a) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`LCASE(a)` varchar(9) CHARACTER SET cp1251 DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT UCASE(a) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`UCASE(a)` varchar(9) CHARACTER SET cp1251 DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT REPEAT(1,2) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`REPEAT(1,2)` varchar(2) CHARACTER SET cp1251 NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT LEFT(123,2) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`LEFT(123,2)` varchar(2) CHARACTER SET cp1251 NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT RIGHT(123,2) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`RIGHT(123,2)` varchar(2) CHARACTER SET cp1251 NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT LTRIM(123) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`LTRIM(123)` varchar(3) CHARACTER SET cp1251 NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT RTRIM(123) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`RTRIM(123)` varchar(3) CHARACTER SET cp1251 NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT ELT(1,111,222,333) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`ELT(1,111,222,333)` varchar(3) CHARACTER SET cp1251 DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT REPLACE(111,2,3) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`REPLACE(111,2,3)` varchar(3) CHARACTER SET cp1251 NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT SUBSTRING_INDEX(111,111,1) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`SUBSTRING_INDEX(111,111,1)` varchar(3) CHARACTER SET cp1251 NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT MAKE_SET(111,222,3) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`MAKE_SET(111,222,3)` varchar(5) CHARACTER SET cp1251 NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT SOUNDEX(1) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`SOUNDEX(1)` varchar(4) CHARACTER SET cp1251 NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT EXPORT_SET(1,'Y','N','',8);
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`EXPORT_SET(1,'Y','N','',8)` varchar(64) CHARACTER SET cp1251 NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# End of Bug#54916
|
||||
#
|
||||
#
|
||||
# Bug#52159 returning time type from function and empty left join causes debug assertion
|
||||
#
|
||||
CREATE FUNCTION f1() RETURNS TIME RETURN 1;
|
||||
|
@ -3008,6 +3008,156 @@ SELECT charset(@x), collation(@x);
|
||||
charset(@x) collation(@x)
|
||||
latin1 latin1_swedish_ci
|
||||
#
|
||||
# Bug#54916 GROUP_CONCAT + IFNULL truncates output
|
||||
#
|
||||
SELECT @@collation_connection;
|
||||
@@collation_connection
|
||||
latin1_swedish_ci
|
||||
CREATE TABLE t1 (a MEDIUMINT NULL) ENGINE=MYISAM;
|
||||
INSERT INTO t1 VALUES (1234567);
|
||||
SELECT GROUP_CONCAT(IFNULL(a,'')) FROM t1;
|
||||
GROUP_CONCAT(IFNULL(a,''))
|
||||
1234567
|
||||
SELECT GROUP_CONCAT(IF(a,a,'')) FROM t1;
|
||||
GROUP_CONCAT(IF(a,a,''))
|
||||
1234567
|
||||
SELECT GROUP_CONCAT(CASE WHEN a THEN a ELSE '' END) FROM t1;
|
||||
GROUP_CONCAT(CASE WHEN a THEN a ELSE '' END)
|
||||
1234567
|
||||
SELECT COALESCE(a,'') FROM t1 GROUP BY 1;
|
||||
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
|
||||
def COALESCE(a,'') 253 9 7 Y 0 31 8
|
||||
COALESCE(a,'')
|
||||
1234567
|
||||
# All columns must be VARCHAR(9) with the same length:
|
||||
CREATE TABLE t2 AS
|
||||
SELECT
|
||||
CONCAT(a),
|
||||
IFNULL(a,''),
|
||||
IF(a,a,''),
|
||||
CASE WHEN a THEN a ELSE '' END,
|
||||
COALESCE(a,'')
|
||||
FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`CONCAT(a)` varchar(9) DEFAULT NULL,
|
||||
`IFNULL(a,'')` varchar(9) NOT NULL DEFAULT '',
|
||||
`IF(a,a,'')` varchar(9) DEFAULT NULL,
|
||||
`CASE WHEN a THEN a ELSE '' END` varchar(9) DEFAULT NULL,
|
||||
`COALESCE(a,'')` varchar(9) DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT CONCAT_WS(1,2,3) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`CONCAT_WS(1,2,3)` varchar(3) NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT INSERT(1133,3,0,22) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`INSERT(1133,3,0,22)` varchar(6) NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT LCASE(a) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`LCASE(a)` varchar(9) DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT UCASE(a) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`UCASE(a)` varchar(9) DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT REPEAT(1,2) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`REPEAT(1,2)` varchar(2) NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT LEFT(123,2) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`LEFT(123,2)` varchar(2) NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT RIGHT(123,2) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`RIGHT(123,2)` varchar(2) NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT LTRIM(123) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`LTRIM(123)` varchar(3) NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT RTRIM(123) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`RTRIM(123)` varchar(3) NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT ELT(1,111,222,333) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`ELT(1,111,222,333)` varchar(3) DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT REPLACE(111,2,3) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`REPLACE(111,2,3)` varchar(3) NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT SUBSTRING_INDEX(111,111,1) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`SUBSTRING_INDEX(111,111,1)` varchar(3) NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT MAKE_SET(111,222,3) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`MAKE_SET(111,222,3)` varchar(5) NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT SOUNDEX(1) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`SOUNDEX(1)` varchar(4) NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT EXPORT_SET(1,'Y','N','',8);
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`EXPORT_SET(1,'Y','N','',8)` varchar(64) NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# End of Bug#54916
|
||||
#
|
||||
#
|
||||
# Bug#52159 returning time type from function and empty left join causes debug assertion
|
||||
#
|
||||
CREATE FUNCTION f1() RETURNS TIME RETURN 1;
|
||||
|
@ -3840,6 +3840,153 @@ SELECT charset(@x), collation(@x);
|
||||
charset(@x) collation(@x)
|
||||
ucs2 ucs2_general_ci
|
||||
#
|
||||
# Bug#54916 GROUP_CONCAT + IFNULL truncates output
|
||||
#
|
||||
SELECT @@collation_connection;
|
||||
@@collation_connection
|
||||
ucs2_general_ci
|
||||
CREATE TABLE t1 (a MEDIUMINT NULL) ENGINE=MYISAM;
|
||||
INSERT INTO t1 VALUES (1234567);
|
||||
SELECT GROUP_CONCAT(IFNULL(a,'')) FROM t1;
|
||||
GROUP_CONCAT(IFNULL(a,''))
|
||||
1234567
|
||||
SELECT GROUP_CONCAT(IF(a,a,'')) FROM t1;
|
||||
GROUP_CONCAT(IF(a,a,''))
|
||||
1234567
|
||||
SELECT COALESCE(a,'') FROM t1 GROUP BY 1;
|
||||
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
|
||||
def COALESCE(a,'') 253 9 7 Y 0 31 8
|
||||
COALESCE(a,'')
|
||||
1234567
|
||||
# All columns must be VARCHAR(9) with the same length:
|
||||
CREATE TABLE t2 AS
|
||||
SELECT
|
||||
CONCAT(a),
|
||||
IFNULL(a,''),
|
||||
IF(a,a,''),
|
||||
CASE WHEN a THEN a ELSE '' END,
|
||||
COALESCE(a,'')
|
||||
FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`CONCAT(a)` varchar(9) CHARACTER SET ucs2 DEFAULT NULL,
|
||||
`IFNULL(a,'')` varchar(9) CHARACTER SET ucs2 NOT NULL DEFAULT '',
|
||||
`IF(a,a,'')` varchar(9) CHARACTER SET ucs2 DEFAULT NULL,
|
||||
`CASE WHEN a THEN a ELSE '' END` varchar(9) CHARACTER SET ucs2 DEFAULT NULL,
|
||||
`COALESCE(a,'')` varchar(9) CHARACTER SET ucs2 DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT CONCAT_WS(1,2,3) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`CONCAT_WS(1,2,3)` varchar(3) CHARACTER SET ucs2 NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT INSERT(1133,3,0,22) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`INSERT(1133,3,0,22)` varchar(6) CHARACTER SET ucs2 NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT LCASE(a) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`LCASE(a)` varchar(9) CHARACTER SET ucs2 DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT UCASE(a) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`UCASE(a)` varchar(9) CHARACTER SET ucs2 DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT REPEAT(1,2) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`REPEAT(1,2)` varchar(2) CHARACTER SET ucs2 NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT LEFT(123,2) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`LEFT(123,2)` varchar(2) CHARACTER SET ucs2 NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT RIGHT(123,2) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`RIGHT(123,2)` varchar(2) CHARACTER SET ucs2 NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT LTRIM(123) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`LTRIM(123)` varchar(3) CHARACTER SET ucs2 NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT RTRIM(123) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`RTRIM(123)` varchar(3) CHARACTER SET ucs2 NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT ELT(1,111,222,333) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`ELT(1,111,222,333)` varchar(3) CHARACTER SET ucs2 DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT REPLACE(111,2,3) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`REPLACE(111,2,3)` varchar(3) CHARACTER SET ucs2 NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT SUBSTRING_INDEX(111,111,1) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`SUBSTRING_INDEX(111,111,1)` varchar(3) CHARACTER SET ucs2 NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT MAKE_SET(111,222,3) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`MAKE_SET(111,222,3)` varchar(5) CHARACTER SET ucs2 NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT SOUNDEX(1) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`SOUNDEX(1)` varchar(4) CHARACTER SET ucs2 NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS SELECT EXPORT_SET(1,'Y','N','',8);
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`EXPORT_SET(1,'Y','N','',8)` varchar(64) CHARACTER SET ucs2 NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# End of Bug#54916
|
||||
#
|
||||
#
|
||||
# Bug#52159 returning time type from function and empty left join causes debug assertion
|
||||
#
|
||||
CREATE FUNCTION f1() RETURNS TIME RETURN 1;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -111,6 +111,9 @@ explain extended SELECT
|
||||
SHOW CREATE TABLE t1;
|
||||
DROP TABLE t1;
|
||||
|
||||
--error 1267
|
||||
CREATE TABLE t1 SELECT IFNULL('a' COLLATE latin1_swedish_ci, 'b' COLLATE latin1_bin);
|
||||
|
||||
# Test for BUG#10151
|
||||
SELECT 'case+union+test'
|
||||
UNION
|
||||
|
@ -1505,6 +1505,11 @@ CREATE TABLE t2 AS SELECT CONCAT(s1) FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
DROP TABLE t1, t2;
|
||||
|
||||
|
||||
SET NAMES utf8;
|
||||
--source include/ctype_numconv.inc
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # End of 5.5 tests
|
||||
--echo #
|
||||
|
15
sql/item.h
15
sql/item.h
@ -547,7 +547,7 @@ public:
|
||||
@see Query_arena::free_list
|
||||
*/
|
||||
Item *next;
|
||||
uint32 max_length;
|
||||
uint32 max_length; /* Maximum length, in bytes */
|
||||
uint name_length; /* Length of name */
|
||||
int8 marker;
|
||||
uint8 decimals;
|
||||
@ -1221,6 +1221,18 @@ public:
|
||||
max_length= char_to_byte_length_safe(max_char_length_arg,
|
||||
collation.collation->mbmaxlen);
|
||||
}
|
||||
void fix_char_length_ulonglong(ulonglong max_char_length_arg)
|
||||
{
|
||||
ulonglong max_result_length= max_char_length_arg *
|
||||
collation.collation->mbmaxlen;
|
||||
if (max_result_length >= MAX_BLOB_WIDTH)
|
||||
{
|
||||
max_length= MAX_BLOB_WIDTH;
|
||||
maybe_null= 1;
|
||||
}
|
||||
else
|
||||
max_length= max_result_length;
|
||||
}
|
||||
void fix_length_and_charset_datetime(uint32 max_char_length_arg)
|
||||
{
|
||||
collation.set(&my_charset_numeric, DERIVATION_NUMERIC, MY_REPERTOIRE_ASCII);
|
||||
@ -2825,6 +2837,7 @@ protected:
|
||||
cached_result_type= item->result_type();
|
||||
unsigned_flag= item->unsigned_flag;
|
||||
fixed= item->fixed;
|
||||
collation.set(item->collation);
|
||||
}
|
||||
|
||||
public:
|
||||
|
@ -2374,6 +2374,7 @@ void Item_func_between::print(String *str, enum_query_type query_type)
|
||||
void
|
||||
Item_func_ifnull::fix_length_and_dec()
|
||||
{
|
||||
uint32 char_length;
|
||||
agg_result_type(&hybrid_type, args, 2);
|
||||
maybe_null=args[1]->maybe_null;
|
||||
decimals= max(args[0]->decimals, args[1]->decimals);
|
||||
@ -2381,20 +2382,21 @@ Item_func_ifnull::fix_length_and_dec()
|
||||
|
||||
if (hybrid_type == DECIMAL_RESULT || hybrid_type == INT_RESULT)
|
||||
{
|
||||
int len0= args[0]->max_length - args[0]->decimals
|
||||
int len0= args[0]->max_char_length() - args[0]->decimals
|
||||
- (args[0]->unsigned_flag ? 0 : 1);
|
||||
|
||||
int len1= args[1]->max_length - args[1]->decimals
|
||||
int len1= args[1]->max_char_length() - args[1]->decimals
|
||||
- (args[1]->unsigned_flag ? 0 : 1);
|
||||
|
||||
max_length= max(len0, len1) + decimals + (unsigned_flag ? 0 : 1);
|
||||
char_length= max(len0, len1) + decimals + (unsigned_flag ? 0 : 1);
|
||||
}
|
||||
else
|
||||
max_length= max(args[0]->max_length, args[1]->max_length);
|
||||
char_length= max(args[0]->max_char_length(), args[1]->max_char_length());
|
||||
|
||||
switch (hybrid_type) {
|
||||
case STRING_RESULT:
|
||||
agg_arg_charsets_for_comparison(collation, args, arg_count);
|
||||
if (agg_arg_charsets_for_comparison(collation, args, arg_count))
|
||||
return;
|
||||
break;
|
||||
case DECIMAL_RESULT:
|
||||
case REAL_RESULT:
|
||||
@ -2406,6 +2408,7 @@ Item_func_ifnull::fix_length_and_dec()
|
||||
default:
|
||||
DBUG_ASSERT(0);
|
||||
}
|
||||
fix_char_length(char_length);
|
||||
cached_field_type= agg_field_type(args, 2);
|
||||
}
|
||||
|
||||
@ -2579,6 +2582,7 @@ Item_func_if::fix_length_and_dec()
|
||||
cached_field_type= agg_field_type(args + 1, 2);
|
||||
}
|
||||
|
||||
uint32 char_length;
|
||||
if ((cached_result_type == DECIMAL_RESULT )
|
||||
|| (cached_result_type == INT_RESULT))
|
||||
{
|
||||
@ -2588,10 +2592,11 @@ Item_func_if::fix_length_and_dec()
|
||||
int len2= args[2]->max_length - args[2]->decimals
|
||||
- (args[2]->unsigned_flag ? 0 : 1);
|
||||
|
||||
max_length=max(len1, len2) + decimals + (unsigned_flag ? 0 : 1);
|
||||
char_length= max(len1, len2) + decimals + (unsigned_flag ? 0 : 1);
|
||||
}
|
||||
else
|
||||
max_length= max(args[1]->max_length, args[2]->max_length);
|
||||
char_length= max(args[1]->max_char_length(), args[2]->max_char_length());
|
||||
fix_char_length(char_length);
|
||||
}
|
||||
|
||||
|
||||
@ -2901,7 +2906,7 @@ bool Item_func_case::fix_fields(THD *thd, Item **ref)
|
||||
|
||||
void Item_func_case::agg_str_lengths(Item* arg)
|
||||
{
|
||||
set_if_bigger(max_length, arg->max_length);
|
||||
fix_char_length(max(max_char_length(), arg->max_char_length()));
|
||||
set_if_bigger(decimals, arg->decimals);
|
||||
unsigned_flag= unsigned_flag && arg->unsigned_flag;
|
||||
}
|
||||
@ -3129,9 +3134,10 @@ void Item_func_coalesce::fix_length_and_dec()
|
||||
agg_result_type(&hybrid_type, args, arg_count);
|
||||
switch (hybrid_type) {
|
||||
case STRING_RESULT:
|
||||
count_only_length();
|
||||
decimals= NOT_FIXED_DEC;
|
||||
agg_arg_charsets_for_string_result(collation, args, arg_count);
|
||||
if (agg_arg_charsets_for_string_result(collation, args, arg_count))
|
||||
return;
|
||||
count_only_length();
|
||||
break;
|
||||
case DECIMAL_RESULT:
|
||||
count_decimal_length();
|
||||
|
@ -564,8 +564,9 @@ void Item_func::count_decimal_length()
|
||||
set_if_smaller(unsigned_flag, args[i]->unsigned_flag);
|
||||
}
|
||||
int precision= min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
|
||||
max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
|
||||
unsigned_flag);
|
||||
fix_char_length(my_decimal_precision_to_length_no_truncation(precision,
|
||||
decimals,
|
||||
unsigned_flag));
|
||||
}
|
||||
|
||||
|
||||
@ -575,13 +576,14 @@ void Item_func::count_decimal_length()
|
||||
|
||||
void Item_func::count_only_length()
|
||||
{
|
||||
max_length= 0;
|
||||
uint32 char_length= 0;
|
||||
unsigned_flag= 0;
|
||||
for (uint i=0 ; i < arg_count ; i++)
|
||||
{
|
||||
set_if_bigger(max_length, args[i]->max_length);
|
||||
set_if_bigger(char_length, args[i]->max_char_length());
|
||||
set_if_bigger(unsigned_flag, args[i]->unsigned_flag);
|
||||
}
|
||||
fix_char_length(char_length);
|
||||
}
|
||||
|
||||
|
||||
|
@ -605,27 +605,15 @@ null:
|
||||
|
||||
void Item_func_concat::fix_length_and_dec()
|
||||
{
|
||||
ulonglong max_result_length= 0;
|
||||
ulonglong char_length= 0;
|
||||
|
||||
if (agg_arg_charsets_for_string_result(collation, args, arg_count))
|
||||
return;
|
||||
|
||||
for (uint i=0 ; i < arg_count ; i++)
|
||||
{
|
||||
if (args[i]->collation.collation->mbmaxlen != collation.collation->mbmaxlen)
|
||||
max_result_length+= (args[i]->max_length /
|
||||
args[i]->collation.collation->mbmaxlen) *
|
||||
collation.collation->mbmaxlen;
|
||||
else
|
||||
max_result_length+= args[i]->max_length;
|
||||
}
|
||||
char_length+= args[i]->max_char_length();
|
||||
|
||||
if (max_result_length >= MAX_BLOB_WIDTH)
|
||||
{
|
||||
max_result_length= MAX_BLOB_WIDTH;
|
||||
maybe_null= 1;
|
||||
}
|
||||
max_length= (ulong) max_result_length;
|
||||
fix_char_length_ulonglong(char_length);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -962,7 +950,7 @@ null:
|
||||
|
||||
void Item_func_concat_ws::fix_length_and_dec()
|
||||
{
|
||||
ulonglong max_result_length;
|
||||
ulonglong char_length;
|
||||
|
||||
if (agg_arg_charsets_for_string_result(collation, args, arg_count))
|
||||
return;
|
||||
@ -972,16 +960,11 @@ void Item_func_concat_ws::fix_length_and_dec()
|
||||
it is done on parser level in sql_yacc.yy
|
||||
so, (arg_count - 2) is safe here.
|
||||
*/
|
||||
max_result_length= (ulonglong) args[0]->max_length * (arg_count - 2);
|
||||
char_length= (ulonglong) args[0]->max_char_length() * (arg_count - 2);
|
||||
for (uint i=1 ; i < arg_count ; i++)
|
||||
max_result_length+=args[i]->max_length;
|
||||
char_length+= args[i]->max_char_length();
|
||||
|
||||
if (max_result_length >= MAX_BLOB_WIDTH)
|
||||
{
|
||||
max_result_length= MAX_BLOB_WIDTH;
|
||||
maybe_null= 1;
|
||||
}
|
||||
max_length= (ulong) max_result_length;
|
||||
fix_char_length_ulonglong(char_length);
|
||||
}
|
||||
|
||||
|
||||
@ -1036,6 +1019,7 @@ String *Item_func_reverse::val_str(String *str)
|
||||
void Item_func_reverse::fix_length_and_dec()
|
||||
{
|
||||
agg_arg_charsets_for_string_result(collation, args, 1);
|
||||
DBUG_ASSERT(collation.collation != NULL);
|
||||
fix_char_length(args[0]->max_char_length());
|
||||
}
|
||||
|
||||
@ -1165,22 +1149,17 @@ null:
|
||||
|
||||
void Item_func_replace::fix_length_and_dec()
|
||||
{
|
||||
ulonglong max_result_length= args[0]->max_length;
|
||||
int diff=(int) (args[2]->max_length - args[1]->max_length);
|
||||
if (diff > 0 && args[1]->max_length)
|
||||
ulonglong char_length= (ulonglong) args[0]->max_char_length();
|
||||
int diff=(int) (args[2]->max_char_length() - args[1]->max_char_length());
|
||||
if (diff > 0 && args[1]->max_char_length())
|
||||
{ // Calculate of maxreplaces
|
||||
ulonglong max_substrs= max_result_length/args[1]->max_length;
|
||||
max_result_length+= max_substrs * (uint) diff;
|
||||
ulonglong max_substrs= char_length / args[1]->max_char_length();
|
||||
char_length+= max_substrs * (uint) diff;
|
||||
}
|
||||
if (max_result_length >= MAX_BLOB_WIDTH)
|
||||
{
|
||||
max_result_length= MAX_BLOB_WIDTH;
|
||||
maybe_null= 1;
|
||||
}
|
||||
max_length= (ulong) max_result_length;
|
||||
|
||||
|
||||
if (agg_arg_charsets_for_comparison(collation, args, 3))
|
||||
return;
|
||||
fix_char_length_ulonglong(char_length);
|
||||
}
|
||||
|
||||
|
||||
@ -1235,19 +1214,14 @@ null:
|
||||
|
||||
void Item_func_insert::fix_length_and_dec()
|
||||
{
|
||||
ulonglong max_result_length;
|
||||
ulonglong char_length;
|
||||
|
||||
// Handle character set for args[0] and args[3].
|
||||
if (agg_arg_charsets_for_string_result(collation, args, 2, 3))
|
||||
return;
|
||||
max_result_length= ((ulonglong) args[0]->max_length+
|
||||
(ulonglong) args[3]->max_length);
|
||||
if (max_result_length >= MAX_BLOB_WIDTH)
|
||||
{
|
||||
max_result_length= MAX_BLOB_WIDTH;
|
||||
maybe_null= 1;
|
||||
}
|
||||
max_length= (ulong) max_result_length;
|
||||
char_length= ((ulonglong) args[0]->max_char_length() +
|
||||
(ulonglong) args[3]->max_char_length());
|
||||
fix_char_length_ulonglong(char_length);
|
||||
}
|
||||
|
||||
|
||||
@ -1287,17 +1261,19 @@ String *Item_str_conv::val_str(String *str)
|
||||
void Item_func_lcase::fix_length_and_dec()
|
||||
{
|
||||
agg_arg_charsets_for_string_result(collation, args, 1);
|
||||
DBUG_ASSERT(collation.collation != NULL);
|
||||
multiply= collation.collation->casedn_multiply;
|
||||
converter= collation.collation->cset->casedn;
|
||||
max_length= args[0]->max_length * multiply;
|
||||
fix_char_length_ulonglong((ulonglong) args[0]->max_char_length() * multiply);
|
||||
}
|
||||
|
||||
void Item_func_ucase::fix_length_and_dec()
|
||||
{
|
||||
agg_arg_charsets_for_string_result(collation, args, 1);
|
||||
DBUG_ASSERT(collation.collation != NULL);
|
||||
multiply= collation.collation->caseup_multiply;
|
||||
converter= collation.collation->cset->caseup;
|
||||
max_length= args[0]->max_length * multiply;
|
||||
fix_char_length_ulonglong((ulonglong) args[0]->max_char_length() * multiply);
|
||||
}
|
||||
|
||||
|
||||
@ -1328,21 +1304,23 @@ String *Item_func_left::val_str(String *str)
|
||||
|
||||
void Item_str_func::left_right_max_length()
|
||||
{
|
||||
max_length=args[0]->max_length;
|
||||
uint32 char_length= args[0]->max_char_length();
|
||||
if (args[1]->const_item())
|
||||
{
|
||||
int length=(int) args[1]->val_int()*collation.collation->mbmaxlen;
|
||||
int length= (int) args[1]->val_int();
|
||||
if (length <= 0)
|
||||
max_length=0;
|
||||
char_length=0;
|
||||
else
|
||||
set_if_smaller(max_length,(uint) length);
|
||||
set_if_smaller(char_length, (uint) length);
|
||||
}
|
||||
fix_char_length(char_length);
|
||||
}
|
||||
|
||||
|
||||
void Item_func_left::fix_length_and_dec()
|
||||
{
|
||||
agg_arg_charsets_for_string_result(collation, args, 1);
|
||||
DBUG_ASSERT(collation.collation != NULL);
|
||||
left_right_max_length();
|
||||
}
|
||||
|
||||
@ -1376,6 +1354,7 @@ String *Item_func_right::val_str(String *str)
|
||||
void Item_func_right::fix_length_and_dec()
|
||||
{
|
||||
agg_arg_charsets_for_string_result(collation, args, 1);
|
||||
DBUG_ASSERT(collation.collation != NULL);
|
||||
left_right_max_length();
|
||||
}
|
||||
|
||||
@ -1432,6 +1411,7 @@ void Item_func_substr::fix_length_and_dec()
|
||||
max_length=args[0]->max_length;
|
||||
|
||||
agg_arg_charsets_for_string_result(collation, args, 1);
|
||||
DBUG_ASSERT(collation.collation != NULL);
|
||||
if (args[1]->const_item())
|
||||
{
|
||||
int32 start= (int32) args[1]->val_int();
|
||||
@ -1454,10 +1434,9 @@ void Item_func_substr::fix_length_and_dec()
|
||||
|
||||
void Item_func_substr_index::fix_length_and_dec()
|
||||
{
|
||||
max_length= args[0]->max_length;
|
||||
|
||||
if (agg_arg_charsets_for_comparison(collation, args, 2))
|
||||
return;
|
||||
fix_char_length(args[0]->max_char_length());
|
||||
}
|
||||
|
||||
|
||||
@ -1783,10 +1762,10 @@ String *Item_func_trim::val_str(String *str)
|
||||
|
||||
void Item_func_trim::fix_length_and_dec()
|
||||
{
|
||||
max_length= args[0]->max_length;
|
||||
if (arg_count == 1)
|
||||
{
|
||||
agg_arg_charsets_for_string_result(collation, args, 1);
|
||||
DBUG_ASSERT(collation.collation != NULL);
|
||||
remove.set_charset(collation.collation);
|
||||
remove.set_ascii(" ",1);
|
||||
}
|
||||
@ -1797,6 +1776,7 @@ void Item_func_trim::fix_length_and_dec()
|
||||
if (agg_arg_charsets_for_comparison(collation, &args[1], 2, -1))
|
||||
return;
|
||||
}
|
||||
fix_char_length(args[0]->max_char_length());
|
||||
}
|
||||
|
||||
void Item_func_trim::print(String *str, enum_query_type query_type)
|
||||
@ -2072,9 +2052,11 @@ bool Item_func_current_user::fix_fields(THD *thd, Item **ref)
|
||||
|
||||
void Item_func_soundex::fix_length_and_dec()
|
||||
{
|
||||
uint32 char_length= args[0]->max_char_length();
|
||||
agg_arg_charsets_for_string_result(collation, args, 1);
|
||||
max_length=args[0]->max_length;
|
||||
set_if_bigger(max_length, 4 * collation.collation->mbminlen);
|
||||
DBUG_ASSERT(collation.collation != NULL);
|
||||
set_if_bigger(char_length, 4);
|
||||
fix_char_length(char_length);
|
||||
tmp_value.set_charset(collation.collation);
|
||||
}
|
||||
|
||||
@ -2251,11 +2233,10 @@ MY_LOCALE *Item_func_format::get_locale(Item *item)
|
||||
|
||||
void Item_func_format::fix_length_and_dec()
|
||||
{
|
||||
uint char_length= args[0]->max_length/args[0]->collation.collation->mbmaxlen;
|
||||
uint max_sep_count= char_length/3 + (decimals ? 1 : 0) + /*sign*/1;
|
||||
uint32 char_length= args[0]->max_char_length();
|
||||
uint32 max_sep_count= (char_length / 3) + (decimals ? 1 : 0) + /*sign*/1;
|
||||
collation.set(default_charset());
|
||||
max_length= (char_length + max_sep_count + decimals) *
|
||||
collation.collation->mbmaxlen;
|
||||
fix_char_length(char_length + max_sep_count + decimals);
|
||||
if (arg_count == 3)
|
||||
locale= args[2]->basic_const_item() ? get_locale(args[2]) : NULL;
|
||||
else
|
||||
@ -2375,7 +2356,7 @@ void Item_func_format::print(String *str, enum_query_type query_type)
|
||||
|
||||
void Item_func_elt::fix_length_and_dec()
|
||||
{
|
||||
max_length=0;
|
||||
uint32 char_length= 0;
|
||||
decimals=0;
|
||||
|
||||
if (agg_arg_charsets_for_string_result(collation, args + 1, arg_count - 1))
|
||||
@ -2383,9 +2364,10 @@ void Item_func_elt::fix_length_and_dec()
|
||||
|
||||
for (uint i= 1 ; i < arg_count ; i++)
|
||||
{
|
||||
set_if_bigger(max_length,args[i]->max_length);
|
||||
set_if_bigger(char_length, args[i]->max_char_length());
|
||||
set_if_bigger(decimals,args[i]->decimals);
|
||||
}
|
||||
fix_char_length(char_length);
|
||||
maybe_null=1; // NULL if wrong first arg
|
||||
}
|
||||
|
||||
@ -2443,14 +2425,14 @@ void Item_func_make_set::split_sum_func(THD *thd, Item **ref_pointer_array,
|
||||
|
||||
void Item_func_make_set::fix_length_and_dec()
|
||||
{
|
||||
max_length=arg_count-1;
|
||||
uint32 char_length= arg_count - 1; /* Separators */
|
||||
|
||||
if (agg_arg_charsets_for_string_result(collation, args, arg_count))
|
||||
return;
|
||||
|
||||
for (uint i=0 ; i < arg_count ; i++)
|
||||
max_length+=args[i]->max_length;
|
||||
|
||||
char_length+= args[i]->max_char_length();
|
||||
fix_char_length(char_length);
|
||||
used_tables_cache|= item->used_tables();
|
||||
not_null_tables_cache&= item->not_null_tables();
|
||||
const_item_cache&= item->const_item();
|
||||
@ -2616,6 +2598,7 @@ inline String* alloc_buffer(String *res,String *str,String *tmp_value,
|
||||
void Item_func_repeat::fix_length_and_dec()
|
||||
{
|
||||
agg_arg_charsets_for_string_result(collation, args, 1);
|
||||
DBUG_ASSERT(collation.collation != NULL);
|
||||
if (args[1]->const_item())
|
||||
{
|
||||
/* must be longlong to avoid truncation */
|
||||
@ -2626,13 +2609,8 @@ void Item_func_repeat::fix_length_and_dec()
|
||||
if (count > INT_MAX32)
|
||||
count= INT_MAX32;
|
||||
|
||||
ulonglong max_result_length= (ulonglong) args[0]->max_length * count;
|
||||
if (max_result_length >= MAX_BLOB_WIDTH)
|
||||
{
|
||||
max_result_length= MAX_BLOB_WIDTH;
|
||||
maybe_null= 1;
|
||||
}
|
||||
max_length= (ulong) max_result_length;
|
||||
ulonglong char_length= (ulonglong) args[0]->max_char_length() * count;
|
||||
fix_char_length_ulonglong(char_length);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2703,26 +2681,13 @@ void Item_func_rpad::fix_length_and_dec()
|
||||
return;
|
||||
if (args[1]->const_item())
|
||||
{
|
||||
ulonglong length= 0;
|
||||
|
||||
if (collation.collation->mbmaxlen > 0)
|
||||
{
|
||||
ulonglong temp= (ulonglong) args[1]->val_int();
|
||||
|
||||
/* Assumes that the maximum length of a String is < INT_MAX32. */
|
||||
/* Set here so that rest of code sees out-of-bound value as such. */
|
||||
if (temp > INT_MAX32)
|
||||
temp = INT_MAX32;
|
||||
|
||||
length= temp * collation.collation->mbmaxlen;
|
||||
}
|
||||
|
||||
if (length >= MAX_BLOB_WIDTH)
|
||||
{
|
||||
length= MAX_BLOB_WIDTH;
|
||||
maybe_null= 1;
|
||||
}
|
||||
max_length= (ulong) length;
|
||||
ulonglong char_length= (ulonglong) args[1]->val_int();
|
||||
DBUG_ASSERT(collation.collation->mbmaxlen > 0);
|
||||
/* Assumes that the maximum length of a String is < INT_MAX32. */
|
||||
/* Set here so that rest of code sees out-of-bound value as such. */
|
||||
if (char_length > INT_MAX32)
|
||||
char_length= INT_MAX32;
|
||||
fix_char_length_ulonglong(char_length);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2806,26 +2771,13 @@ void Item_func_lpad::fix_length_and_dec()
|
||||
|
||||
if (args[1]->const_item())
|
||||
{
|
||||
ulonglong length= 0;
|
||||
|
||||
if (collation.collation->mbmaxlen > 0)
|
||||
{
|
||||
ulonglong temp= (ulonglong) args[1]->val_int();
|
||||
|
||||
/* Assumes that the maximum length of a String is < INT_MAX32. */
|
||||
/* Set here so that rest of code sees out-of-bound value as such. */
|
||||
if (temp > INT_MAX32)
|
||||
temp= INT_MAX32;
|
||||
|
||||
length= temp * collation.collation->mbmaxlen;
|
||||
}
|
||||
|
||||
if (length >= MAX_BLOB_WIDTH)
|
||||
{
|
||||
length= MAX_BLOB_WIDTH;
|
||||
maybe_null= 1;
|
||||
}
|
||||
max_length= (ulong) length;
|
||||
ulonglong char_length= (ulonglong) args[1]->val_int();
|
||||
DBUG_ASSERT(collation.collation->mbmaxlen > 0);
|
||||
/* Assumes that the maximum length of a String is < INT_MAX32. */
|
||||
/* Set here so that rest of code sees out-of-bound value as such. */
|
||||
if (char_length > INT_MAX32)
|
||||
char_length= INT_MAX32;
|
||||
fix_char_length_ulonglong(char_length);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -3309,8 +3261,8 @@ String* Item_func_export_set::val_str(String* str)
|
||||
|
||||
void Item_func_export_set::fix_length_and_dec()
|
||||
{
|
||||
uint length=max(args[1]->max_length,args[2]->max_length);
|
||||
uint sep_length=(arg_count > 3 ? args[3]->max_length : 1);
|
||||
uint32 length= max(args[1]->max_char_length(), args[2]->max_char_length());
|
||||
uint32 sep_length= (arg_count > 3 ? args[3]->max_char_length() : 1);
|
||||
|
||||
if (agg_arg_charsets_for_string_result(collation,
|
||||
args + 1, min(4, arg_count) - 1))
|
||||
|
Loading…
x
Reference in New Issue
Block a user