Skip to content

Commit 48c11d4

Browse files
author
Alexander Barkov
committed
MDEV-13202 Assertion `ltime->neg == 0' failed in date_to_datetime
1 parent 4a35e76 commit 48c11d4

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

mysql-test/r/func_time.result

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2878,5 +2878,29 @@ NULL
28782878
Warnings:
28792879
Warning 1441 Datetime function: datetime field overflow
28802880
#
2881+
# MDEV-13202 Assertion `ltime->neg == 0' failed in date_to_datetime
2882+
#
2883+
CREATE TABLE t1 (i INT, d DATE);
2884+
INSERT INTO t1 VALUES (1, '1970-01-01');
2885+
SELECT MAX(NULLIF(i,1)) FROM t1 ORDER BY DATE_SUB(d,INTERVAL 17300000 HOUR);
2886+
MAX(NULLIF(i,1))
2887+
NULL
2888+
Warnings:
2889+
Warning 1441 Datetime function: datetime field overflow
2890+
DROP TABLE t1;
2891+
CREATE TABLE t1 (i INT, d DATE);
2892+
INSERT INTO t1 VALUES (1, '1970-01-01');
2893+
SELECT CONCAT(DATE_SUB(d, INTERVAL 17300000 HOUR)) FROM t1;
2894+
CONCAT(DATE_SUB(d, INTERVAL 17300000 HOUR))
2895+
NULL
2896+
Warnings:
2897+
Warning 1441 Datetime function: datetime field overflow
2898+
DROP TABLE t1;
2899+
SELECT CONCAT(DATE_SUB(TIMESTAMP'1970-01-01 00:00:00', INTERVAL 17300000 HOUR));
2900+
CONCAT(DATE_SUB(TIMESTAMP'1970-01-01 00:00:00', INTERVAL 17300000 HOUR))
2901+
NULL
2902+
Warnings:
2903+
Warning 1441 Datetime function: datetime field overflow
2904+
#
28812905
# End of 10.0 tests
28822906
#

mysql-test/t/func_time.test

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1758,6 +1758,22 @@ SELECT ADDDATE(DATE'0000-01-01', INTERVAL '3652423:0:0:315569433559' DAY_SECOND)
17581758
SELECT ADDDATE(DATE'0000-01-01', INTERVAL '0:87658175:0:315569433559' DAY_SECOND);
17591759
SELECT ADDDATE(DATE'0000-01-01', INTERVAL '0:0:5259490559:315569433599' DAY_SECOND);
17601760

1761+
--echo #
1762+
--echo # MDEV-13202 Assertion `ltime->neg == 0' failed in date_to_datetime
1763+
--echo #
1764+
1765+
CREATE TABLE t1 (i INT, d DATE);
1766+
INSERT INTO t1 VALUES (1, '1970-01-01');
1767+
SELECT MAX(NULLIF(i,1)) FROM t1 ORDER BY DATE_SUB(d,INTERVAL 17300000 HOUR);
1768+
DROP TABLE t1;
1769+
1770+
CREATE TABLE t1 (i INT, d DATE);
1771+
INSERT INTO t1 VALUES (1, '1970-01-01');
1772+
SELECT CONCAT(DATE_SUB(d, INTERVAL 17300000 HOUR)) FROM t1;
1773+
DROP TABLE t1;
1774+
1775+
SELECT CONCAT(DATE_SUB(TIMESTAMP'1970-01-01 00:00:00', INTERVAL 17300000 HOUR));
1776+
17611777

17621778
--echo #
17631779
--echo # End of 10.0 tests

sql/sql_time.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -960,6 +960,8 @@ bool date_add_interval(MYSQL_TIME *ltime, interval_type int_type,
960960
ltime->day= 0;
961961
return 0;
962962
}
963+
else if (ltime->neg)
964+
goto invalid_date;
963965

964966
if (int_type != INTERVAL_DAY)
965967
ltime->time_type= MYSQL_TIMESTAMP_DATETIME; // Return full date

0 commit comments

Comments
 (0)