diff options
author | Alexander Barkov <bar@mariadb.org> | 2014-06-04 20:32:57 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.org> | 2014-06-04 20:32:57 +0400 |
commit | 661daf16f11ffa879ffb005008b6e73f6744e0ad (patch) | |
tree | c0f1facac5d17e590dc2aa12353d2f513c007bdf /sql/time.cc | |
parent | a1975dd2c106180ab16836631e6797cff5b4e396 (diff) | |
download | mariadb-git-661daf16f11ffa879ffb005008b6e73f6744e0ad.tar.gz |
MDEV-4858 Wrong results for a huge unsigned value inserted into a TIME column
MDEV-6099 Bad results for DATE_ADD(.., INTERVAL 2000000000000000000.0 SECOND)
MDEV-6097 Inconsistent results for CAST(int,decimal,double AS DATETIME)
MDEV-6100 No warning on CAST(9000000 AS TIME)
Diffstat (limited to 'sql/time.cc')
-rw-r--r-- | sql/time.cc | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/sql/time.cc b/sql/time.cc index b91ddad6cd4..ab36db40bfe 100644 --- a/sql/time.cc +++ b/sql/time.cc @@ -291,20 +291,23 @@ static bool number_to_time_with_warn(bool neg, ulonglong nr, ulong sec_part, int was_cut; longlong res; enum_field_types f_type; + bool have_warnings; if (fuzzydate & TIME_TIME_ONLY) { fuzzydate= TIME_TIME_ONLY; // clear other flags f_type= MYSQL_TYPE_TIME; res= number_to_time(neg, nr, sec_part, ltime, &was_cut); + have_warnings= MYSQL_TIME_WARN_HAVE_WARNINGS(was_cut); } else { f_type= MYSQL_TYPE_DATETIME; res= neg ? -1 : number_to_datetime(nr, sec_part, ltime, fuzzydate, &was_cut); + have_warnings= was_cut && (fuzzydate & TIME_NO_ZERO_IN_DATE); } - if (res < 0 || (was_cut && (fuzzydate & TIME_NO_ZERO_IN_DATE))) + if (res < 0 || have_warnings) { make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, str, @@ -347,12 +350,11 @@ bool decimal_to_datetime_with_warn(const my_decimal *value, MYSQL_TIME *ltime, } -bool int_to_datetime_with_warn(longlong value, MYSQL_TIME *ltime, +bool int_to_datetime_with_warn(bool neg, ulonglong value, MYSQL_TIME *ltime, ulong fuzzydate, const char *field_name) { - const Lazy_string_num str(value); - bool neg= value < 0; - return number_to_time_with_warn(neg, neg ? -value : value, 0, ltime, + const Lazy_string_num str(neg ? -value : value, !neg); + return number_to_time_with_warn(neg, value, 0, ltime, fuzzydate, &str, field_name); } |