From f249d8467ae7fadafc7c52234c403eec3bb769ca Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 22 Mar 2018 15:07:33 +0100 Subject: [PATCH] MDEV-15570 Assertion `Item_cache_temporal::field_type() != MYSQL_TYPE_TIME' failed in Item_cache_temporal::val_datetime_packed remove an assert. TIME value can be used (and cached) in a datetime context --- mysql-test/r/type_temporal_innodb.result | 6 ++++++ mysql-test/t/type_temporal_innodb.test | 8 ++++++++ sql/item.cc | 1 - 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/type_temporal_innodb.result b/mysql-test/r/type_temporal_innodb.result index ce2b3a4e53f..b869822722d 100644 --- a/mysql-test/r/type_temporal_innodb.result +++ b/mysql-test/r/type_temporal_innodb.result @@ -154,3 +154,9 @@ SELECT 1 FROM t1 WHERE (SELECT a FROM t1 group by c) = b; Warnings: Warning 1292 Incorrect datetime value: '' DROP TABLE t1; +CREATE TABLE t1 (d DATE) ENGINE=InnoDB; +INSERT INTO t1 VALUES ('2012-12-21'); +SELECT * FROM t1 WHERE LEAST( UTC_TIME(), d ); +d +2012-12-21 +DROP TABLE t1; diff --git a/mysql-test/t/type_temporal_innodb.test b/mysql-test/t/type_temporal_innodb.test index 1ab68961eaa..81f2f586c51 100644 --- a/mysql-test/t/type_temporal_innodb.test +++ b/mysql-test/t/type_temporal_innodb.test @@ -58,3 +58,11 @@ SELECT * FROM t1 IGNORE KEY (b) WHERE b=''; SELECT * FROM t1 WHERE a=b; SELECT 1 FROM t1 WHERE (SELECT a FROM t1 group by c) = b; DROP TABLE t1; + +# +# MDEV-15570 Assertion `Item_cache_temporal::field_type() != MYSQL_TYPE_TIME' failed in Item_cache_temporal::val_datetime_packed +# +CREATE TABLE t1 (d DATE) ENGINE=InnoDB; +INSERT INTO t1 VALUES ('2012-12-21'); +SELECT * FROM t1 WHERE LEAST( UTC_TIME(), d ); +DROP TABLE t1; diff --git a/sql/item.cc b/sql/item.cc index dead75f548c..007b4f4bd54 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -9707,7 +9707,6 @@ Item_cache_temporal::Item_cache_temporal(THD *thd, longlong Item_cache_temporal::val_datetime_packed() { DBUG_ASSERT(fixed == 1); - DBUG_ASSERT(Item_cache_temporal::field_type() != MYSQL_TYPE_TIME); if ((!value_cached && !cache_value()) || null_value) { null_value= TRUE;