diff options
author | Sergei Golubchik <sergii@pisem.net> | 2014-06-06 00:07:27 +0200 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2014-06-06 00:07:27 +0200 |
commit | e27c338634739ef56a6888e7948e04c0fa0ba677 (patch) | |
tree | ad63ccae614f3dd77509825d1905fd815ef322cb /sql/sql_time.cc | |
parent | 2a5905141a3c509a7c34c3d370fb146dbc1c965f (diff) | |
parent | 6d75570e99fbf070cdbeefdfbcfc94d1c7b3ad1f (diff) | |
download | mariadb-git-e27c338634739ef56a6888e7948e04c0fa0ba677.tar.gz |
5.5.38 merge
Diffstat (limited to 'sql/sql_time.cc')
-rw-r--r-- | sql/sql_time.cc | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/sql/sql_time.cc b/sql/sql_time.cc index c8a2c2daf85..e0b17a918ee 100644 --- a/sql/sql_time.cc +++ b/sql/sql_time.cc @@ -358,20 +358,30 @@ 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); + if (neg) + { + res= -1; + } + else + { + res= 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, Sql_condition::WARN_LEVEL_WARN, str, @@ -414,12 +424,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, ulonglong fuzzydate, const char *field_name) { - const ErrConvInteger str(value); - bool neg= value < 0; - return number_to_time_with_warn(neg, neg ? -value : value, 0, ltime, + const ErrConvInteger str(neg ? -value : value, !neg); + return number_to_time_with_warn(neg, value, 0, ltime, fuzzydate, &str, field_name); } |