The world's most popular open source database
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Classes | |
| class | Time_zone |
Functions | |
| TABLE_LIST * | my_tz_get_table_list (THD *thd, TABLE_LIST ***global_next_ptr) |
| Time_zone * | my_tz_find (const String *name, TABLE_LIST *tz_tables) |
| Time_zone * | my_tz_find_with_opening_tz_tables (THD *thd, const String *name) |
| my_bool | my_tz_init (THD *org_thd, const char *default_tzname, my_bool bootstrap) |
| void | my_tz_free () |
| my_time_t | sec_since_epoch_TIME (TIME *t) |
| bool | my_tz_check_n_skip_implicit_tables (TABLE_LIST **table, TABLE_LIST *tz_tables) |
Variables | |
| Time_zone * | my_tz_UTC |
| Time_zone * | my_tz_SYSTEM |
| TABLE_LIST | fake_time_zone_tables_list |
| static const int | MY_TZ_TABLES_COUNT = 4 |
| bool my_tz_check_n_skip_implicit_tables | ( | TABLE_LIST ** | table, | |
| TABLE_LIST * | tz_tables | |||
| ) | [inline] |
Definition at line 98 of file tztime.h.
References FALSE, MY_TZ_TABLES_COUNT, SELECT_ACL, and TRUE.
Referenced by check_table_access(), and multi_update_precheck().
00100 { 00101 if (*table == tz_tables) 00102 { 00103 for (int i= 0; i < MY_TZ_TABLES_COUNT; i++) 00104 (*table)[i].grant.privilege= SELECT_ACL; 00105 (*table)+= MY_TZ_TABLES_COUNT - 1; 00106 return TRUE; 00107 } 00108 return FALSE; 00109 }
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.
References current_thd, DBUG_ASSERT, DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, hash_search(), my_hash_insert(), name, offset, offset_tzs, pthread_mutex_lock, pthread_mutex_unlock, sql_print_error(), str_to_offset(), Tz_names_entry::tz, tz_load_from_open_tables(), tz_names, tz_storage, and VOID.
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 call graph for this function:

Definition at line 2289 of file mysql_tzinfo_to_sql.cc.
References close_thread_tables(), DBUG_ASSERT, DBUG_ENTER, DBUG_RETURN, my_tz_find(), MY_TZ_TABLES_COUNT, name, simple_open_n_lock_tables(), and tz_init_table_list().
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 }
Here is the call graph for this function:

| void my_tz_free | ( | ) |
Definition at line 1752 of file mysql_tzinfo_to_sql.cc.
References free_root(), hash_free(), MYF, offset_tzs, pthread_mutex_destroy, tz_names, tz_storage, and VOID.
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 call 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.
References DBUG_ENTER, DBUG_RETURN, fake_time_zone_tables_list, MY_TZ_TABLES_COUNT, and tz_init_table_list().
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 }
Here is the call graph for this function:

Definition at line 1555 of file mysql_tzinfo_to_sql.cc.
References alloc_root(), bzero, close_thread_tables(), db, DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, st_table::field, st_table::file, global_system_variables, HA_ERR_END_OF_FILE, handler::ha_index_end(), handler::ha_index_init(), hash_free(), hash_init, handler::index_first(), handler::index_next(), init_alloc_root(), lsinfo::ls_corr, lsinfo::ls_trans, my_charset_latin1, my_hash_insert(), MY_MUTEX_INIT_FAST, my_offset_tzs_get_key(), my_pthread_setspecific_ptr, my_tz_find(), my_tz_free(), my_tz_names_get_key(), my_tz_SYSTEM, MY_TZ_TABLES_COUNT, Tz_names_entry::name, offset_tzs, pthread_mutex_init, st_table::record, String::set(), simple_open_n_lock_tables(), sql_print_error(), sql_print_warning(), STRING_WITH_LEN, system_variables::time_zone, TL_READ, Tz_names_entry::tz, tz_init_table_list(), tz_lsis, TZ_MAX_LEAPS, tz_names, tz_storage, st_table::use_all_columns(), Field::val_int(), and VOID.
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 call graph for this function:

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

Definition at line 1481 of file mysql_tzinfo_to_sql.cc.
Definition at line 1354 of file mysql_tzinfo_to_sql.cc.
const int MY_TZ_TABLES_COUNT = 4 [static] |
Definition at line 79 of file tztime.h.
Referenced by my_tz_check_n_skip_implicit_tables(), my_tz_find_with_opening_tz_tables(), my_tz_get_table_list(), my_tz_init(), and tz_init_table_list().
Definition at line 1353 of file mysql_tzinfo_to_sql.cc.
1.4.7

