#include <my_global.h>#include "mysql_priv.h"#include "tzfile.h"#include <m_string.h>#include <my_dir.h>Include dependency graph for mysql_tzinfo_to_sql.cc:

Go to the source code of this file.
| #define ABBR_ARE_USED |
Definition at line 54 of file mysql_tzinfo_to_sql.cc.
| #define LEAPS_THRU_END_OF | ( | y | ) | ((y) / 4 - (y) / 100 + (y) / 400) |
Definition at line 521 of file mysql_tzinfo_to_sql.cc.
Referenced by sec_since_epoch(), and sec_to_TIME().
| #define MY_TZNAME_MAX 255 |
| typedef struct st_time_zone_info TIME_ZONE_INFO |
| typedef struct ttinfo TRAN_TYPE_INFO |
| static uint find_time_range | ( | my_time_t | t, | |
| const my_time_t * | range_boundaries, | |||
| uint | higher_bound | |||
| ) | [static] |
Definition at line 626 of file mysql_tzinfo_to_sql.cc.
References DBUG_ASSERT.
Referenced by find_transition_type(), and TIME_to_gmt_sec().
00628 { 00629 uint i, lower_bound= 0; 00630 00631 /* 00632 Function will work without this assertion but result would be meaningless. 00633 */ 00634 DBUG_ASSERT(higher_bound > 0 && t >= range_boundaries[0]); 00635 00636 /* 00637 Do binary search for minimal interval which contain t. We preserve: 00638 range_boundaries[lower_bound] <= t < range_boundaries[higher_bound] 00639 invariant and decrease this higher_bound - lower_bound gap twice 00640 times on each step. 00641 */ 00642 00643 while (higher_bound - lower_bound > 1) 00644 { 00645 i= (lower_bound + higher_bound) >> 1; 00646 if (range_boundaries[i] <= t) 00647 lower_bound= i; 00648 else 00649 higher_bound= i; 00650 } 00651 return lower_bound; 00652 }
Here is the caller graph for this function:

| static const TRAN_TYPE_INFO* find_transition_type | ( | my_time_t | t, | |
| const TIME_ZONE_INFO * | sp | |||
| ) | [static] |
Definition at line 668 of file mysql_tzinfo_to_sql.cc.
References st_time_zone_info::ats, st_time_zone_info::fallback_tti, find_time_range(), st_time_zone_info::timecnt, st_time_zone_info::ttis, st_time_zone_info::types, and unlikely.
Referenced by gmt_sec_to_TIME().
00669 { 00670 if (unlikely(sp->timecnt == 0 || t < sp->ats[0])) 00671 { 00672 /* 00673 If we have not any transitions or t is before first transition let 00674 us use fallback time type. 00675 */ 00676 return sp->fallback_tti; 00677 } 00678 00679 /* 00680 Do binary search for minimal interval between transitions which 00681 contain t. With this localtime_r on real data may takes less 00682 time than with linear search (I've seen 30% speed up). 00683 */ 00684 return &(sp->ttis[sp->types[find_time_range(t, sp->ats, sp->timecnt)]]); 00685 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void gmt_sec_to_TIME | ( | TIME * | tmp, | |
| my_time_t | sec_in_utc, | |||
| const TIME_ZONE_INFO * | sp | |||
| ) | [static] |
Definition at line 710 of file mysql_tzinfo_to_sql.cc.
References find_transition_type(), st_time_zone_info::leapcnt, lsinfo::ls_corr, lsinfo::ls_trans, st_time_zone_info::lsis, sec_to_TIME(), st_mysql_time::second, and ttinfo::tt_gmtoff.
00711 { 00712 const TRAN_TYPE_INFO *ttisp; 00713 const LS_INFO *lp; 00714 long corr= 0; 00715 int hit= 0; 00716 int i; 00717 00718 /* 00719 Find proper transition (and its local time type) for our sec_in_utc value. 00720 Funny but again by separating this step in function we receive code 00721 which very close to glibc's code. No wonder since they obviously use 00722 the same base and all steps are sensible. 00723 */ 00724 ttisp= find_transition_type(sec_in_utc, sp); 00725 00726 /* 00727 Let us find leap correction for our sec_in_utc value and number of extra 00728 secs to add to this minute. 00729 This loop is rarely used because most users will use time zones without 00730 leap seconds, and even in case when we have such time zone there won't 00731 be many iterations (we have about 22 corrections at this moment (2004)). 00732 */ 00733 for ( i= sp->leapcnt; i-- > 0; ) 00734 { 00735 lp= &sp->lsis[i]; 00736 if (sec_in_utc >= lp->ls_trans) 00737 { 00738 if (sec_in_utc == lp->ls_trans) 00739 { 00740 hit= ((i == 0 && lp->ls_corr > 0) || 00741 lp->ls_corr > sp->lsis[i - 1].ls_corr); 00742 if (hit) 00743 { 00744 while (i > 0 && 00745 sp->lsis[i].ls_trans == sp->lsis[i - 1].ls_trans + 1 && 00746 sp->lsis[i].ls_corr == sp->lsis[i - 1].ls_corr + 1) 00747 { 00748 hit++; 00749 i--; 00750 } 00751 } 00752 } 00753 corr= lp->ls_corr; 00754 break; 00755 } 00756 } 00757 00758 sec_to_TIME(tmp, sec_in_utc, ttisp->tt_gmtoff - corr); 00759 00760 tmp->second+= hit; 00761 }
Here is the call graph for this function:

| byte* my_offset_tzs_get_key | ( | Time_zone_offset * | entry, | |
| uint * | length, | |||
| my_bool not_used | __attribute__((unused)) | |||
| ) |
Definition at line 1423 of file mysql_tzinfo_to_sql.cc.
Referenced by my_tz_init().
Here is the caller graph for this function:

| Time_zone* my_tz_find | ( | const String * | name, | |
| TABLE_LIST * | tz_tables | |||
| ) |
Definition at line 2213 of file mysql_tzinfo_to_sql.cc.
Referenced by sys_var_thd_time_zone::check(), my_tz_find_with_opening_tz_tables(), my_tz_init(), and sys_var_thd_time_zone::set_default().
02214 { 02215 Tz_names_entry *tmp_tzname; 02216 Time_zone *result_tz= 0; 02217 long offset; 02218 DBUG_ENTER("my_tz_find"); 02219 DBUG_PRINT("enter", ("time zone name='%s'", 02220 name ? ((String *)name)->c_ptr_safe() : "NULL")); 02221 DBUG_ASSERT(!time_zone_tables_exist || tz_tables || 02222 current_thd->slave_thread); 02223 02224 if (!name) 02225 DBUG_RETURN(0); 02226 02227 VOID(pthread_mutex_lock(&tz_LOCK)); 02228 02229 if (!str_to_offset(name->ptr(), name->length(), &offset)) 02230 { 02231 02232 if (!(result_tz= (Time_zone_offset *)hash_search(&offset_tzs, 02233 (const byte *)&offset, 02234 sizeof(long)))) 02235 { 02236 DBUG_PRINT("info", ("Creating new Time_zone_offset object")); 02237 02238 if (!(result_tz= new (&tz_storage) Time_zone_offset(offset)) || 02239 my_hash_insert(&offset_tzs, (const byte *) result_tz)) 02240 { 02241 result_tz= 0; 02242 sql_print_error("Fatal error: Out of memory " 02243 "while setting new time zone"); 02244 } 02245 } 02246 } 02247 else 02248 { 02249 result_tz= 0; 02250 if ((tmp_tzname= (Tz_names_entry *)hash_search(&tz_names, 02251 (const byte *)name->ptr(), 02252 name->length()))) 02253 result_tz= tmp_tzname->tz; 02254 else if (time_zone_tables_exist && tz_tables) 02255 result_tz= tz_load_from_open_tables(name, tz_tables); 02256 } 02257 02258 VOID(pthread_mutex_unlock(&tz_LOCK)); 02259 02260 DBUG_RETURN(result_tz); 02261 }
Here is the caller graph for this function:

Definition at line 2289 of file mysql_tzinfo_to_sql.cc.
02290 { 02291 Time_zone *tz; 02292 DBUG_ENTER("my_tz_find_with_opening_tables"); 02293 DBUG_ASSERT(thd); 02294 DBUG_ASSERT(thd->slave_thread); // intended for use with slave thread only 02295 02296 if (!(tz= my_tz_find(name, 0)) && time_zone_tables_exist) 02297 { 02298 /* 02299 Probably we have not loaded this time zone yet so let us look it up in 02300 our time zone tables. Note that if we don't have tz tables on this 02301 slave, we don't even try. 02302 */ 02303 TABLE_LIST tables[MY_TZ_TABLES_COUNT]; 02304 TABLE_LIST *dummy; 02305 TABLE_LIST **dummyp= &dummy; 02306 tz_init_table_list(tables, &dummyp); 02307 if (simple_open_n_lock_tables(thd, tables)) 02308 DBUG_RETURN(0); 02309 tz= my_tz_find(name, tables); 02310 /* We need to close tables _now_ to not pollute coming query */ 02311 close_thread_tables(thd); 02312 } 02313 DBUG_RETURN(tz); 02314 }
| void my_tz_free | ( | ) |
Definition at line 1752 of file mysql_tzinfo_to_sql.cc.
Referenced by clean_up(), and my_tz_init().
01753 { 01754 if (tz_inited) 01755 { 01756 tz_inited= 0; 01757 VOID(pthread_mutex_destroy(&tz_LOCK)); 01758 hash_free(&offset_tzs); 01759 hash_free(&tz_names); 01760 free_root(&tz_storage, MYF(0)); 01761 } 01762 }
Here is the caller graph for this function:

| TABLE_LIST* my_tz_get_table_list | ( | THD * | thd, | |
| TABLE_LIST *** | global_next_ptr | |||
| ) |
Definition at line 1511 of file mysql_tzinfo_to_sql.cc.
01512 { 01513 TABLE_LIST *tz_tabs; 01514 DBUG_ENTER("my_tz_get_table_list"); 01515 01516 if (!time_zone_tables_exist) 01517 DBUG_RETURN(0); 01518 01519 if (!(tz_tabs= (TABLE_LIST *)thd->alloc(sizeof(TABLE_LIST) * 01520 MY_TZ_TABLES_COUNT))) 01521 DBUG_RETURN(&fake_time_zone_tables_list); 01522 01523 tz_init_table_list(tz_tabs, global_next_ptr); 01524 01525 DBUG_RETURN(tz_tabs); 01526 }
Definition at line 1555 of file mysql_tzinfo_to_sql.cc.
Referenced by main().
01556 { 01557 THD *thd; 01558 TABLE_LIST *tables= 0; 01559 TABLE_LIST tables_buff[1+MY_TZ_TABLES_COUNT], **last_global_next_ptr; 01560 TABLE *table; 01561 Tz_names_entry *tmp_tzname; 01562 my_bool return_val= 1; 01563 char db[]= "mysql"; 01564 int res; 01565 DBUG_ENTER("my_tz_init"); 01566 01567 /* 01568 To be able to run this from boot, we allocate a temporary THD 01569 */ 01570 if (!(thd= new THD)) 01571 DBUG_RETURN(1); 01572 thd->thread_stack= (char*) &thd; 01573 thd->store_globals(); 01574 01575 /* Init all memory structures that require explicit destruction */ 01576 if (hash_init(&tz_names, &my_charset_latin1, 20, 01577 0, 0, (hash_get_key)my_tz_names_get_key, 0, 0)) 01578 { 01579 sql_print_error("Fatal error: OOM while initializing time zones"); 01580 goto end; 01581 } 01582 if (hash_init(&offset_tzs, &my_charset_latin1, 26, 0, 0, 01583 (hash_get_key)my_offset_tzs_get_key, 0, 0)) 01584 { 01585 sql_print_error("Fatal error: OOM while initializing time zones"); 01586 hash_free(&tz_names); 01587 goto end; 01588 } 01589 init_alloc_root(&tz_storage, 32 * 1024, 0); 01590 VOID(pthread_mutex_init(&tz_LOCK, MY_MUTEX_INIT_FAST)); 01591 tz_inited= 1; 01592 01593 /* Add 'SYSTEM' time zone to tz_names hash */ 01594 if (!(tmp_tzname= new (&tz_storage) Tz_names_entry())) 01595 { 01596 sql_print_error("Fatal error: OOM while initializing time zones"); 01597 goto end_with_cleanup; 01598 } 01599 tmp_tzname->name.set(STRING_WITH_LEN("SYSTEM"), &my_charset_latin1); 01600 tmp_tzname->tz= my_tz_SYSTEM; 01601 if (my_hash_insert(&tz_names, (const byte *)tmp_tzname)) 01602 { 01603 sql_print_error("Fatal error: OOM while initializing time zones"); 01604 goto end_with_cleanup; 01605 } 01606 01607 if (bootstrap) 01608 { 01609 /* If we are in bootstrap mode we should not load time zone tables */ 01610 return_val= time_zone_tables_exist= 0; 01611 goto end_with_setting_default_tz; 01612 } 01613 01614 /* 01615 After this point all memory structures are inited and we even can live 01616 without time zone description tables. Now try to load information about 01617 leap seconds shared by all time zones. 01618 */ 01619 01620 thd->set_db(db, sizeof(db)-1); 01621 bzero((char*) &tables_buff, sizeof(TABLE_LIST)); 01622 tables_buff[0].alias= tables_buff[0].table_name= 01623 (char*)"time_zone_leap_second"; 01624 tables_buff[0].lock_type= TL_READ; 01625 tables_buff[0].db= db; 01626 /* 01627 Fill TABLE_LIST for the rest of the time zone describing tables 01628 and link it to first one. 01629 */ 01630 last_global_next_ptr= &(tables_buff[0].next_global); 01631 tz_init_table_list(tables_buff + 1, &last_global_next_ptr); 01632 01633 if (simple_open_n_lock_tables(thd, tables_buff)) 01634 { 01635 sql_print_warning("Can't open and lock time zone table: %s " 01636 "trying to live without them", thd->net.last_error); 01637 /* We will try emulate that everything is ok */ 01638 return_val= time_zone_tables_exist= 0; 01639 goto end_with_setting_default_tz; 01640 } 01641 tables= tables_buff + 1; 01642 01643 /* 01644 Now we are going to load leap seconds descriptions that are shared 01645 between all time zones that use them. We are using index for getting 01646 records in proper order. Since we share the same MEM_ROOT between 01647 all time zones we just allocate enough memory for it first. 01648 */ 01649 if (!(tz_lsis= (LS_INFO*) alloc_root(&tz_storage, 01650 sizeof(LS_INFO) * TZ_MAX_LEAPS))) 01651 { 01652 sql_print_error("Fatal error: Out of memory while loading " 01653 "mysql.time_zone_leap_second table"); 01654 goto end_with_close; 01655 } 01656 01657 table= tables_buff[0].table; 01658 /* 01659 It is OK to ignore ha_index_init()/ha_index_end() return values since 01660 mysql.time_zone* tables are MyISAM and these operations always succeed 01661 for MyISAM. 01662 */ 01663 (void)table->file->ha_index_init(0, 1); 01664 table->use_all_columns(); 01665 01666 tz_leapcnt= 0; 01667 01668 res= table->file->index_first(table->record[0]); 01669 01670 while (!res) 01671 { 01672 if (tz_leapcnt + 1 > TZ_MAX_LEAPS) 01673 { 01674 sql_print_error("Fatal error: While loading mysql.time_zone_leap_second" 01675 " table: too much leaps"); 01676 table->file->ha_index_end(); 01677 goto end_with_close; 01678 } 01679 01680 tz_lsis[tz_leapcnt].ls_trans= (my_time_t)table->field[0]->val_int(); 01681 tz_lsis[tz_leapcnt].ls_corr= (long)table->field[1]->val_int(); 01682 01683 tz_leapcnt++; 01684 01685 DBUG_PRINT("info", 01686 ("time_zone_leap_second table: tz_leapcnt=%u tt_time=%lld offset=%ld", 01687 tz_leapcnt, (longlong)tz_lsis[tz_leapcnt-1].ls_trans, 01688 tz_lsis[tz_leapcnt-1].ls_corr)); 01689 01690 res= table->file->index_next(table->record[0]); 01691 } 01692 01693 (void)table->file->ha_index_end(); 01694 01695 if (res != HA_ERR_END_OF_FILE) 01696 { 01697 sql_print_error("Fatal error: Error while loading " 01698 "mysql.time_zone_leap_second table"); 01699 goto end_with_close; 01700 } 01701 01702 /* 01703 Loading of info about leap seconds succeeded 01704 */ 01705 01706 return_val= 0; 01707 01708 01709 end_with_setting_default_tz: 01710 /* If we have default time zone try to load it */ 01711 if (default_tzname) 01712 { 01713 String tmp_tzname(default_tzname, &my_charset_latin1); 01714 if (!(global_system_variables.time_zone= my_tz_find(&tmp_tzname, tables))) 01715 { 01716 sql_print_error("Fatal error: Illegal or unknown default time zone '%s'", 01717 default_tzname); 01718 return_val= 1; 01719 } 01720 } 01721 01722 end_with_close: 01723 thd->version--; /* Force close to free memory */ 01724 close_thread_tables(thd); 01725 01726 end_with_cleanup: 01727 01728 /* if there were error free time zone describing structs */ 01729 if (return_val) 01730 my_tz_free(); 01731 end: 01732 delete thd; 01733 if (org_thd) 01734 org_thd->store_globals(); /* purecov: inspected */ 01735 else 01736 { 01737 /* Remember that we don't have a THD */ 01738 my_pthread_setspecific_ptr(THR_THD, 0); 01739 my_pthread_setspecific_ptr(THR_MALLOC, 0); 01740 } 01741 DBUG_RETURN(return_val); 01742 }
Here is the caller graph for this function:

| byte* my_tz_names_get_key | ( | Tz_names_entry * | entry, | |
| uint * | length, | |||
| my_bool not_used | __attribute__((unused)) | |||
| ) |
Definition at line 1416 of file mysql_tzinfo_to_sql.cc.
Referenced by my_tz_init().
Here is the caller graph for this function:

| static my_bool prepare_tz_info | ( | TIME_ZONE_INFO * | sp, | |
| MEM_ROOT * | storage | |||
| ) | [static] |
Definition at line 315 of file mysql_tzinfo_to_sql.cc.
References st_time_zone_info::fallback_tti, LINT_INIT, MY_TIME_T_MIN, st_time_zone_info::revcnt, st_time_zone_info::timecnt, ttinfo::tt_isdst, st_time_zone_info::ttis, st_time_zone_info::typecnt, and TZ_MAX_REV_RANGES.
Referenced by tz_load_from_open_tables().
00316 { 00317 my_time_t cur_t= MY_TIME_T_MIN; 00318 my_time_t cur_l, end_t, end_l; 00319 my_time_t cur_max_seen_l= MY_TIME_T_MIN; 00320 long cur_offset, cur_corr, cur_off_and_corr; 00321 uint next_trans_idx, next_leap_idx; 00322 uint i; 00323 /* 00324 Temporary arrays where we will store tables. Needed because 00325 we don't know table sizes ahead. (Well we can estimate their 00326 upper bound but this will take extra space.) 00327 */ 00328 my_time_t revts[TZ_MAX_REV_RANGES]; 00329 REVT_INFO revtis[TZ_MAX_REV_RANGES]; 00330 00331 LINT_INIT(end_l); 00332 00333 /* 00334 Let us setup fallback time type which will be used if we have not any 00335 transitions or if we have moment of time before first transition. 00336 We will find first non-DST local time type and use it (or use first 00337 local time type if all of them are DST types). 00338 */ 00339 for (i= 0; i < sp->typecnt && sp->ttis[i].tt_isdst; i++) 00340 /* no-op */ ; 00341 if (i == sp->typecnt) 00342 i= 0; 00343 sp->fallback_tti= &(sp->ttis[i]); 00344 00345 00346 /* 00347 Let us build shifted my_time_t -> my_time_t map. 00348 */ 00349 sp->revcnt= 0; 00350 00351 /* Let us find initial offset */ 00352 if (sp->timecnt == 0 || cur_t < sp->ats[0]) 00353 { 00354 /* 00355 If we have not any transitions or t is before first transition we are using 00356 already found fallback time type which index is already in i. 00357 */ 00358 next_trans_idx= 0; 00359 } 00360 else 00361 { 00362 /* cur_t == sp->ats[0] so we found transition */ 00363 i= sp->types[0]; 00364 next_trans_idx= 1; 00365 } 00366 00367 cur_offset= sp->ttis[i].tt_gmtoff; 00368 00369 00370 /* let us find leap correction... unprobable, but... */ 00371 for (next_leap_idx= 0; next_leap_idx < sp->leapcnt && 00372 cur_t >= sp->lsis[next_leap_idx].ls_trans; 00373 ++next_leap_idx) 00374 continue; 00375 00376 if (next_leap_idx > 0) 00377 cur_corr= sp->lsis[next_leap_idx - 1].ls_corr; 00378 else 00379 cur_corr= 0; 00380 00381 /* Iterate trough t space */ 00382 while (sp->revcnt < TZ_MAX_REV_RANGES - 1) 00383 { 00384 cur_off_and_corr= cur_offset - cur_corr; 00385 00386 /* 00387 We assuming that cur_t could be only overflowed downwards, 00388 we also assume that end_t won't be overflowed in this case. 00389 */ 00390 if (cur_off_and_corr < 0 && 00391 cur_t < MY_TIME_T_MIN - cur_off_and_corr) 00392 cur_t= MY_TIME_T_MIN - cur_off_and_corr; 00393 00394 cur_l= cur_t + cur_off_and_corr; 00395 00396 /* 00397 Let us choose end_t as point before next time type change or leap 00398 second correction. 00399 */ 00400 end_t= min((next_trans_idx < sp->timecnt) ? sp->ats[next_trans_idx] - 1: 00401 MY_TIME_T_MAX, 00402 (next_leap_idx < sp->leapcnt) ? 00403 sp->lsis[next_leap_idx].ls_trans - 1: MY_TIME_T_MAX); 00404 /* 00405 again assuming that end_t can be overlowed only in positive side 00406 we also assume that end_t won't be overflowed in this case. 00407 */ 00408 if (cur_off_and_corr > 0 && 00409 end_t > MY_TIME_T_MAX - cur_off_and_corr) 00410 end_t= MY_TIME_T_MAX - cur_off_and_corr; 00411 00412 end_l= end_t + cur_off_and_corr; 00413 00414 00415 if (end_l > cur_max_seen_l) 00416 { 00417 /* We want special handling in the case of first range */ 00418 if (cur_max_seen_l == MY_TIME_T_MIN) 00419 { 00420 revts[sp->revcnt]= cur_l; 00421 revtis[sp->revcnt].rt_offset= cur_off_and_corr; 00422 revtis[sp->revcnt].rt_type= 0; 00423 sp->revcnt++; 00424 cur_max_seen_l= end_l; 00425 } 00426 else 00427 { 00428 if (cur_l > cur_max_seen_l + 1) 00429 { 00430 /* We have a spring time-gap and we are not at the first range */ 00431 revts[sp->revcnt]= cur_max_seen_l + 1; 00432 revtis[sp->revcnt].rt_offset= revtis[sp->revcnt-1].rt_offset; 00433 revtis[sp->revcnt].rt_type= 1; 00434 sp->revcnt++; 00435 if (sp->revcnt == TZ_MAX_TIMES + TZ_MAX_LEAPS + 1) 00436 break; /* That was too much */ 00437 cur_max_seen_l= cur_l - 1; 00438 } 00439 00440 /* Assume here end_l > cur_max_seen_l (because end_l>=cur_l) */ 00441 00442 revts[sp->revcnt]= cur_max_seen_l + 1; 00443 revtis[sp->revcnt].rt_offset= cur_off_and_corr; 00444 revtis[sp->revcnt].rt_type= 0; 00445 sp->revcnt++; 00446 cur_max_seen_l= end_l; 00447 } 00448 } 00449 00450 if (end_t == MY_TIME_T_MAX || 00451 (cur_off_and_corr > 0) && 00452 (end_t >= MY_TIME_T_MAX - cur_off_and_corr)) 00453 /* end of t space */ 00454 break; 00455 00456 cur_t= end_t + 1; 00457 00458 /* 00459 Let us find new offset and correction. Because of our choice of end_t 00460 cur_t can only be point where new time type starts or/and leap 00461 correction is performed. 00462 */ 00463 if (sp->timecnt != 0 && cur_t >= sp->ats[0]) /* else reuse old offset */ 00464 if (next_trans_idx < sp->timecnt && 00465 cur_t == sp->ats[next_trans_idx]) 00466 { 00467 /* We are at offset point */ 00468 cur_offset= sp->ttis[sp->types[next_trans_idx]].tt_gmtoff; 00469 ++next_trans_idx; 00470 } 00471 00472 if (next_leap_idx < sp->leapcnt && 00473 cur_t == sp->lsis[next_leap_idx].ls_trans) 00474 { 00475 /* we are at leap point */ 00476 cur_corr= sp->lsis[next_leap_idx].ls_corr; 00477 ++next_leap_idx; 00478 } 00479 } 00480 00481 /* check if we have had enough space */ 00482 if (sp->revcnt == TZ_MAX_REV_RANGES - 1) 00483 return 1; 00484 00485 /* set maximum end_l as finisher */ 00486 revts[sp->revcnt]= end_l; 00487 00488 /* Allocate arrays of proper size in sp and copy result there */ 00489 if (!(sp->revts= (my_time_t *)alloc_root(storage, 00490 sizeof(my_time_t) * (sp->revcnt + 1))) || 00491 !(sp->revtis= (REVT_INFO *)alloc_root(storage, 00492 sizeof(REVT_INFO) * sp->revcnt))) 00493 return 1; 00494 00495 memcpy(sp->revts, revts, sizeof(my_time_t) * (sp->revcnt + 1)); 00496 memcpy(sp->revtis, revtis, sizeof(REVT_INFO) * sp->revcnt); 00497 00498 return 0; 00499 }
Here is the caller graph for this function:

| static my_time_t sec_since_epoch | ( | int | year, | |
| int | mon, | |||
| int | mday, | |||
| int | hour, | |||
| int | min, | |||
| int | sec | |||
| ) | [static] |
Definition at line 782 of file mysql_tzinfo_to_sql.cc.
References DAYS_PER_NYEAR, DBUG_ASSERT, EPOCH_YEAR, HOURS_PER_DAY, isleap, LEAPS_THRU_END_OF, MINS_PER_HOUR, MONS_PER_YEAR, and SECS_PER_MIN.
Referenced by sec_since_epoch_TIME(), Time_zone_offset::TIME_to_gmt_sec(), and TIME_to_gmt_sec().
00783 { 00784 #ifndef WE_WANT_TO_HANDLE_UNORMALIZED_DATES 00785 /* 00786 It turns out that only whenever month is normalized or unnormalized 00787 plays role. 00788 */ 00789 DBUG_ASSERT(mon > 0 && mon < 13); 00790 long days= year * DAYS_PER_NYEAR - EPOCH_YEAR * DAYS_PER_NYEAR + 00791 LEAPS_THRU_END_OF(year - 1) - 00792 LEAPS_THRU_END_OF(EPOCH_YEAR - 1); 00793 days+= mon_starts[isleap(year)][mon - 1]; 00794 #else 00795 long norm_month= (mon - 1) % MONS_PER_YEAR; 00796 long a_year= year + (mon - 1)/MONS_PER_YEAR - (int)(norm_month < 0); 00797 long days= a_year * DAYS_PER_NYEAR - EPOCH_YEAR * DAYS_PER_NYEAR + 00798 LEAPS_THRU_END_OF(a_year - 1) - 00799 LEAPS_THRU_END_OF(EPOCH_YEAR - 1); 00800 days+= mon_starts[isleap(a_year)] 00801 [norm_month + (norm_month < 0 ? MONS_PER_YEAR : 0)]; 00802 #endif 00803 days+= mday - 1; 00804 00805 return ((days * HOURS_PER_DAY + hour) * MINS_PER_HOUR + min) * 00806 SECS_PER_MIN + sec; 00807 }
Here is the caller graph for this function:

Definition at line 815 of file mysql_tzinfo_to_sql.cc.
Referenced by Event_scheduler::run().
00816 { 00817 return sec_since_epoch(t->year, t->month, t->day, 00818 t->hour, t->minute, t->second); 00819 }
Here is the caller graph for this function:

Definition at line 542 of file mysql_tzinfo_to_sql.cc.
References st_mysql_time::day, DAYS_PER_NYEAR, EPOCH_YEAR, st_mysql_time::hour, isleap, LEAPS_THRU_END_OF, st_mysql_time::minute, st_mysql_time::month, MYSQL_TIMESTAMP_DATETIME, st_mysql_time::neg, st_mysql_time::second, st_mysql_time::second_part, SECS_PER_DAY, SECS_PER_HOUR, SECS_PER_MIN, st_mysql_time::time_type, and st_mysql_time::year.
Referenced by Time_zone_offset::gmt_sec_to_TIME(), and gmt_sec_to_TIME().
00543 { 00544 long days; 00545 long rem; 00546 int y; 00547 int yleap; 00548 const uint *ip; 00549 00550 days= t / SECS_PER_DAY; 00551 rem= t % SECS_PER_DAY; 00552 00553 /* 00554 We do this as separate step after dividing t, because this 00555 allows us handle times near my_time_t bounds without overflows. 00556 */ 00557 rem+= offset; 00558 while (rem < 0) 00559 { 00560 rem+= SECS_PER_DAY; 00561 days--; 00562 } 00563 while (rem >= SECS_PER_DAY) 00564 { 00565 rem -= SECS_PER_DAY; 00566 days++; 00567 } 00568 tmp->hour= (uint)(rem / SECS_PER_HOUR); 00569 rem= rem % SECS_PER_HOUR; 00570 tmp->minute= (uint)(rem / SECS_PER_MIN); 00571 /* 00572 A positive leap second requires a special 00573 representation. This uses "... ??:59:60" et seq. 00574 */ 00575 tmp->second= (uint)(rem % SECS_PER_MIN); 00576 00577 y= EPOCH_YEAR; 00578 while (days < 0 || days >= (long)year_lengths[yleap= isleap(y)]) 00579 { 00580 int newy; 00581 00582 newy= y + days / DAYS_PER_NYEAR; 00583 if (days < 0) 00584 newy--; 00585 days-= (newy - y) * DAYS_PER_NYEAR + 00586 LEAPS_THRU_END_OF(newy - 1) - 00587 LEAPS_THRU_END_OF(y - 1); 00588 y= newy; 00589 } 00590 tmp->year= y; 00591 00592 ip= mon_lengths[yleap]; 00593 for (tmp->month= 0; days >= (long) ip[tmp->month]; tmp->month++) 00594 days= days - (long) ip[tmp->month]; 00595 tmp->month++; 00596 tmp->day= (uint)(days + 1); 00597 00598 /* filling MySQL specific TIME members */ 00599 tmp->neg= 0; tmp->second_part= 0; 00600 tmp->time_type= MYSQL_TIMESTAMP_DATETIME; 00601 }
Here is the caller graph for this function:

Definition at line 2112 of file mysql_tzinfo_to_sql.cc.
References MINS_PER_HOUR, my_charset_latin1, my_isdigit, SECS_PER_HOUR, and SECS_PER_MIN.
Referenced by my_tz_find().
02113 { 02114 const char *end= str + length; 02115 my_bool negative; 02116 ulong number_tmp; 02117 long offset_tmp; 02118 02119 if (length < 4) 02120 return 1; 02121 02122 if (*str == '+') 02123 negative= 0; 02124 else if (*str == '-') 02125 negative= 1; 02126 else 02127 return 1; 02128 str++; 02129 02130 number_tmp= 0; 02131 02132 while (str < end && my_isdigit(&my_charset_latin1, *str)) 02133 { 02134 number_tmp= number_tmp*10 + *str - '0'; 02135 str++; 02136 } 02137 02138 if (str + 1 >= end || *str != ':') 02139 return 1; 02140 str++; 02141 02142 offset_tmp = number_tmp * MINS_PER_HOUR; number_tmp= 0; 02143 02144 while (str < end && my_isdigit(&my_charset_latin1, *str)) 02145 { 02146 number_tmp= number_tmp * 10 + *str - '0'; 02147 str++; 02148 } 02149 02150 if (str != end) 02151 return 1; 02152 02153 offset_tmp= (offset_tmp + number_tmp) * SECS_PER_MIN; 02154 02155 if (negative) 02156 offset_tmp= -offset_tmp; 02157 02158 /* 02159 Check if offset is in range prescribed by standard 02160 (from -12:59 to 13:00). 02161 */ 02162 02163 if (number_tmp > 59 || offset_tmp < -13 * SECS_PER_HOUR + 1 || 02164 offset_tmp > 13 * SECS_PER_HOUR) 02165 return 1; 02166 02167 *offset= offset_tmp; 02168 02169 return 0; 02170 }
Here is the caller graph for this function:

| static my_time_t TIME_to_gmt_sec | ( | const TIME * | t, | |
| const TIME_ZONE_INFO * | sp, | |||
| my_bool * | in_dst_time_gap | |||
| ) | [static] |
Definition at line 895 of file mysql_tzinfo_to_sql.cc.
References st_mysql_time::day, DBUG_ASSERT, DBUG_ENTER, DBUG_RETURN, find_time_range(), st_mysql_time::hour, st_mysql_time::minute, st_mysql_time::month, st_time_zone_info::revcnt, st_time_zone_info::revtis, st_time_zone_info::revts, revtinfo::rt_offset, revtinfo::rt_type, sec_since_epoch(), st_mysql_time::second, SECS_PER_MIN, and st_mysql_time::year.
Referenced by Time_zone_db::TIME_to_gmt_sec().
00897 { 00898 my_time_t local_t; 00899 uint saved_seconds; 00900 uint i; 00901 DBUG_ENTER("TIME_to_gmt_sec"); 00902 00903 /* We need this for correct leap seconds handling */ 00904 if (t->second < SECS_PER_MIN) 00905 saved_seconds= 0; 00906 else 00907 saved_seconds= t->second; 00908 00909 /* 00910 NOTE If we want to convert full my_time_t range without MySQL 00911 restrictions we should catch overflow here somehow. 00912 */ 00913 00914 local_t= sec_since_epoch(t->year, t->month, t->day, 00915 t->hour, t->minute, 00916 saved_seconds ? 0 : t->second); 00917 00918 /* We have at least one range */ 00919 DBUG_ASSERT(sp->revcnt >= 1); 00920 00921 if (local_t < sp->revts[0] || local_t > sp->revts[sp->revcnt]) 00922 { 00923 /* 00924 This means that source time can't be represented as my_time_t due to 00925 limited my_time_t range. 00926 */ 00927 DBUG_RETURN(0); 00928 } 00929 00930 /* binary search for our range */ 00931 i= find_time_range(local_t, sp->revts, sp->revcnt); 00932 00933 if (sp->revtis[i].rt_type) 00934 { 00935 /* 00936 Oops! We are in spring time gap. 00937 May be we should return error here? 00938 Now we are returning my_time_t value corresponding to the 00939 beginning of the gap. 00940 */ 00941 *in_dst_time_gap= 1; 00942 DBUG_RETURN(sp->revts[i] - sp->revtis[i].rt_offset + saved_seconds); 00943 } 00944 else 00945 DBUG_RETURN(local_t - sp->revtis[i].rt_offset + saved_seconds); 00946 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void tz_init_table_list | ( | TABLE_LIST * | tz_tabs, | |
| TABLE_LIST *** | global_next_ptr | |||
| ) | [static] |
Definition at line 1451 of file mysql_tzinfo_to_sql.cc.
References bzero, st_table_list::db, st_table_list::db_length, LEX_STRING::length, st_table_list::lock_type, MY_TZ_TABLES_COUNT, st_table_list::next_global, st_table_list::prev_global, LEX_STRING::str, st_table_list::table_name_length, TL_READ, tz_tables_db_name, and tz_tables_names.
Referenced by my_tz_find_with_opening_tz_tables(), my_tz_get_table_list(), and my_tz_init().
01452 { 01453 bzero(tz_tabs, sizeof(TABLE_LIST) * MY_TZ_TABLES_COUNT); 01454 01455 for (int i= 0; i < MY_TZ_TABLES_COUNT; i++) 01456 { 01457 tz_tabs[i].alias= tz_tabs[i].table_name= tz_tables_names[i].str; 01458 tz_tabs[i].table_name_length= tz_tables_names[i].length; 01459 tz_tabs[i].db= tz_tables_db_name.str; 01460 tz_tabs[i].db_length= tz_tables_db_name.length; 01461 tz_tabs[i].lock_type= TL_READ; 01462 01463 if (i != MY_TZ_TABLES_COUNT - 1) 01464 tz_tabs[i].next_global= tz_tabs[i].next_local= &tz_tabs[i+1]; 01465 if (i != 0) 01466 tz_tabs[i].prev_global= &tz_tabs[i-1].next_global; 01467 } 01468 01469 /* Link into global list */ 01470 tz_tabs[0].prev_global= *global_next_ptr; 01471 **global_next_ptr= tz_tabs; 01472 /* Update last-global-pointer to point to pointer in last table */ 01473 *global_next_ptr= &tz_tabs[MY_TZ_TABLES_COUNT-1].next_global; 01474 }
Here is the caller graph for this function:

| static Time_zone* tz_load_from_open_tables | ( | const String * | tz_name, | |
| TABLE_LIST * | tz_tables | |||
| ) | [static] |
Definition at line 1787 of file mysql_tzinfo_to_sql.cc.
References ALIGN_SIZE, alloc_root(), bzero, DBUG_ASSERT, DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, EXTRA_DEBUG, HA_ERR_END_OF_FILE, HA_ERR_KEY_NOT_FOUND, HA_READ_KEY_EXACT, String::length(), max, MAX_FIELD_WIDTH, memcpy, my_charset_latin1, my_hash_insert(), MY_TZNAME_MAX, Tz_names_entry::name, new(), st_table_list::next_local, prepare_tz_info(), String::ptr(), String::set(), sql_print_error(), strmake(), st_table_list::table, TRUE, ttinfo::tt_abbrind, ttinfo::tt_gmtoff, ttinfo::tt_isdst, Tz_names_entry::tz, tz_lsis, TZ_MAX_CHARS, TZ_MAX_TIMES, TZ_MAX_TYPES, tz_names, tz_storage, and st_table::use_all_columns().
Referenced by my_tz_find().
01788 { 01789 TABLE *table= 0; 01790 TIME_ZONE_INFO *tz_info; 01791 Tz_names_entry *tmp_tzname; 01792 Time_zone *return_val= 0; 01793 int res; 01794 uint tzid, ttid; 01795 my_time_t ttime; 01796 char buff[MAX_FIELD_WIDTH]; 01797 String abbr(buff, sizeof(buff), &my_charset_latin1); 01798 char *alloc_buff, *tz_name_buff; 01799 /* 01800 Temporary arrays that are used for loading of data for filling 01801 TIME_ZONE_INFO structure 01802 */ 01803 my_time_t ats[TZ_MAX_TIMES]; 01804 uchar types[TZ_MAX_TIMES]; 01805 TRAN_TYPE_INFO ttis[TZ_MAX_TYPES]; 01806 #ifdef ABBR_ARE_USED 01807 char chars[max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1)))]; 01808 #endif 01809 DBUG_ENTER("tz_load_from_open_tables"); 01810 01811 /* Prepare tz_info for loading also let us make copy of time zone name */ 01812 if (!(alloc_buff= alloc_root(&tz_storage, sizeof(TIME_ZONE_INFO) + 01813 tz_name->length() + 1))) 01814 { 01815 sql_print_error("Out of memory while loading time zone description"); 01816 return 0; 01817 } 01818 tz_info= (TIME_ZONE_INFO *)alloc_buff; 01819 bzero(tz_info, sizeof(TIME_ZONE_INFO)); 01820 tz_name_buff= alloc_buff + sizeof(TIME_ZONE_INFO); 01821 /* 01822 By writing zero to the end we guarantee that we can call ptr() 01823 instead of c_ptr() for time zone name. 01824 */ 01825 strmake(tz_name_buff, tz_name->ptr(), tz_name->length()); 01826 01827 /* 01828 Let us find out time zone id by its name (there is only one index 01829 and it is specifically for this purpose). 01830 */ 01831 table= tz_tables->table; 01832 tz_tables= tz_tables->next_local; 01833 table->use_all_columns(); 01834 table->field[0]->store(tz_name->ptr(), tz_name->length(), 01835 &my_charset_latin1); 01836 /* 01837 It is OK to ignore ha_index_init()/ha_index_end() return values since 01838 mysql.time_zone* tables are MyISAM and these operations always succeed 01839 for MyISAM. 01840 */ 01841 (void)table->file->ha_index_init(0, 1); 01842 01843 if (table->file->index_read(table->record[0], (byte*)table->field[0]->ptr, 01844 0, HA_READ_KEY_EXACT)) 01845 { 01846 #ifdef EXTRA_DEBUG 01847 /* 01848 Most probably user has mistyped time zone name, so no need to bark here 01849 unless we need it for debugging. 01850 */ 01851 sql_print_error("Can't find description of time zone '%s'", tz_name_buff); 01852 #endif 01853 goto end; 01854 } 01855 01856 tzid= (uint)table->field[1]->val_int(); 01857 01858 (void)table->file->ha_index_end(); 01859 01860 /* 01861 Now we need to lookup record in mysql.time_zone table in order to 01862 understand whenever this timezone uses leap seconds (again we are 01863 using the only index in this table). 01864 */ 01865 table= tz_tables->table; 01866 table->use_all_columns(); 01867 tz_tables= tz_tables->next_local; 01868 table->field[0]->store((longlong) tzid, TRUE); 01869 (void)table->file->ha_index_init(0, 1); 01870 01871 if (table->file->index_read(table->record[0], (byte*)table->field[0]->ptr, 01872 0, HA_READ_KEY_EXACT)) 01873 { 01874 sql_print_error("Can't find description of time zone '%u'", tzid); 01875 goto end; 01876 } 01877 01878 /* If Uses_leap_seconds == 'Y' */ 01879 if (table->field[1]->val_int() == 1) 01880 { 01881 tz_info->leapcnt= tz_leapcnt; 01882 tz_info->lsis= tz_lsis; 01883 } 01884 01885 (void)table->file->ha_index_end(); 01886 01887 /* 01888 Now we will iterate through records for out time zone in 01889 mysql.time_zone_transition_type table. Because we want records 01890 only for our time zone guess what are we doing? 01891 Right - using special index. 01892 */ 01893 table= tz_tables->table; 01894 table->use_all_columns(); 01895 tz_tables= tz_tables->next_local; 01896 table->field[0]->store((longlong) tzid, TRUE); 01897 (void)table->file->ha_index_init(0, 1); 01898 01899 // FIXME Is there any better approach than explicitly specifying 4 ??? 01900 res= table->file->index_read(table->record[0], (byte*)table->field[0]->ptr, 01901 4, HA_READ_KEY_EXACT); 01902 while (!res) 01903 { 01904 ttid= (uint)table->field[1]->val_int(); 01905 01906 if (ttid >= TZ_MAX_TYPES) 01907 { 01908 sql_print_error("Error while loading time zone description from " 01909 "mysql.time_zone_transition_type table: too big " 01910 "transition type id"); 01911 goto end; 01912 } 01913 01914 ttis[ttid].tt_gmtoff= (long)table->field[2]->val_int(); 01915 ttis[ttid].tt_isdst= (table->field[3]->val_int() > 0); 01916 01917 #ifdef ABBR_ARE_USED 01918 // FIXME should we do something with duplicates here ? 01919 table->field[4]->val_str(&abbr, &abbr); 01920 if (tz_info->charcnt + abbr.length() + 1 > sizeof(chars)) 01921 { 01922 sql_print_error("Error while loading time zone description from " 01923 "mysql.time_zone_transition_type table: not enough " 01924 "room for abbreviations"); 01925 goto end; 01926 } 01927 ttis[ttid].tt_abbrind= tz_info->charcnt; 01928 memcpy(chars + tz_info->charcnt, abbr.ptr(), abbr.length()); 01929 tz_info->charcnt+= abbr.length(); 01930 chars[tz_info->charcnt]= 0; 01931 tz_info->charcnt++; 01932 01933 DBUG_PRINT("info", 01934 ("time_zone_transition_type table: tz_id=%u tt_id=%u tt_gmtoff=%ld " 01935 "abbr='%s' tt_isdst=%u", tzid, ttid, ttis[ttid].tt_gmtoff, 01936 chars + ttis[ttid].tt_abbrind, ttis[ttid].tt_isdst)); 01937 #else 01938 DBUG_PRINT("info", 01939 ("time_zone_transition_type table: tz_id=%u tt_id=%u tt_gmtoff=%ld " 01940 "tt_isdst=%u", tzid, ttid, ttis[ttid].tt_gmtoff, ttis[ttid].tt_isdst)); 01941 #endif 01942 01943 /* ttid is increasing because we are reading using index */ 01944 DBUG_ASSERT(ttid >= tz_info->typecnt); 01945 01946 tz_info->typecnt= ttid + 1; 01947 01948 res= table->file->index_next_same(table->record[0], 01949 (byte*)table->field[0]->ptr, 4); 01950 } 01951 01952 if (res != HA_ERR_END_OF_FILE) 01953 { 01954 sql_print_error("Error while loading time zone description from " 01955 "mysql.time_zone_transition_type table"); 01956 goto end; 01957 } 01958 01959 (void)table->file->ha_index_end(); 01960 01961 01962 /* 01963 At last we are doing the same thing for records in 01964 mysql.time_zone_transition table. Here we additionaly need records 01965 in ascending order by index scan also satisfies us. 01966 */ 01967 table= tz_tables->table; 01968 table->use_all_columns(); 01969 table->field[0]->store((longlong) tzid, TRUE); 01970 (void)table->file->ha_index_init(0, 1); 01971 01972 // FIXME Is there any better approach than explicitly specifying 4 ??? 01973 res= table->file->index_read(table->record[0], (byte*)table->field[0]->ptr, 01974 4, HA_READ_KEY_EXACT); 01975 while (!res) 01976 { 01977 ttime= (my_time_t)table->field[1]->val_int(); 01978 ttid= (uint)table->field[2]->val_int(); 01979 01980 if (tz_info->timecnt + 1 > TZ_MAX_TIMES) 01981 { 01982 sql_print_error("Error while loading time zone description from " 01983 "mysql.time_zone_transition table: " 01984 "too much transitions"); 01985 goto end; 01986 } 01987 if (ttid + 1 > tz_info->typecnt) 01988 { 01989 sql_print_error("Error while loading time zone description from " 01990 "mysql.time_zone_transition table: " 01991 "bad transition type id"); 01992 goto end; 01993 } 01994 01995 ats[tz_info->timecnt]= ttime; 01996 types[tz_info->timecnt]= ttid; 01997 tz_info->timecnt++; 01998 01999 DBUG_PRINT("info", 02000 ("time_zone_transition table: tz_id=%u tt_time=%lld tt_id=%u", 02001 tzid, (longlong)ttime, ttid)); 02002 02003 res= table->file->index_next_same(table->record[0], 02004 (byte*)table->field[0]->ptr, 4); 02005 } 02006 02007 /* 02008 We have to allow HA_ERR_KEY_NOT_FOUND because some time zones 02009 for example UTC have no transitons. 02010 */ 02011 if (res != HA_ERR_END_OF_FILE && res != HA_ERR_KEY_NOT_FOUND) 02012 { 02013 sql_print_error("Error while loading time zone description from " 02014 "mysql.time_zone_transition table"); 02015 goto end; 02016 } 02017 02018 (void)table->file->ha_index_end(); 02019 table= 0; 02020 02021 /* 02022 Now we will allocate memory and init TIME_ZONE_INFO structure. 02023 */ 02024 if (!(alloc_buff= alloc_root(&tz_storage, 02025 ALIGN_SIZE(sizeof(my_time_t) * 02026 tz_info->timecnt) + 02027 ALIGN_SIZE(tz_info->timecnt) + 02028 #ifdef ABBR_ARE_USED 02029 ALIGN_SIZE(tz_info->charcnt) + 02030 #endif 02031 sizeof(TRAN_TYPE_INFO) * tz_info->typecnt))) 02032 { 02033 sql_print_error("Out of memory while loading time zone description"); 02034 goto end; 02035 } 02036 02037 02038 tz_info->ats= (my_time_t *)alloc_buff; 02039 memcpy(tz_info->ats, ats, tz_info->timecnt * sizeof(my_time_t)); 02040 alloc_buff+= ALIGN_SIZE(sizeof(my_time_t) * tz_info->timecnt); 02041 tz_info->types= (uchar *)alloc_buff; 02042 memcpy(tz_info->types, types, tz_info->timecnt); 02043 alloc_buff+= ALIGN_SIZE(tz_info->timecnt); 02044 #ifdef ABBR_ARE_USED 02045 tz_info->chars= alloc_buff; 02046 memcpy(tz_info->chars, chars, tz_info->charcnt); 02047 alloc_buff+= ALIGN_SIZE(tz_info->charcnt); 02048 #endif 02049 tz_info->ttis= (TRAN_TYPE_INFO *)alloc_buff; 02050 memcpy(tz_info->ttis, ttis, tz_info->typecnt * sizeof(TRAN_TYPE_INFO)); 02051 02052 /* 02053 Let us check how correct our time zone description and build 02054 reversed map. We don't check for tz->timecnt < 1 since it ok for GMT. 02055 */ 02056 if (tz_info->typecnt < 1) 02057 { 02058 sql_print_error("loading time zone without transition types"); 02059 goto end; 02060 } 02061 if (prepare_tz_info(tz_info, &tz_storage)) 02062 { 02063 sql_print_error("Unable to build mktime map for time zone"); 02064 goto end; 02065 } 02066 02067 02068 if (!(tmp_tzname= new (&tz_storage) Tz_names_entry()) || 02069 !(tmp_tzname->tz= new (&tz_storage) Time_zone_db(tz_info, 02070 &(tmp_tzname->name))) || 02071 (tmp_tzname->name.set(tz_name_buff, tz_name->length(), 02072 &my_charset_latin1), 02073 my_hash_insert(&tz_names, (const byte *)tmp_tzname))) 02074 { 02075 sql_print_error("Out of memory while loading time zone"); 02076 goto end; 02077 } 02078 02079 /* 02080 Loading of time zone succeeded 02081 */ 02082 return_val= tmp_tzname->tz; 02083 02084 end: 02085 02086 if (table) 02087 (void)table->file->ha_index_end(); 02088 02089 DBUG_RETURN(return_val); 02090 }
Here is the call graph for this function:

Here is the caller graph for this function:

const uint mon_lengths[2][MONS_PER_YEAR] [static] |
Initial value:
{
{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
{ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
}
Definition at line 504 of file mysql_tzinfo_to_sql.cc.
const uint mon_starts[2][MONS_PER_YEAR] [static] |
Initial value:
{
{ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 },
{ 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335 }
}
Definition at line 510 of file mysql_tzinfo_to_sql.cc.
Definition at line 1354 of file mysql_tzinfo_to_sql.cc.
Referenced by init_common_variables(), my_tz_init(), and sys_var_thd_time_zone::set_default().
Definition at line 1353 of file mysql_tzinfo_to_sql.cc.
Referenced by Event_timed::compute_next_execution_time(), Event_timed::init_ends(), Event_timed::init_execute_at(), Event_timed::init_starts(), Event_timed::mark_last_executed(), Item_func_now_utc::store_now_in_TIME(), Item_func_curtime_utc::store_now_in_TIME(), and Item_func_curdate_utc::store_now_in_TIME().
HASH offset_tzs [static] |
Definition at line 1357 of file mysql_tzinfo_to_sql.cc.
Referenced by my_tz_find(), my_tz_free(), and my_tz_init().
bool time_zone_tables_exist = 1 [static] |
Definition at line 1382 of file mysql_tzinfo_to_sql.cc.
Definition at line 1368 of file mysql_tzinfo_to_sql.cc.
uint tz_leapcnt = 0 [static] |
Definition at line 1374 of file mysql_tzinfo_to_sql.cc.
pthread_mutex_t tz_LOCK [static] |
Definition at line 1367 of file mysql_tzinfo_to_sql.cc.
Definition at line 1375 of file mysql_tzinfo_to_sql.cc.
Referenced by my_tz_init(), and tz_load_from_open_tables().
Definition at line 1356 of file mysql_tzinfo_to_sql.cc.
Referenced by my_tz_find(), my_tz_free(), my_tz_init(), and tz_load_from_open_tables().
MEM_ROOT tz_storage [static] |
Definition at line 1358 of file mysql_tzinfo_to_sql.cc.
Referenced by my_tz_find(), my_tz_free(), my_tz_init(), and tz_load_from_open_tables().
Time_zone_system tz_SYSTEM [static] |
Definition at line 1351 of file mysql_tzinfo_to_sql.cc.
const String tz_SYSTEM_name("SYSTEM", 6,&my_charset_latin1) [static] |
Referenced by Time_zone_system::get_name().
const LEX_STRING tz_tables_db_name = { C_STRING_WITH_LEN("mysql")} [static] |
const LEX_STRING tz_tables_names[MY_TZ_TABLES_COUNT] [static] |
Initial value:
{
{ C_STRING_WITH_LEN("time_zone_name")},
{ C_STRING_WITH_LEN("time_zone")},
{ C_STRING_WITH_LEN("time_zone_transition_type")},
{ C_STRING_WITH_LEN("time_zone_transition")}
}
Definition at line 1390 of file mysql_tzinfo_to_sql.cc.
Referenced by tz_init_table_list().
Time_zone_utc tz_UTC [static] |
Definition at line 1350 of file mysql_tzinfo_to_sql.cc.
const uint year_lengths[2] [static] |
Initial value:
Definition at line 516 of file mysql_tzinfo_to_sql.cc.
1.4.7

