diff options
author | unknown <dlenev@mysql.com> | 2004-01-30 19:15:11 +0300 |
---|---|---|
committer | unknown <dlenev@mysql.com> | 2004-01-30 19:15:11 +0300 |
commit | ef55f2dcdbc79c78aa37e6646ac2aef62c23e7d3 (patch) | |
tree | 4ec74f20317ff0acdaa2c6e6917f33e72d11f720 /sql/field.cc | |
parent | e95a3e3ce8aa653c111c5c9ab28905750874dc60 (diff) | |
download | mariadb-git-ef55f2dcdbc79c78aa37e6646ac2aef62c23e7d3.tar.gz |
Fix for bug #2523 '"func_time" test fails on QNX'.
Moved all range checks for TIMESTAMP value to my_gmt_sec().
Also fixed check of upper boundary of TIMESTAMP range (which
also now will catch datetime values which are too small for
TIMESTAMP in case if time_t is unsigned).
mysql-test/r/timezone.result:
Added test which checks if TIMESTAMP range is checked
correctly (current time zone is honoured and both upper
and lower bounds of TIMESTAMP range are checked).
mysql-test/t/timezone.test:
Added test which checks if TIMESTAMP range is checked
correctly (current time zone is honoured and both upper
and lower bounds of TIMESTAMP range are checked).
sql/field.cc:
Check if datetime value is in TIMESTAMP range has moved to
my_gmt_sec() function.
sql/mysql_priv.h:
Added more constants for checking if datetime is in allowed
range for TIMESTAMP.
sql/time.cc:
Check if datetime value is in TIMESTAMP range has moved to
my_gmt_sec() function. Fixed check of its return value
to catch overflows in both directions and also overflows in
case of unsigned time_t.
Diffstat (limited to 'sql/field.cc')
-rw-r--r-- | sql/field.cc | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/sql/field.cc b/sql/field.cc index 687c22bb69b..ac3ebb4bfc7 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -2583,22 +2583,18 @@ static longlong fix_datetime(longlong nr, TIME *time_res) void Field_timestamp::store(longlong nr) { TIME l_time; - time_t timestamp; + time_t timestamp= 0; if ((nr= fix_datetime(nr, &l_time))) { long not_used; - if (l_time.year >= TIMESTAMP_MAX_YEAR || l_time.year < 1900+YY_PART_YEAR-1) - { + timestamp= my_gmt_sec(&l_time, ¬_used); + + if (!timestamp) current_thd->cuted_fields++; - timestamp=0; - } - else - timestamp=my_gmt_sec(&l_time, ¬_used); } - else - timestamp=0; + #ifdef WORDS_BIGENDIAN if (table->db_low_byte_first) { |