Below is the list of changes that have just been committed into a local
5.1 repository of msvensson. When msvensson does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-02-23 17:26:13+01:00, msvensson@stripped +2 -0
Merge pilot.blaudden:/home/msvensson/mysql/bug26536/my50-bug26536
into pilot.blaudden:/home/msvensson/mysql/bug26536/my51-bug26536
MERGE: 1.1810.2372.117
include/my_time.h@stripped, 2007-02-23 17:26:11+01:00, msvensson@stripped +0 -0
Auto merged
MERGE: 1.11.5.3
sql/tztime.cc@stripped, 2007-02-23 17:26:11+01:00, msvensson@stripped +0 -0
Auto merged
MERGE: 1.24.2.2
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: msvensson
# Host: pilot.blaudden
# Root: /home/msvensson/mysql/bug26536/my51-bug26536/RESYNC
--- 1.47/sql/tztime.cc 2007-01-24 18:57:01 +01:00
+++ 1.48/sql/tztime.cc 2007-02-23 17:26:11 +01:00
@@ -780,6 +780,8 @@ gmt_sec_to_TIME(TIME *tmp, my_time_t sec
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
@@ -911,28 +913,9 @@ TIME_to_gmt_sec(const TIME *t, const TIM
else
saved_seconds= t->second;
- /*
- NOTE: to convert full my_time_t range we do a shift of the
- boundary dates here to avoid overflow of my_time_t.
- We use alike approach in my_system_gmt_sec().
-
- However in that function we also have to take into account
- overflow near 0 on some platforms. That's because my_system_gmt_sec
- uses localtime_r(), which doesn't work with negative values correctly
- on platforms with unsigned time_t (QNX). Here we don't use localtime()
- => we negative values of local_t are ok.
*/
-
if ((t->year == TIMESTAMP_MAX_YEAR) && (t->month == 1) && t->day > 4)
- {
- /*
- We will pass (t->day - shift) to sec_since_epoch(), and
- want this value to be a positive number, so we shift
- only dates > 4.01.2038 (to avoid owerflow).
- */
shift= 2;
- }
-
local_t= sec_since_epoch(t->year, t->month, (t->day - shift),
t->hour, t->minute,
@@ -960,12 +943,12 @@ TIME_to_gmt_sec(const TIME *t, const TIM
*/
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 +1336,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,9 +1345,23 @@ Time_zone_offset::TIME_to_gmt_sec(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;
--- 1.27/include/my_time.h 2007-01-24 18:56:57 +01:00
+++ 1.28/include/my_time.h 2007-02-23 17:26:11 +01:00
@@ -30,7 +30,13 @@ extern uchar days_in_month[];
/*
Portable time_t replacement.
- Should be signed and hold seconds for 1902-2038 range.
+ Should be signed and hold seconds for 1902 -- 2038-01-19 range
+ i.e at least a 32bit variable
+
+ Using the system built in time_t is not an option as
+ we rely on the above requirements in the time functions
+
+ For example QNX has an unsigned time_t type
*/
#if defined(_WIN64) || defined(WIN64)
/* on Win64 long is still 4 bytes (not 8!) */
| Thread |
|---|
| • bk commit into 5.1 tree (msvensson:1.2458) | msvensson | 23 Feb |