summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/func_time.result15
-rw-r--r--mysql-test/t/func_time.test9
-rw-r--r--sql/item_func.cc2
3 files changed, 25 insertions, 1 deletions
diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result
index c52f512aa70..c798414c5e2 100644
--- a/mysql-test/r/func_time.result
+++ b/mysql-test/r/func_time.result
@@ -2389,3 +2389,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 52dbf3471ac..fdf834253af 100644
--- a/mysql-test/t/func_time.test
+++ b/mysql-test/t/func_time.test
@@ -1442,3 +1442,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 fc69fa711c2..8df0564af15 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -2646,7 +2646,7 @@ bool Item_func_min_max::get_date(MYSQL_TIME *ltime, uint 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);