diff options
-rw-r--r-- | mysql-test/main/type_time.result | 12 | ||||
-rw-r--r-- | mysql-test/main/type_time.test | 12 | ||||
-rw-r--r-- | sql/sql_type.cc | 6 |
3 files changed, 30 insertions, 0 deletions
diff --git a/mysql-test/main/type_time.result b/mysql-test/main/type_time.result index 8f50d49d4b9..6d26ee1fdaa 100644 --- a/mysql-test/main/type_time.result +++ b/mysql-test/main/type_time.result @@ -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 # diff --git a/mysql-test/main/type_time.test b/mysql-test/main/type_time.test index f4a1a474046..6a3f6984583 100644 --- a/mysql-test/main/type_time.test +++ b/mysql-test/main/type_time.test @@ -1340,5 +1340,17 @@ 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 # diff --git a/sql/sql_type.cc b/sql/sql_type.cc index e8dbf663df6..7746ce76004 100644 --- a/sql/sql_type.cc +++ b/sql/sql_type.cc @@ -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); |