diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index f71b27d1a2a..995b5f702e2 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -2416,3 +2416,18 @@ c1 c2 9923-03-10 22:47:10.0 NULL Warnings: Warning 1292 Truncated incorrect DECIMAL value: '2000000000000000000.0' +# +# MDEV-5750 Assertion `ltime->year == 0' fails on a query with EXTRACT DAY_MINUTE and TIME column +# +CREATE TABLE t1 ( d DATE, t TIME ); +INSERT INTO t1 VALUES ('2008-12-05','22:34:09'),('2005-03-27','14:26:02'); +SELECT EXTRACT(DAY_MINUTE FROM GREATEST(t,d)), GREATEST(t,d) FROM t1; +EXTRACT(DAY_MINUTE FROM GREATEST(t,d)) GREATEST(t,d) +342259 838:59:59 +342259 838:59:59 +Warnings: +Warning 1292 Truncated incorrect time value: '9336:00:00' +Warning 1292 Truncated incorrect time value: '9336:00:00' +Warning 1292 Truncated incorrect time value: '2952:00:00' +Warning 1292 Truncated incorrect time value: '2952:00:00' +DROP TABLE t1; diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index d30300f90d3..56c96bb5748 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -1472,3 +1472,12 @@ DROP TABLE t1; --echo # MDEV-6099 Bad results for DATE_ADD(.., INTERVAL 2000000000000000000.0 SECOND) --echo # SELECT DATE_ADD('2001-01-01 10:20:30',INTERVAL 250000000000.0 SECOND) AS c1, DATE_ADD('2001-01-01 10:20:30',INTERVAL 2000000000000000000.0 SECOND) AS c2; + + +--echo # +--echo # MDEV-5750 Assertion `ltime->year == 0' fails on a query with EXTRACT DAY_MINUTE and TIME column +--echo # +CREATE TABLE t1 ( d DATE, t TIME ); +INSERT INTO t1 VALUES ('2008-12-05','22:34:09'),('2005-03-27','14:26:02'); +SELECT EXTRACT(DAY_MINUTE FROM GREATEST(t,d)), GREATEST(t,d) FROM t1; +DROP TABLE t1; diff --git a/sql/item_func.cc b/sql/item_func.cc index bf45b41b2d9..c00dde874fc 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2960,7 +2960,7 @@ bool Item_func_min_max::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date) { ltime->time_type= MYSQL_TIMESTAMP_TIME; ltime->hour+= (ltime->month * 32 + ltime->day) * 24; - ltime->month= ltime->day= 0; + ltime->year= ltime->month= ltime->day= 0; if (adjust_time_range_with_warn(ltime, min(decimals, TIME_SECOND_PART_DIGITS))) return (null_value= true);