summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorGeorgi Kodinov <kgeorge@mysql.com>2008-12-01 17:22:16 +0200
committerGeorgi Kodinov <kgeorge@mysql.com>2008-12-01 17:22:16 +0200
commit6afd8123a3265feea6ca946556f7499eaefe2808 (patch)
tree780668255bbeeacd8effb883f816b3322b1b28a4 /sql
parent9a2d729bb370b0f5dead11e2f774eea66735580a (diff)
parentc419185fed8a7e5feab99c29f01654028ac93866 (diff)
downloadmariadb-git-6afd8123a3265feea6ca946556f7499eaefe2808.tar.gz
merged bug 39920 and 5.1-main to 5.1-bugteam
Diffstat (limited to 'sql')
-rw-r--r--sql/tztime.cc21
-rw-r--r--sql/tztime.h3
2 files changed, 24 insertions, 0 deletions
diff --git a/sql/tztime.cc b/sql/tztime.cc
index 1028cfb7c1b..53870915973 100644
--- a/sql/tztime.cc
+++ b/sql/tztime.cc
@@ -1072,6 +1072,7 @@ Time_zone_system::gmt_sec_to_TIME(MYSQL_TIME *tmp, my_time_t t) const
localtime_r(&tmp_t, &tmp_tm);
localtime_to_TIME(tmp, &tmp_tm);
tmp->time_type= MYSQL_TIMESTAMP_DATETIME;
+ adjust_leap_second(tmp);
}
@@ -1156,6 +1157,7 @@ Time_zone_utc::gmt_sec_to_TIME(MYSQL_TIME *tmp, my_time_t t) const
gmtime_r(&tmp_t, &tmp_tm);
localtime_to_TIME(tmp, &tmp_tm);
tmp->time_type= MYSQL_TIMESTAMP_DATETIME;
+ adjust_leap_second(tmp);
}
@@ -1259,6 +1261,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);
}
@@ -2279,6 +2282,24 @@ my_tz_find(THD *thd, const String *name)
}
+/**
+ Convert leap seconds into non-leap
+
+ This function will convert the leap seconds added by the OS to
+ non-leap seconds, e.g. 23:59:59, 23:59:60 -> 23:59:59, 00:00:01 ...
+ This check is not checking for years on purpose : although it's not a
+ complete check this way it doesn't require looking (and having installed)
+ the leap seconds table.
+
+ @param[in,out] broken down time structure as filled in by the OS
+*/
+
+void Time_zone::adjust_leap_second(MYSQL_TIME *t)
+{
+ if (t->second == 60 || t->second == 61)
+ t->second= 59;
+}
+
#endif /* !defined(TESTTIME) && !defined(TZINFO2SQL) */
diff --git a/sql/tztime.h b/sql/tztime.h
index 3d77a3eefa3..9bf103519c4 100644
--- a/sql/tztime.h
+++ b/sql/tztime.h
@@ -55,6 +55,9 @@ public:
allocated on MEM_ROOT and should not require destruction.
*/
virtual ~Time_zone() {};
+
+protected:
+ static inline void adjust_leap_second(MYSQL_TIME *t);
};
extern Time_zone * my_tz_UTC;