Commit a5e2a14e authored by Alexander Barkov's avatar Alexander Barkov

MDEV-17634 Regression: TIME(0)=TIME('z') returns NULL vs 1

parent 41e68e8e
......@@ -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
#
......@@ -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
......
......@@ -2416,9 +2416,9 @@ 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(),
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());
}
......
......@@ -790,6 +790,10 @@ class Time: public Temporal
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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment