List:Commits« Previous MessageNext Message »
From:Georgi Kodinov Date:November 19 2008 4:14pm
Subject:bzr commit into mysql-5.0-bugteam branch (kgeorge:2717) Bug#39920
View as plain text  
#At file:///home/kgeorge/mysql/work/B39920-5.0-bugteam/

 2717 Georgi Kodinov	2008-11-19
      Bug #39920: MySQL cannot deal with Leap Second expression in string literal.
      
      Updated MySQL to react correctly on the 2008's UTC leap second.
      MySQL functions that return the OS current time, like e.g. CURDATE(), NOW() etc
      will return :59:59 instead of :59:60.
      As a result the reader will receive :59:59 for two consecutive seconds during the
      leap second.
modified:
  sql/tztime.cc
  sql/tztime.h

per-file messages:
  sql/tztime.cc
    Bug #39920: adjust 2008's leap second to :59
  sql/tztime.h
    Bug #39920: adjust 2008's leap second to :59
=== modified file 'sql/tztime.cc'
--- a/sql/tztime.cc	2008-04-03 17:19:32 +0000
+++ b/sql/tztime.cc	2008-11-19 15:14:01 +0000
@@ -1073,6 +1073,7 @@ Time_zone_system::gmt_sec_to_TIME(MYSQL_
   localtime_r(&tmp_t, &tmp_tm);
   localtime_to_TIME(tmp, &tmp_tm);
   tmp->time_type= MYSQL_TIMESTAMP_DATETIME;
+  adjust_leap_second(tmp);
 }
 
 
@@ -1157,6 +1158,7 @@ Time_zone_utc::gmt_sec_to_TIME(MYSQL_TIM
   gmtime_r(&tmp_t, &tmp_tm);
   localtime_to_TIME(tmp, &tmp_tm);
   tmp->time_type= MYSQL_TIMESTAMP_DATETIME;
+  adjust_leap_second(tmp);
 }
 
 
@@ -1260,6 +1262,7 @@ void
 Time_zone_db::gmt_sec_to_TIME(MYSQL_TIME *tmp, my_time_t t) const
 {
   ::gmt_sec_to_TIME(tmp, t, tz_info);
+  adjust_leap_second(tmp);
 }
 
 
@@ -1392,6 +1395,7 @@ void
 Time_zone_offset::gmt_sec_to_TIME(MYSQL_TIME *tmp, my_time_t t) const
 {
   sec_to_TIME(tmp, t, offset);
+  adjust_leap_second(tmp);
 }
 
 
@@ -2373,6 +2377,15 @@ Time_zone *my_tz_find_with_opening_tz_ta
   DBUG_RETURN(tz);
 }
 
+
+void Time_zone::adjust_leap_second(MYSQL_TIME *t)
+{
+  if (((t->year == 2008 && t->month == 12 && t->day == 31) ||
+       (t->year == 2009 && t->month == 1 && t->day == 1))
&&
+      t->minute == 59 && (t->second == 60 || t->second == 61))
+    t->second= 59;
+}
+
 #endif /* !defined(TESTTIME) && !defined(TZINFO2SQL) */
 
 

=== modified file 'sql/tztime.h'
--- a/sql/tztime.h	2007-05-16 08:44:36 +0000
+++ b/sql/tztime.h	2008-11-19 15:14:01 +0000
@@ -55,6 +55,9 @@ public:
     allocated on MEM_ROOT and should not require destruction.
   */
   virtual ~Time_zone() {};
+
+protected:
+  static void adjust_leap_second(MYSQL_TIME *t);
 };
 
 extern Time_zone * my_tz_UTC;

Thread
bzr commit into mysql-5.0-bugteam branch (kgeorge:2717) Bug#39920Georgi Kodinov19 Nov