diff options
-rw-r--r-- | mysql-test/r/type_date.result | 11 | ||||
-rw-r--r-- | mysql-test/r/type_datetime.result | 11 | ||||
-rw-r--r-- | mysql-test/r/type_time.result | 11 | ||||
-rw-r--r-- | mysql-test/t/type_date.test | 9 | ||||
-rw-r--r-- | mysql-test/t/type_datetime.test | 8 | ||||
-rw-r--r-- | mysql-test/t/type_time.test | 8 | ||||
-rw-r--r-- | sql/item.cc | 18 | ||||
-rw-r--r-- | sql/item.h | 3 |
8 files changed, 79 insertions, 0 deletions
diff --git a/mysql-test/r/type_date.result b/mysql-test/r/type_date.result index aa9a8193d56..155918ccbb7 100644 --- a/mysql-test/r/type_date.result +++ b/mysql-test/r/type_date.result @@ -748,5 +748,16 @@ Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` DROP TABLE t1; SET timestamp=DEFAULT; # +# MDEV-8795 Equal expression propagation does not work for temporal literals +# +CREATE TABLE t1 (a DATE); +INSERT INTO t1 VALUES ('2001-01-01'),('2001-01-02'); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE COALESCE(a)=DATE'2001-01-01' AND COALESCE(a)>=DATE'2001-01-01'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where (coalesce(`test`.`t1`.`a`) = DATE'2001-01-01') +DROP TABLE t1; +# # End of 10.1 tests # diff --git a/mysql-test/r/type_datetime.result b/mysql-test/r/type_datetime.result index 9b01f3b00ef..011855ca2d1 100644 --- a/mysql-test/r/type_datetime.result +++ b/mysql-test/r/type_datetime.result @@ -1085,5 +1085,16 @@ Warnings: Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = TIME'00:00:00') and (<cache>(length(TIMESTAMP'2001-01-01 00:00:00')) = (40 + rand()))) DROP TABLE t1; # +# MDEV-8795 Equal expression propagation does not work for temporal literals +# +CREATE TABLE t1 (a DATETIME); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00'),('2001-01-02 00:00:00'); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE COALESCE(a)=TIMESTAMP'2001-01-01 00:00:00' AND COALESCE(a)>=TIMESTAMP'2001-01-01 00:00:00'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where (coalesce(`test`.`t1`.`a`) = TIMESTAMP'2001-01-01 00:00:00') +DROP TABLE t1; +# # End of 10.1 tests # diff --git a/mysql-test/r/type_time.result b/mysql-test/r/type_time.result index 7f748275809..979fb785db2 100644 --- a/mysql-test/r/type_time.result +++ b/mysql-test/r/type_time.result @@ -958,5 +958,16 @@ Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` DROP TABLE t1; SET timestamp=DEFAULT; # +# MDEV-8795 Equal expression propagation does not work for temporal literals +# +CREATE TABLE t1 (a TIME); +INSERT INTO t1 VALUES ('00:00:01'),('00:00:02'); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE COALESCE(a)=TIME'00:00:01' AND COALESCE(a)>=TIME'00:00:01'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where (coalesce(`test`.`t1`.`a`) = TIME'00:00:01') +DROP TABLE t1; +# # End of 10.1 tests # diff --git a/mysql-test/t/type_date.test b/mysql-test/t/type_date.test index 1b8cd89b998..56036c4c7ba 100644 --- a/mysql-test/t/type_date.test +++ b/mysql-test/t/type_date.test @@ -532,5 +532,14 @@ DROP TABLE t1; SET timestamp=DEFAULT; --echo # +--echo # MDEV-8795 Equal expression propagation does not work for temporal literals +--echo # +CREATE TABLE t1 (a DATE); +INSERT INTO t1 VALUES ('2001-01-01'),('2001-01-02'); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE COALESCE(a)=DATE'2001-01-01' AND COALESCE(a)>=DATE'2001-01-01'; +DROP TABLE t1; + + +--echo # --echo # End of 10.1 tests --echo # diff --git a/mysql-test/t/type_datetime.test b/mysql-test/t/type_datetime.test index 33e4d3f05fd..b417c298837 100644 --- a/mysql-test/t/type_datetime.test +++ b/mysql-test/t/type_datetime.test @@ -656,5 +656,13 @@ SET sql_mode=DEFAULT; --source include/equal_fields_propagation_datetime.inc --echo # +--echo # MDEV-8795 Equal expression propagation does not work for temporal literals +--echo # +CREATE TABLE t1 (a DATETIME); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00'),('2001-01-02 00:00:00'); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE COALESCE(a)=TIMESTAMP'2001-01-01 00:00:00' AND COALESCE(a)>=TIMESTAMP'2001-01-01 00:00:00'; +DROP TABLE t1; + +--echo # --echo # End of 10.1 tests --echo # diff --git a/mysql-test/t/type_time.test b/mysql-test/t/type_time.test index f655ebdb87c..2c196727055 100644 --- a/mysql-test/t/type_time.test +++ b/mysql-test/t/type_time.test @@ -577,5 +577,13 @@ DROP TABLE t1; SET timestamp=DEFAULT; --echo # +--echo # MDEV-8795 Equal expression propagation does not work for temporal literals +--echo # +CREATE TABLE t1 (a TIME); +INSERT INTO t1 VALUES ('00:00:01'),('00:00:02'); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE COALESCE(a)=TIME'00:00:01' AND COALESCE(a)>=TIME'00:00:01'; +DROP TABLE t1; + +--echo # --echo # End of 10.1 tests --echo # diff --git a/sql/item.cc b/sql/item.cc index 3182f9d6a47..6ae6fc87bf7 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -6430,6 +6430,12 @@ void Item_date_literal::print(String *str, enum_query_type query_type) } +Item *Item_date_literal::clone_item(THD *thd) +{ + return new (thd->mem_root) Item_date_literal(thd, &cached_time); +} + + bool Item_date_literal::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date) { DBUG_ASSERT(fixed); @@ -6450,6 +6456,12 @@ void Item_datetime_literal::print(String *str, enum_query_type query_type) } +Item *Item_datetime_literal::clone_item(THD *thd) +{ + return new (thd->mem_root) Item_datetime_literal(thd, &cached_time, decimals); +} + + bool Item_datetime_literal::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date) { DBUG_ASSERT(fixed); @@ -6470,6 +6482,12 @@ void Item_time_literal::print(String *str, enum_query_type query_type) } +Item *Item_time_literal::clone_item(THD *thd) +{ + return new (thd->mem_root) Item_time_literal(thd, &cached_time, decimals); +} + + bool Item_time_literal::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date) { DBUG_ASSERT(fixed); diff --git a/sql/item.h b/sql/item.h index d3dbc543e82..6a4e5481b36 100644 --- a/sql/item.h +++ b/sql/item.h @@ -3348,6 +3348,7 @@ public: } enum_field_types field_type() const { return MYSQL_TYPE_DATE; } void print(String *str, enum_query_type query_type); + Item *clone_item(THD *thd); bool get_date(MYSQL_TIME *res, ulonglong fuzzy_date); }; @@ -3366,6 +3367,7 @@ public: } enum_field_types field_type() const { return MYSQL_TYPE_TIME; } void print(String *str, enum_query_type query_type); + Item *clone_item(THD *thd); bool get_date(MYSQL_TIME *res, ulonglong fuzzy_date); }; @@ -3386,6 +3388,7 @@ public: } enum_field_types field_type() const { return MYSQL_TYPE_DATETIME; } void print(String *str, enum_query_type query_type); + Item *clone_item(THD *thd); bool get_date(MYSQL_TIME *res, ulonglong fuzzy_date); }; |