diff options
author | unknown <monty@mysql.com> | 2004-11-12 17:44:17 +0200 |
---|---|---|
committer | unknown <monty@mysql.com> | 2004-11-12 17:44:17 +0200 |
commit | 55ae2e788088067fe539020c5162f4cfd96dfe43 (patch) | |
tree | ed1b1c23390d48668f06ceff0a8f851e16568f90 /sql-common/my_time.c | |
parent | 44070705ea958c57faa486e7f22ca5fb1ada095c (diff) | |
download | mariadb-git-55ae2e788088067fe539020c5162f4cfd96dfe43.tar.gz |
After merge fixes
client/mysqldump.c:
Merge with 4.0 (and reordering of options)
client/mysqltest.c:
Added DB as a user variable
myisam/mi_check.c:
Trivial cleanup
mysql-test/r/grant.result:
Move test to be in same order as in 4.0
mysql-test/r/mix_innodb_myisam_binlog.result:
Updated results
mysql-test/r/ps_1general.result:
Updated tests to work after privilege fixes
mysql-test/r/timezone3.result:
Updated results to 4.1
mysql-test/t/ps_1general.test:
Updated tests to work after privilege fixes
sql-common/my_time.c:
Applied sub-second patch from 4.0
sql/sql_acl.cc:
More debugging
Diffstat (limited to 'sql-common/my_time.c')
-rw-r--r-- | sql-common/my_time.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/sql-common/my_time.c b/sql-common/my_time.c index 6c020466e1e..d1a36a75a5a 100644 --- a/sql-common/my_time.c +++ b/sql-common/my_time.c @@ -664,6 +664,10 @@ my_system_gmt_sec(const MYSQL_TIME *t, long *my_timezone, bool *in_dst_time_gap) I couldn't come up with a better way to get a repeatable result :( We can't use mktime() as it's buggy on many platforms and not thread safe. + + Note: this code assumes that our time_t estimation is not too far away + from real value (we assume that localtime_r(tmp) will return something + within 24 hrs from t) which is probably true for all current time zones. */ tmp=(time_t) (((calc_daynr((uint) t->year,(uint) t->month,(uint) t->day) - (long) days_at_timestart)*86400L + (long) t->hour*3600L + @@ -676,7 +680,8 @@ my_system_gmt_sec(const MYSQL_TIME *t, long *my_timezone, bool *in_dst_time_gap) for (loop=0; loop < 2 && (t->hour != (uint) l_time->tm_hour || - t->minute != (uint) l_time->tm_min); + t->minute != (uint) l_time->tm_min || + t->second != (uint) l_time->tm_sec); loop++) { /* One check should be enough ? */ /* Get difference in days */ @@ -686,15 +691,22 @@ my_system_gmt_sec(const MYSQL_TIME *t, long *my_timezone, bool *in_dst_time_gap) else if (days > 1) days= -1; diff=(3600L*(long) (days*24+((int) t->hour - (int) l_time->tm_hour)) + - (long) (60*((int) t->minute - (int) l_time->tm_min))); + (long) (60*((int) t->minute - (int) l_time->tm_min)) + + (long) ((int) t->second - (int) l_time->tm_sec)); current_timezone+= diff+3600; /* Compensate for -3600 above */ tmp+= (time_t) diff; localtime_r(&tmp,&tm_tmp); l_time=&tm_tmp; } /* - Fix that if we are in the not existing daylight saving time hour - we move the start of the next real hour + Fix that if we are in the non existing daylight saving time hour + we move the start of the next real hour. + + This code doesn't handle such exotical thing as time-gaps whose length + is more than one hour or non-integer (latter can theoretically happen + if one of seconds will be removed due leap correction, or because of + general time correction like it happened for Africa/Monrovia time zone + in year 1972). */ if (loop == 2 && t->hour != (uint) l_time->tm_hour) { @@ -704,7 +716,8 @@ my_system_gmt_sec(const MYSQL_TIME *t, long *my_timezone, bool *in_dst_time_gap) else if (days > 1) days= -1; diff=(3600L*(long) (days*24+((int) t->hour - (int) l_time->tm_hour))+ - (long) (60*((int) t->minute - (int) l_time->tm_min))); + (long) (60*((int) t->minute - (int) l_time->tm_min)) + + (long) ((int) t->second - (int) l_time->tm_sec)); if (diff == 3600) tmp+=3600 - t->minute*60 - t->second; /* Move to next hour */ else if (diff == -3600) |