Commit 54d0ec57 authored by Sergei Golubchik's avatar Sergei Golubchik

fix for cast of negative numbers to datetime

parent 93a16a17
......@@ -329,7 +329,7 @@ cast(cast(1.1 as double) as datetime)
0000-00-00 00:00:01
select cast(cast(-1.1 as double) as datetime);
cast(cast(-1.1 as double) as datetime)
0000-00-00 00:00:01
NULL
explain extended select cast(10 as double(5,2));
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
......
......@@ -271,10 +271,10 @@ static bool number_to_time_with_warn(bool neg, ulonglong nr, ulong sec_part,
else
{
f_type= MYSQL_TYPE_DATETIME;
res= number_to_datetime(nr, sec_part, ltime, fuzzydate, &was_cut);
res= neg ? -1 : number_to_datetime(nr, sec_part, ltime, fuzzydate, &was_cut);
}
if ((was_cut && !(fuzzydate & TIME_FUZZY_DATE)) || res < 0)
if (res < 0 || (was_cut && !(fuzzydate & TIME_FUZZY_DATE)))
{
make_truncated_value_warning(current_thd,
MYSQL_ERROR::WARN_LEVEL_WARN, str,
......
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