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-common | |
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-common')
-rw-r--r-- | sql-common/my_time.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/sql-common/my_time.c b/sql-common/my_time.c index 1f058f89bb7..17d031168c6 100644 --- a/sql-common/my_time.c +++ b/sql-common/my_time.c @@ -1226,7 +1226,7 @@ longlong number_to_datetime(longlong nr, ulong sec_part, MYSQL_TIME *time_res, *was_cut= 0; time_res->time_type=MYSQL_TIMESTAMP_DATE; - if (nr == 0 || nr >= 10000101000000LL || sec_part) + if (nr == 0 || nr >= 10000101000000LL) { time_res->time_type=MYSQL_TIMESTAMP_DATETIME; goto ok; @@ -1284,7 +1284,11 @@ longlong number_to_datetime(longlong nr, ulong sec_part, MYSQL_TIME *time_res, time_res->minute <= 59 && time_res->second <= 59 && sec_part <= TIME_MAX_SECOND_PART && !check_date(time_res, nr || sec_part, flags, was_cut)) + { + if (time_res->time_type == MYSQL_TIMESTAMP_DATE && sec_part != 0) + *was_cut= MYSQL_TIME_NOTE_TRUNCATED; return nr; + } /* Don't want to have was_cut get set if NO_ZERO_DATE was violated. */ if (nr || !(flags & TIME_NO_ZERO_DATE)) @@ -1318,10 +1322,10 @@ longlong number_to_datetime(longlong nr, ulong sec_part, MYSQL_TIME *time_res, 0 time value is valid, but was possibly truncated -1 time value is invalid */ -int number_to_time(my_bool neg, longlong nr, ulong sec_part, +int number_to_time(my_bool neg, ulonglong nr, ulong sec_part, MYSQL_TIME *ltime, int *was_cut) { - if (nr > 9999999 && neg == 0) + if (nr > 9999999 && nr < 99991231235959ULL && neg == 0) { if (number_to_datetime(nr, sec_part, ltime, TIME_INVALID_DATES, was_cut) < 0) @@ -1329,7 +1333,7 @@ int number_to_time(my_bool neg, longlong nr, ulong sec_part, ltime->year= ltime->month= ltime->day= 0; ltime->time_type= MYSQL_TIMESTAMP_TIME; - *was_cut= MYSQL_TIME_WARN_TRUNCATED; + *was_cut= MYSQL_TIME_NOTE_TRUNCATED; return 0; } |