mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-16971 Assertion `is_valid_value_slow()' failed in Time::adjust_time_range_or_invalidate
The patch for MDEV-16928 added a few new asserts to check that time, date, datetime values are valid and consistent after initialization. One of the new asserts caught an improper initialization in Time::make_from_datetime_with_days_diff() (the former function calc_datetime_days_diff()). If the YYYYMM part is not zero after unpack time we have an out-of-range TIME value.
This commit is contained in:
@ -2064,5 +2064,17 @@ Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where octet_length(coalesce(TIME'00:00:00.0',`test`.`t1`.`a`)) <=> octet_length(coalesce(<cache>(TIME'00:00:00.00'),`test`.`t1`.`a`))
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# MDEV-16971 Assertion `is_valid_value_slow()' failed in Time::adjust_time_range_or_invalidate
|
||||
#
|
||||
SET sql_mode='';
|
||||
CREATE TABLE t1 (d1 date, t1 time, KEY t1 (t1));
|
||||
INSERT INTO t1 VALUES ('1982-12-19','08:16:31'),('1981-04-19','21:52:59'),('1971-06-09','07:15:44'),('2007-08-15','03:55:02'),('1993-06-05','04:17:51'),('2034-07-01','17:31:12'),('1998-08-24','08:09:27'),('1991-01-15','01:14:07'),('2001-02-25','10:41:28'),('1974-06-24','10:21:58'),('1977-04-21','16:38:05'),('1981-12-03','01:24:42'),('1972-06-15','20:19:16'),('1989-08-10','08:53:47'),('2018-05-19','15:06:49'),('1984-01-12','15:56:11'),('2013-01-23','04:16:16'),('2000-06-10','02:06:44'),('1995-01-03','04:51:38');
|
||||
CREATE TABLE t2 (d1 date );
|
||||
INSERT INTO t2 VALUES ('2018-06-01'),('1979-10-25'),('1974-08-22'),('1980-06-17');
|
||||
SELECT * FROM (t1 JOIN t2 ON (t2.d1 = t1.t1)) WHERE (t1.d1 > 70 );
|
||||
d1 t1 d1
|
||||
UPDATE (t1 JOIN t2 ON (t2.d1 = t1.t1)) SET t1.d1 = '2018-07-07' WHERE (t1.d1 > 70 );
|
||||
DROP TABLE t1,t2;
|
||||
#
|
||||
# End of 10.4 tests
|
||||
#
|
||||
|
@ -1339,6 +1339,18 @@ EXECUTE IMMEDIATE 'EXPLAIN EXTENDED SELECT * FROM t1 WHERE LENGTH(COALESCE(TIME'
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-16971 Assertion `is_valid_value_slow()' failed in Time::adjust_time_range_or_invalidate
|
||||
--echo #
|
||||
SET sql_mode='';
|
||||
CREATE TABLE t1 (d1 date, t1 time, KEY t1 (t1));
|
||||
INSERT INTO t1 VALUES ('1982-12-19','08:16:31'),('1981-04-19','21:52:59'),('1971-06-09','07:15:44'),('2007-08-15','03:55:02'),('1993-06-05','04:17:51'),('2034-07-01','17:31:12'),('1998-08-24','08:09:27'),('1991-01-15','01:14:07'),('2001-02-25','10:41:28'),('1974-06-24','10:21:58'),('1977-04-21','16:38:05'),('1981-12-03','01:24:42'),('1972-06-15','20:19:16'),('1989-08-10','08:53:47'),('2018-05-19','15:06:49'),('1984-01-12','15:56:11'),('2013-01-23','04:16:16'),('2000-06-10','02:06:44'),('1995-01-03','04:51:38');
|
||||
CREATE TABLE t2 (d1 date );
|
||||
INSERT INTO t2 VALUES ('2018-06-01'),('1979-10-25'),('1974-08-22'),('1980-06-17');
|
||||
SELECT * FROM (t1 JOIN t2 ON (t2.d1 = t1.t1)) WHERE (t1.d1 > 70 );
|
||||
UPDATE (t1 JOIN t2 ON (t2.d1 = t1.t1)) SET t1.d1 = '2018-07-07' WHERE (t1.d1 > 70 );
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
--echo #
|
||||
--echo # End of 10.4 tests
|
||||
--echo #
|
||||
|
@ -404,6 +404,12 @@ void Time::make_from_datetime_with_days_diff(int *warn, const MYSQL_TIME *from,
|
||||
from->second) * 1000000LL +
|
||||
from->second_part);
|
||||
unpack_time(timediff, this, MYSQL_TIMESTAMP_TIME);
|
||||
if (year || month)
|
||||
{
|
||||
*warn|= MYSQL_TIME_WARN_OUT_OF_RANGE;
|
||||
year= month= day= 0;
|
||||
hour= TIME_MAX_HOUR + 1;
|
||||
}
|
||||
}
|
||||
// The above code can generate TIME values outside of the valid TIME range.
|
||||
adjust_time_range_or_invalidate(warn);
|
||||
|
Reference in New Issue
Block a user