summaryrefslogtreecommitdiff
path: root/sql/tztime.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/tztime.cc')
-rw-r--r--sql/tztime.cc54
1 files changed, 35 insertions, 19 deletions
diff --git a/sql/tztime.cc b/sql/tztime.cc
index d12aef47b40..4f6542bd043 100644
--- a/sql/tztime.cc
+++ b/sql/tztime.cc
@@ -107,7 +107,7 @@ typedef struct st_time_zone_info
uint revcnt; // Number of transition descr. for TIME->my_time_t conversion
/* The following are dynamical arrays are allocated in MEM_ROOT */
my_time_t *ats; // Times of transitions between time types
- unsigned char *types; // Local time types for transitions
+ uchar *types; // Local time types for transitions
TRAN_TYPE_INFO *ttis; // Local time types descriptions
#ifdef ABBR_ARE_USED
/* Storage for local time types abbreviations. They are stored as ASCIIZ */
@@ -222,7 +222,7 @@ tz_load(const char *name, TIME_ZONE_INFO *sp, MEM_ROOT *storage)
sp->ats= (my_time_t *)tzinfo_buf;
tzinfo_buf+= ALIGN_SIZE(sp->timecnt * sizeof(my_time_t));
- sp->types= (unsigned char *)tzinfo_buf;
+ sp->types= (uchar *)tzinfo_buf;
tzinfo_buf+= ALIGN_SIZE(sp->timecnt);
sp->ttis= (TRAN_TYPE_INFO *)tzinfo_buf;
tzinfo_buf+= ALIGN_SIZE(sp->typecnt * sizeof(TRAN_TYPE_INFO));
@@ -237,7 +237,7 @@ tz_load(const char *name, TIME_ZONE_INFO *sp, MEM_ROOT *storage)
for (i= 0; i < sp->timecnt; i++)
{
- sp->types[i]= (unsigned char) *p++;
+ sp->types[i]= (uchar) *p++;
if (sp->types[i] >= sp->typecnt)
return 1;
}
@@ -248,10 +248,10 @@ tz_load(const char *name, TIME_ZONE_INFO *sp, MEM_ROOT *storage)
ttisp= &sp->ttis[i];
ttisp->tt_gmtoff= int4net(p);
p+= 4;
- ttisp->tt_isdst= (unsigned char) *p++;
+ ttisp->tt_isdst= (uchar) *p++;
if (ttisp->tt_isdst != 0 && ttisp->tt_isdst != 1)
return 1;
- ttisp->tt_abbrind= (unsigned char) *p++;
+ ttisp->tt_abbrind= (uchar) *p++;
if (ttisp->tt_abbrind > sp->charcnt)
return 1;
}
@@ -807,6 +807,18 @@ sec_since_epoch(int year, int mon, int mday, int hour, int min ,int sec)
}
+ /*
+ Works like sec_since_epoch but expects TIME structure as parameter.
+*/
+
+my_time_t
+sec_since_epoch_TIME(TIME *t)
+{
+ return sec_since_epoch(t->year, t->month, t->day,
+ t->hour, t->minute, t->second);
+}
+
+
/*
Converts local time in broken down TIME representation to my_time_t
representation.
@@ -1648,7 +1660,9 @@ my_tz_init(THD *org_thd, const char *default_tzname, my_bool bootstrap)
mysql.time_zone* tables are MyISAM and these operations always succeed
for MyISAM.
*/
- (void)table->file->ha_index_init(0);
+ (void)table->file->ha_index_init(0, 1);
+ table->use_all_columns();
+
tz_leapcnt= 0;
res= table->file->index_first(table->record[0]);
@@ -1787,15 +1801,13 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables)
TIME_ZONE_INFO structure
*/
my_time_t ats[TZ_MAX_TIMES];
- unsigned char types[TZ_MAX_TIMES];
+ uchar types[TZ_MAX_TIMES];
TRAN_TYPE_INFO ttis[TZ_MAX_TYPES];
#ifdef ABBR_ARE_USED
char chars[max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1)))];
#endif
-
DBUG_ENTER("tz_load_from_open_tables");
-
/* Prepare tz_info for loading also let us make copy of time zone name */
if (!(alloc_buff= alloc_root(&tz_storage, sizeof(TIME_ZONE_INFO) +
tz_name->length() + 1)))
@@ -1818,6 +1830,7 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables)
*/
table= tz_tables->table;
tz_tables= tz_tables->next_local;
+ table->use_all_columns();
table->field[0]->store(tz_name->ptr(), tz_name->length(),
&my_charset_latin1);
/*
@@ -1825,7 +1838,7 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables)
mysql.time_zone* tables are MyISAM and these operations always succeed
for MyISAM.
*/
- (void)table->file->ha_index_init(0);
+ (void)table->file->ha_index_init(0, 1);
if (table->file->index_read(table->record[0], (byte*)table->field[0]->ptr,
0, HA_READ_KEY_EXACT))
@@ -1850,9 +1863,10 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables)
using the only index in this table).
*/
table= tz_tables->table;
+ table->use_all_columns();
tz_tables= tz_tables->next_local;
table->field[0]->store((longlong) tzid, TRUE);
- (void)table->file->ha_index_init(0);
+ (void)table->file->ha_index_init(0, 1);
if (table->file->index_read(table->record[0], (byte*)table->field[0]->ptr,
0, HA_READ_KEY_EXACT))
@@ -1877,9 +1891,10 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables)
Right - using special index.
*/
table= tz_tables->table;
+ table->use_all_columns();
tz_tables= tz_tables->next_local;
table->field[0]->store((longlong) tzid, TRUE);
- (void)table->file->ha_index_init(0);
+ (void)table->file->ha_index_init(0, 1);
// FIXME Is there any better approach than explicitly specifying 4 ???
res= table->file->index_read(table->record[0], (byte*)table->field[0]->ptr,
@@ -1950,8 +1965,9 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables)
in ascending order by index scan also satisfies us.
*/
table= tz_tables->table;
+ table->use_all_columns();
table->field[0]->store((longlong) tzid, TRUE);
- (void)table->file->ha_index_init(0);
+ (void)table->file->ha_index_init(0, 1);
// FIXME Is there any better approach than explicitly specifying 4 ???
res= table->file->index_read(table->record[0], (byte*)table->field[0]->ptr,
@@ -2022,7 +2038,7 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables)
tz_info->ats= (my_time_t *)alloc_buff;
memcpy(tz_info->ats, ats, tz_info->timecnt * sizeof(my_time_t));
alloc_buff+= ALIGN_SIZE(sizeof(my_time_t) * tz_info->timecnt);
- tz_info->types= (unsigned char *)alloc_buff;
+ tz_info->types= (uchar *)alloc_buff;
memcpy(tz_info->types, types, tz_info->timecnt);
alloc_buff+= ALIGN_SIZE(tz_info->timecnt);
#ifdef ABBR_ARE_USED
@@ -2199,12 +2215,11 @@ my_tz_find(const String * name, TABLE_LIST *tz_tables)
Tz_names_entry *tmp_tzname;
Time_zone *result_tz= 0;
long offset;
-
DBUG_ENTER("my_tz_find");
DBUG_PRINT("enter", ("time zone name='%s'",
- name ? ((String *)name)->c_ptr() : "NULL"));
-
- DBUG_ASSERT(!time_zone_tables_exist || tz_tables || current_thd->slave_thread);
+ name ? ((String *)name)->c_ptr_safe() : "NULL"));
+ DBUG_ASSERT(!time_zone_tables_exist || tz_tables ||
+ current_thd->slave_thread);
if (!name)
DBUG_RETURN(0);
@@ -2269,14 +2284,15 @@ my_tz_find(const String * name, TABLE_LIST *tz_tables)
RETURN VALUE
Pointer to corresponding Time_zone object. 0 - in case of bad time zone
specification or other error.
-
*/
+
Time_zone *my_tz_find_with_opening_tz_tables(THD *thd, const String *name)
{
Time_zone *tz;
DBUG_ENTER("my_tz_find_with_opening_tables");
DBUG_ASSERT(thd);
DBUG_ASSERT(thd->slave_thread); // intended for use with slave thread only
+
if (!(tz= my_tz_find(name, 0)) && time_zone_tables_exist)
{
/*