mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Bug#31384 DATE_ADD() and DATE_SUB() return binary data
Problem: DATE_ADD() is a hybrid function and can return DATE, DATETIME or VARCHAR data type depending on arguments. In case of VARCHAR data type, DATE_ADD() reported "binary" character set, which was wrong. Fix: make DATE_ADD() return @character_set_connection in VARCHAR context. @ mysql-test/include/ctype_numconv.inc Adding tests @ mysql-test/r/ctype_binary.result Adding tests @ mysql-test/r/ctype_cp1251.result Adding tests @ mysql-test/r/ctype_latin1.result Adding tests @ mysql-test/r/ctype_ucs.result Adding tests @ mysql-test/r/ctype_utf8.result Adding tests @ sql/item_strfunc.cc - Moving code from Item_str_ascii_func::val_str() to Item_str_func::val_str_from_val_str_ascii(), as this code needs to be shared by Item_date_add_interval. - Adding str2 parameter to be used as a buffer, instead of using private ascii_buf member. @ sql/item_strfunc.h - Moving code from Item_str_ascii_func::val_str() to Item_str_func::val_str_from_val_str_ascii() - Removing "String *val_str_convert_from_ascii(String *str, String *ascii_buf)" prototype as it was neither used nor declared. @ sql/item_timefunc.h - Overwriting parent's charset_for_protocol() method, becase we need to behave differenlty in VARCHAR and DATE/DATETYPE context. - Adding ascii_buf for conversion. - Adding val_str_ascii() prototype. - Adding val_str() which uses newly added Item_str_func::val_str_from_val_str_ascii(), passing ascii_buf as a conversion buffer.
This commit is contained in:
@ -1737,6 +1737,32 @@ EXPLAIN SELECT * FROM t1 WHERE date_column BETWEEN '2010-09-01' AND '2010-10-01'
|
||||
DROP TABLE t1;
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # Bug #31384 DATE_ADD() and DATE_SUB() return binary data
|
||||
--echo #
|
||||
SELECT @@collation_connection, @@character_set_results;
|
||||
CREATE TABLE t1 AS
|
||||
SELECT
|
||||
DATE_SUB('2007-08-03', INTERVAL 1 MINUTE) AS field_str1,
|
||||
DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE) AS field1_str2,
|
||||
DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY) AS field_date,
|
||||
DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE) AS field_datetime;
|
||||
SHOW CREATE TABLE t1;
|
||||
DROP TABLE t1;
|
||||
--enable_metadata
|
||||
SELECT
|
||||
DATE_SUB('2007-08-03', INTERVAL 1 DAY) AS field_str1,
|
||||
DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE) AS field1_str2,
|
||||
DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY) AS field_date,
|
||||
DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE) AS field_datetime;
|
||||
--disable_metadata
|
||||
SELECT
|
||||
HEX(DATE_SUB('2007-08-03', INTERVAL 1 MINUTE)) AS field_str1,
|
||||
HEX(DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE)) AS field1_str2,
|
||||
HEX(DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY)) AS field_date,
|
||||
HEX(DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE)) AS field_datetime;
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # Bug#52159 returning time type from function and empty left join causes debug assertion
|
||||
--echo #
|
||||
|
Reference in New Issue
Block a user