Commit 80708da1 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-5750 Assertion `ltime->year == 0' fails on a query with EXTRACT DAY_MINUTE and TIME column

Item_func_min_max::get_date() did not clear ltime->year when returning a TIME value.
parent 30b007a1
......@@ -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;
......@@ -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;
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment