Commit 607fc153 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-31302 Assertion `mon > 0 && mon < 13' failed in my_time_t...

MDEV-31302 Assertion `mon > 0 && mon < 13' failed in my_time_t sec_since_epoch(int, int, int, int, int, int)

The code erroneously called sec_since_epoch() for dates with zeros,
e.g. '2024-00-01'.
Fixi: adding a test that the date does not have zeros before
calling TIME_to_native().
parent 9ac8172a
......@@ -6425,5 +6425,16 @@ Warning 1292 Truncated incorrect time value: '8390000'
Warning 1292 Truncated incorrect time value: '8390000'
SET @@timestamp= DEFAULT;
#
# MDEV-31302 Assertion `mon > 0 && mon < 13' failed in my_time_t sec_since_epoch(int, int, int, int, int, int)
#
CREATE TABLE t1 (a DATE);
SET @@time_zone='+1:00';
INSERT INTO t1 VALUES ('2024-00-01');
SELECT UNIX_TIMESTAMP(MAX(a)) AS a FROM t1;
a
NULL
SET @@time_zone=DEFAULT;
DROP TABLE t1;
#
# End of 10.5 tests
#
......@@ -3262,6 +3262,17 @@ SELECT
SET @@timestamp= DEFAULT;
--echo #
--echo # MDEV-31302 Assertion `mon > 0 && mon < 13' failed in my_time_t sec_since_epoch(int, int, int, int, int, int)
--echo #
CREATE TABLE t1 (a DATE);
SET @@time_zone='+1:00';
INSERT INTO t1 VALUES ('2024-00-01');
SELECT UNIX_TIMESTAMP(MAX(a)) AS a FROM t1;
SET @@time_zone=DEFAULT;
DROP TABLE t1;
--echo #
--echo # End of 10.5 tests
--echo #
......@@ -9182,6 +9182,7 @@ Type_handler_timestamp_common::Item_val_native_with_conversion(THD *thd,
Datetime dt(thd, item, Datetime::Options(TIME_NO_ZERO_IN_DATE, thd));
return
!dt.is_valid_datetime() ||
dt.check_date(TIME_NO_ZERO_IN_DATE | TIME_NO_ZERO_DATE) ||
TIME_to_native(thd, dt.get_mysql_time(), to, item->datetime_precision(thd));
}
......
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