diff options
author | dlenev@mysql.com <> | 2004-01-30 19:15:11 +0300 |
---|---|---|
committer | dlenev@mysql.com <> | 2004-01-30 19:15:11 +0300 |
commit | 4578f22271955c3688d175e247fc3d73b4a4ff32 (patch) | |
tree | 4ec74f20317ff0acdaa2c6e6917f33e72d11f720 /sql/time.cc | |
parent | eb218f3c711cc7fcc3d5f57b7473df5ec3564762 (diff) | |
download | mariadb-git-4578f22271955c3688d175e247fc3d73b4a4ff32.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).
Diffstat (limited to 'sql/time.cc')
-rw-r--r-- | sql/time.cc | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/sql/time.cc b/sql/time.cc index 5dc229b1d88..0363d764100 100644 --- a/sql/time.cc +++ b/sql/time.cc @@ -63,6 +63,9 @@ long my_gmt_sec(TIME *t, long *my_timezone) struct tm *l_time,tm_tmp; long diff, current_timezone; + if (t->year > TIMESTAMP_MAX_YEAR || t->year < TIMESTAMP_MIN_YEAR) + return 0; + if (t->hour >= 24) { /* Fix for time-loop */ t->day+=t->hour/24; @@ -125,8 +128,10 @@ long my_gmt_sec(TIME *t, long *my_timezone) tmp-=t->minute*60 + t->second; // Move to previous hour } *my_timezone= current_timezone; - if (tmp < 0 && t->year <= 1900+YY_PART_YEAR) + + if (tmp < TIMESTAMP_MIN_VALUE || tmp > TIMESTAMP_MAX_VALUE) tmp= 0; + return (long) tmp; } /* my_gmt_sec */ @@ -444,15 +449,13 @@ time_t str_to_timestamp(const char *str,uint length) { TIME l_time; long not_used; + time_t timestamp= 0; - if (str_to_TIME(str,length,&l_time,0) == TIMESTAMP_NONE) - return(0); - if (l_time.year >= TIMESTAMP_MAX_YEAR || l_time.year < 1900+YY_PART_YEAR-1) - { + if (str_to_TIME(str,length,&l_time,0) != TIMESTAMP_NONE && + !(timestamp= my_gmt_sec(&l_time, ¬_used))) current_thd->cuted_fields++; - return(0); - } - return(my_gmt_sec(&l_time, ¬_used)); + + return timestamp; } |