diff options
author | Alexander Barkov <bar@mariadb.com> | 2018-11-07 14:42:36 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.com> | 2018-11-07 14:42:36 +0400 |
commit | a5e2a14ef360a04242ec78864358f5d7eccdd741 (patch) | |
tree | c01bbbb14ddde5034f869584500592f6ce8f1d24 | |
parent | 41e68e8e5b3ce89c61f19bf072b59cf13a6fdc16 (diff) | |
download | mariadb-git-a5e2a14ef360a04242ec78864358f5d7eccdd741.tar.gz |
MDEV-17634 Regression: TIME(0)=TIME('z') returns NULL vs 1
-rw-r--r-- | mysql-test/main/type_time.result | 23 | ||||
-rw-r--r-- | mysql-test/main/type_time.test | 12 | ||||
-rw-r--r-- | sql/item_timefunc.cc | 6 | ||||
-rw-r--r-- | sql/sql_type.h | 4 |
4 files changed, 42 insertions, 3 deletions
diff --git a/mysql-test/main/type_time.result b/mysql-test/main/type_time.result index 8a4f977d2d9..e530298db23 100644 --- a/mysql-test/main/type_time.result +++ b/mysql-test/main/type_time.result @@ -2094,5 +2094,28 @@ SELECT TIME(99991231235957), TIME(99991231235958), TIME(99991231235959); TIME(99991231235957) TIME(99991231235958) TIME(99991231235959) 23:59:57 23:59:58 23:59:59 # +# MDEV-17634 Regression: TIME(0)=TIME('z') returns NULL vs 1 +# +SELECT +TIMESTAMP(0)=TIMESTAMP('z') AS ts, +DATE(0)=DATE('z') AS d, +TIME(0)=TIME('z') AS t; +ts d t +1 1 1 +Warnings: +Warning 1292 Incorrect datetime value: 'z' +Warning 1292 Incorrect datetime value: 'z' +Warning 1292 Truncated incorrect time value: 'z' +SELECT +TIMESTAMP(0)=TIMESTAMP('') AS ts, +DATE(0)=DATE('') AS d, +TIME(0)=TIME('') AS t; +ts d t +1 1 1 +Warnings: +Warning 1292 Incorrect datetime value: '' +Warning 1292 Incorrect datetime value: '' +Warning 1292 Truncated incorrect time value: '' +# # End of 10.4 tests # diff --git a/mysql-test/main/type_time.test b/mysql-test/main/type_time.test index f57773de2ef..1fe3d8ab0ee 100644 --- a/mysql-test/main/type_time.test +++ b/mysql-test/main/type_time.test @@ -1366,6 +1366,18 @@ SET optimizer_use_condition_selectivity=DEFAULT; --echo # SELECT TIME(99991231235957), TIME(99991231235958), TIME(99991231235959); +--echo # +--echo # MDEV-17634 Regression: TIME(0)=TIME('z') returns NULL vs 1 +--echo # +SELECT + TIMESTAMP(0)=TIMESTAMP('z') AS ts, + DATE(0)=DATE('z') AS d, + TIME(0)=TIME('z') AS t; + +SELECT + TIMESTAMP(0)=TIMESTAMP('') AS ts, + DATE(0)=DATE('') AS d, + TIME(0)=TIME('') AS t; --echo # --echo # End of 10.4 tests diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index f12c8e12668..2da92f971d1 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -2416,10 +2416,10 @@ void Item_char_typecast::fix_length_and_dec_internal(CHARSET_INFO *from_cs) } -bool Item_time_typecast::get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) +bool Item_time_typecast::get_date(THD *thd, MYSQL_TIME *to, date_mode_t mode) { - Time *tm= new(ltime) Time(thd, args[0], Time::Options_for_cast(), - MY_MIN(decimals, TIME_SECOND_PART_DIGITS)); + Time *tm= new(to) Time(thd, args[0], Time::Options_for_cast(mode), + MY_MIN(decimals, TIME_SECOND_PART_DIGITS)); return (null_value= !tm->is_valid_time()); } diff --git a/sql/sql_type.h b/sql/sql_type.h index fd86102c504..45c98f7b7d3 100644 --- a/sql/sql_type.h +++ b/sql/sql_type.h @@ -790,6 +790,10 @@ public: Options_for_cast() :Options(flags_for_get_date(), DATETIME_TO_TIME_YYYYMMDD_TRUNCATE) { } + Options_for_cast(date_mode_t mode) + :Options(flags_for_get_date() | (mode & TIME_FUZZY_DATES), + DATETIME_TO_TIME_YYYYMMDD_TRUNCATE) + { } }; private: bool is_valid_value_slow() const |