diff options
author | dlenev@brandersnatch.localdomain <> | 2005-01-26 22:25:02 +0300 |
---|---|---|
committer | dlenev@brandersnatch.localdomain <> | 2005-01-26 22:25:02 +0300 |
commit | 80282016c230ea6e91d629b1147a40e262487cb0 (patch) | |
tree | 72a9f7c083067cfd405c029c61debdc8f66d5fe0 /sql/set_var.cc | |
parent | 373dbb475045622e40a74b27292bb2cc78941a87 (diff) | |
download | mariadb-git-80282016c230ea6e91d629b1147a40e262487cb0.tar.gz |
Fix for bug #7899 "CREATE TABLE .. SELECT .. and CONVERT_TZ() function
does not work well together". Now using simplier and more correct
implementation of st_lex::unlink_first_table()/link_first_table_back()
(It also nicely handles case when global table list is created because
of implictly used time zone tables). (2nd attempt)
Fix for bug #7705 "CONVERT_TZ() crashes with subquery/WHERE on index
column". Implemented new approach for caching objects for constant
time zone arguments. Now instead of determining whenever these arguments
are constants and performing time zone lookup at fix_fields() stage, we
do it on first get_date() invocation.
Cleanup of global @@time_zone variable handling.
Diffstat (limited to 'sql/set_var.cc')
-rw-r--r-- | sql/set_var.cc | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/sql/set_var.cc b/sql/set_var.cc index e44ac742abe..99032a29651 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -2438,8 +2438,15 @@ bool sys_var_thd_time_zone::check(THD *thd, set_var *var) bool sys_var_thd_time_zone::update(THD *thd, set_var *var) { - /* We are using Time_zone object found during check() phase */ - *get_tz_ptr(thd,var->type)= var->save_result.time_zone; + /* We are using Time_zone object found during check() phase. */ + if (var->type == OPT_GLOBAL) + { + pthread_mutex_lock(&LOCK_global_system_variables); + global_system_variables.time_zone= var->save_result.time_zone; + pthread_mutex_unlock(&LOCK_global_system_variables); + } + else + thd->variables.time_zone= var->save_result.time_zone; return 0; } @@ -2451,27 +2458,25 @@ byte *sys_var_thd_time_zone::value_ptr(THD *thd, enum_var_type type, We can use ptr() instead of c_ptr() here because String contaning time zone name is guaranteed to be zero ended. */ - return (byte *)((*get_tz_ptr(thd,type))->get_name()->ptr()); -} - - -Time_zone** sys_var_thd_time_zone::get_tz_ptr(THD *thd, - enum_var_type type) -{ if (type == OPT_GLOBAL) - return &global_system_variables.time_zone; + return (byte *)(global_system_variables.time_zone->get_name()->ptr()); else - return &thd->variables.time_zone; + return (byte *)(thd->variables.time_zone->get_name()->ptr()); } void sys_var_thd_time_zone::set_default(THD *thd, enum_var_type type) { + pthread_mutex_lock(&LOCK_global_system_variables); if (type == OPT_GLOBAL) { if (default_tz_name) { String str(default_tz_name, &my_charset_latin1); + /* + We are guaranteed to find this time zone since its existence + is checked during start-up. + */ global_system_variables.time_zone= my_tz_find(&str, thd->lex->time_zone_tables_used); } @@ -2480,6 +2485,7 @@ void sys_var_thd_time_zone::set_default(THD *thd, enum_var_type type) } else thd->variables.time_zone= global_system_variables.time_zone; + pthread_mutex_unlock(&LOCK_global_system_variables); } /* |