diff options
Diffstat (limited to 'mysql-test')
-rw-r--r-- | mysql-test/r/func_in.result | 13 | ||||
-rw-r--r-- | mysql-test/r/func_time.result | 32 | ||||
-rw-r--r-- | mysql-test/t/func_in.test | 14 | ||||
-rw-r--r-- | mysql-test/t/func_time.test | 30 |
4 files changed, 89 insertions, 0 deletions
diff --git a/mysql-test/r/func_in.result b/mysql-test/r/func_in.result index 692806c7cac..65313148bf8 100644 --- a/mysql-test/r/func_in.result +++ b/mysql-test/r/func_in.result @@ -896,3 +896,16 @@ EXECUTE stmt; a b DEALLOCATE PREPARE stmt; DROP TABLE t1; +# +# MDEV-15340 Wrong result HOUR(case_expression_with_time_and_datetime) +# +SELECT +TIME'00:00:00'='' AS c1_true, +TIME'00:00:00' IN ('', TIME'10:20:30') AS c2_true, +TIME'00:00:00' NOT IN ('', TIME'10:20:30') AS c3_false; +c1_true c2_true c3_false +1 1 0 +Warnings: +Warning 1292 Truncated incorrect time value: '' +Warning 1292 Truncated incorrect time value: '' +Warning 1292 Truncated incorrect time value: '' diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index e710f3ac438..53f61f6644f 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -3351,3 +3351,35 @@ SELECT CONVERT_TZ(1, ROW(1,1), 1); ERROR HY000: Illegal parameter data type row for operation 'convert_tz' SELECT CONVERT_TZ(1, 1, ROW(1,1)); ERROR HY000: Illegal parameter data type row for operation 'convert_tz' +# +# MDEV-15340 Wrong result HOUR(case_expression_with_time_and_datetime) +# +SET TIMESTAMP=UNIX_TIMESTAMP('2018-02-17 01:02:03'); +SELECT +COALESCE(TIME'800:00:00', NOW()) AS c, +HOUR(COALESCE(TIME'800:00:00',NOW())) AS hc; +c hc +2018-03-22 08:00:00 8 +SELECT +CASE WHEN TRUE THEN TIME'800:00:00' ELSE NOW() END AS c, +HOUR(CASE WHEN TRUE THEN TIME'800:00:00' ELSE NOW() END) AS hc; +c hc +2018-03-22 08:00:00 8 +SELECT +IFNULL(TIME'800:00:00', NOW()) AS c, +HOUR(IFNULL(TIME'800:00:00', NOW())) AS hc; +c hc +2018-03-22 08:00:00 8 +SELECT +IF(TRUE,TIME'800:00:00', NOW()) AS c, +HOUR(IF(TRUE,TIME'800:00:00', NOW())) AS hc; +c hc +2018-03-22 08:00:00 8 +SELECT +ADDTIME(TIME'10:20:30', TIMESTAMP'2001-01-01 00:00:00') AS c1, +ADDTIME(TIME'10:20:30', COALESCE(TIMESTAMP'2001-01-01 00:00:00',TIMESTAMP'2001-01-01 00:00:00')) AS c2, +ADDTIME(TIME'10:20:30', DATE'2001-01-01') AS c3, +ADDTIME(TIME'10:20:30', COALESCE(DATE'2001-01-01',TIMESTAMP'2001-01-01 00:00:00')) AS c4; +c1 c2 c3 c4 +NULL NULL NULL NULL +SET TIMESTAMP=DEFAULT; diff --git a/mysql-test/t/func_in.test b/mysql-test/t/func_in.test index 8f6062fd2c2..b99fad159c2 100644 --- a/mysql-test/t/func_in.test +++ b/mysql-test/t/func_in.test @@ -676,3 +676,17 @@ EXECUTE stmt; EXECUTE stmt; DEALLOCATE PREPARE stmt; DROP TABLE t1; + +--echo # +--echo # MDEV-15340 Wrong result HOUR(case_expression_with_time_and_datetime) +--echo # + +# This is to make sure that TIME_FUZZY_DATE is always passed to str_to_time(), +# so empty strings are compared as TIME'00:00:00' all around the code: +# when using Arg_comparator (e.g. in binary comparison operators), and +# when not using it (e.g. in IN predicate). + +SELECT + TIME'00:00:00'='' AS c1_true, + TIME'00:00:00' IN ('', TIME'10:20:30') AS c2_true, + TIME'00:00:00' NOT IN ('', TIME'10:20:30') AS c3_false; diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index 09c13598cfd..0066d4a434b 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -1945,3 +1945,33 @@ SELECT CONVERT_TZ(ROW(1,1),1,1); SELECT CONVERT_TZ(1, ROW(1,1), 1); --error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION SELECT CONVERT_TZ(1, 1, ROW(1,1)); + + +--echo # +--echo # MDEV-15340 Wrong result HOUR(case_expression_with_time_and_datetime) +--echo # + +SET TIMESTAMP=UNIX_TIMESTAMP('2018-02-17 01:02:03'); +SELECT + COALESCE(TIME'800:00:00', NOW()) AS c, + HOUR(COALESCE(TIME'800:00:00',NOW())) AS hc; + +SELECT + CASE WHEN TRUE THEN TIME'800:00:00' ELSE NOW() END AS c, + HOUR(CASE WHEN TRUE THEN TIME'800:00:00' ELSE NOW() END) AS hc; + +SELECT + IFNULL(TIME'800:00:00', NOW()) AS c, + HOUR(IFNULL(TIME'800:00:00', NOW())) AS hc; + +SELECT + IF(TRUE,TIME'800:00:00', NOW()) AS c, + HOUR(IF(TRUE,TIME'800:00:00', NOW())) AS hc; + +SELECT + ADDTIME(TIME'10:20:30', TIMESTAMP'2001-01-01 00:00:00') AS c1, + ADDTIME(TIME'10:20:30', COALESCE(TIMESTAMP'2001-01-01 00:00:00',TIMESTAMP'2001-01-01 00:00:00')) AS c2, + ADDTIME(TIME'10:20:30', DATE'2001-01-01') AS c3, + ADDTIME(TIME'10:20:30', COALESCE(DATE'2001-01-01',TIMESTAMP'2001-01-01 00:00:00')) AS c4; + +SET TIMESTAMP=DEFAULT; |