diff options
author | unknown <tsmith@quadxeon.mysql.com> | 2007-03-07 07:21:24 +0100 |
---|---|---|
committer | unknown <tsmith@quadxeon.mysql.com> | 2007-03-07 07:21:24 +0100 |
commit | a69a96e26a06d08d5f1060469c630f6296c64dfc (patch) | |
tree | 3b6fe53494b0d386d485258b18617577fa500e46 /sql/tztime.cc | |
parent | 0ac63815ff77c208b1312427cda72b9680d03709 (diff) | |
parent | 01fc4d068466234ceeea20a0f8ae0e77e36fd90f (diff) | |
download | mariadb-git-a69a96e26a06d08d5f1060469c630f6296c64dfc.tar.gz |
Merge tsmith@bk-internal.mysql.com:/home/bk/mysql-5.1-runtime
into quadxeon.mysql.com:/benchmarks/ext3/TOSAVE/tsmith/bk/maint/mrg0306/51
client/mysqltest.c:
Auto merged
include/my_pthread.h:
Auto merged
mysql-test/mysql-test-run.pl:
Auto merged
mysql-test/r/sp.result:
Auto merged
mysql-test/t/disabled.def:
Auto merged
mysql-test/t/sp.test:
Auto merged
mysys/my_wincond.c:
Auto merged
sql/event_queue.cc:
Auto merged
sql/field.cc:
Auto merged
sql/item_cmpfunc.cc:
Auto merged
sql/item_cmpfunc.h:
Auto merged
sql/log.cc:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/mysqld.cc:
Auto merged
sql/set_var.cc:
Auto merged
sql/sql_class.cc:
Auto merged
sql/sql_class.h:
Auto merged
sql/sql_load.cc:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/sql_trigger.cc:
Auto merged
client/mysql_upgrade.c:
Manual merge; I chose to keep Magnus' changes because they make the code
more simple; always use *only* the option file created by mysql_upgrade.
mysql-test/extra/binlog_tests/ctype_cp932.test:
Manual merge
mysql-test/r/binlog_row_ctype_cp932.result:
Manual merge
mysql-test/r/binlog_stm_ctype_cp932.result:
Manual merge
mysql-test/r/mysqlbinlog.result:
Manual merge
mysql-test/r/rpl_switch_stm_row_mixed.result:
Manual merge
mysql-test/t/mysqlbinlog.test:
Manual merge
mysql-test/t/rpl_switch_stm_row_mixed.test:
Manual merge
Diffstat (limited to 'sql/tztime.cc')
-rw-r--r-- | sql/tztime.cc | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/sql/tztime.cc b/sql/tztime.cc index e236ceb11d7..914c7be46de 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -780,6 +780,8 @@ gmt_sec_to_TIME(TIME *tmp, my_time_t sec_in_utc, const TIME_ZONE_INFO *sp) static my_time_t sec_since_epoch(int year, int mon, int mday, int hour, int min ,int sec) { + /* Guard against my_time_t overflow(on system with 32 bit my_time_t) */ + DBUG_ASSERT(!(year == TIMESTAMP_MAX_YEAR && mon == 1 && mday > 17)); #ifndef WE_WANT_TO_HANDLE_UNORMALIZED_DATES /* It turns out that only whenever month is normalized or unnormalized @@ -960,12 +962,12 @@ TIME_to_gmt_sec(const TIME *t, const TIME_ZONE_INFO *sp, */ if (shift) { - if (local_t > (my_time_t) (TIMESTAMP_MAX_VALUE - shift*86400L + + if (local_t > (my_time_t) (TIMESTAMP_MAX_VALUE - shift * SECS_PER_DAY + sp->revtis[i].rt_offset - saved_seconds)) { DBUG_RETURN(0); /* my_time_t overflow */ } - local_t+= shift*86400L; + local_t+= shift * SECS_PER_DAY; } if (sp->revtis[i].rt_type) @@ -1353,6 +1355,7 @@ my_time_t Time_zone_offset::TIME_to_gmt_sec(const TIME *t, my_bool *in_dst_time_gap) const { my_time_t local_t; + int shift= 0; /* Check timestamp range.we have to do this as calling function relies on @@ -1361,10 +1364,24 @@ Time_zone_offset::TIME_to_gmt_sec(const TIME *t, my_bool *in_dst_time_gap) const if (!validate_timestamp_range(t)) return 0; - local_t= sec_since_epoch(t->year, t->month, t->day, + /* + Do a temporary shift of the boundary dates to avoid + overflow of my_time_t if the time value is near it's + maximum range + */ + if ((t->year == TIMESTAMP_MAX_YEAR) && (t->month == 1) && t->day > 4) + shift= 2; + + local_t= sec_since_epoch(t->year, t->month, (t->day - shift), t->hour, t->minute, t->second) - offset; + if (shift) + { + /* Add back the shifted time */ + local_t+= shift * SECS_PER_DAY; + } + if (local_t >= TIMESTAMP_MIN_VALUE && local_t <= TIMESTAMP_MAX_VALUE) return local_t; |