From e2b03cd3b54f39e09bf20eef77effe1b53813f29 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Wed, 19 Apr 2017 05:20:19 +0400 Subject: MDEV-12514 Split Item_temporal_func::fix_length_and_dec() + MDEV-12515 This patch implements MDEV-12514 according to the task descriptions. It automatically fixes: MDEV-12515 Wrong value when storing DATE_ADD() and ADDTIME() to a numeric field Additionally: a. Moves Item_func::set_attributes_temporal() to Type_str_attributes::fix_attributes_temporal(), which is a more proper place and name for it. b. Continues replacing calls for: set_handler_by_field_type(MYSQL_TYPE_XXX) to corresponding: set_handler(&type_handler_xxx) which is faster. Note, we should eventually get rid of almost all set_handler_by_field_type(). c. Makes type_handler_string, type_handler_time2, type_handler_newdate, type_handler_datetime2 public. (all built-in handlers will become public eventually) d. Removing Item_temporal_func::sql_mode, as it was not used. --- mysql-test/t/func_time.test | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'mysql-test/t/func_time.test') diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index 6e0169d97ca..e8d1d4e79e3 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -1817,3 +1817,35 @@ DROP TABLE t1,t2; --echo # --echo # End of 10.1 tests --echo # + + +--echo # +--echo # Start of 10.3 tests +--echo # + +--echo # +--echo # MDEV-12515 Wrong value when storing DATE_ADD() and ADDTIME() to a numeric field +--echo # + +SET sql_mode=''; + +CREATE TABLE t1 AS SELECT + DATE_ADD('2001-01-01',INTERVAL 1 DAY) AS c1, + ADDTIME('10:20:30',1) AS c2; +SHOW CREATE TABLE t1; +SELECT * FROM t1; +DROP TABLE t1; + +CREATE TABLE t2 (c INT); +INSERT INTO t2 SELECT DATE_ADD('2001-01-01',INTERVAL 1 DAY); +INSERT INTO t2 VALUES ('2001-01-02'); +SELECT * FROM t2; +DROP TABLE t2; + +CREATE TABLE t2 (a INT); +INSERT INTO t2 VALUES (ADDTIME('10:20:30',1)); +INSERT INTO t2 VALUES ('10:20:31'); +SELECT * FROM t2; +DROP TABLE t2; + +SET sql_mode=DEFAULT; -- cgit v1.2.1