diff options
author | dlenev@brandersnatch.localdomain <> | 2004-08-10 12:42:31 +0400 |
---|---|---|
committer | dlenev@brandersnatch.localdomain <> | 2004-08-10 12:42:31 +0400 |
commit | f49d4f5350299e31ec4176210e2d457795fb5ed8 (patch) | |
tree | 4016d026abe9ef6a9eb602093cce08af13970126 /sql/item_timefunc.cc | |
parent | bcbbfc3bb84b490d0f16d555c5e21b96dc105c23 (diff) | |
download | mariadb-git-f49d4f5350299e31ec4176210e2d457795fb5ed8.tar.gz |
Fix for bug #4508 "CONVERT_TZ() function with new time zone as param crashes server".
Instead of trying to open time zone tables during calculation of CONVERT_TZ() function
or setting of @@time_zone variable we should open and lock them with the rest of
statement's table (so we should add them to global table list) and after that use such
pre-opened tables for loading info about time zones.
Diffstat (limited to 'sql/item_timefunc.cc')
-rw-r--r-- | sql/item_timefunc.cc | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index cc320addd47..73aec7e8bdd 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -1648,19 +1648,29 @@ bool Item_func_from_unixtime::get_date(TIME *ltime, void Item_func_convert_tz::fix_length_and_dec() -{ - String str; - - thd= current_thd; +{ collation.set(&my_charset_bin); decimals= 0; max_length= MAX_DATETIME_WIDTH*MY_CHARSET_BIN_MB_MAXLEN; +} + + +bool +Item_func_convert_tz::fix_fields(THD *thd_arg, TABLE_LIST *tables_arg, Item **ref) +{ + String str; + if (Item_date_func::fix_fields(thd_arg, tables_arg, ref)) + return 1; + + tz_tables= thd_arg->lex->time_zone_tables_used; if (args[1]->const_item()) - from_tz= my_tz_find(thd, args[1]->val_str(&str)); - + from_tz= my_tz_find(args[1]->val_str(&str), tz_tables); + if (args[2]->const_item()) - to_tz= my_tz_find(thd, args[2]->val_str(&str)); + to_tz= my_tz_find(args[2]->val_str(&str), tz_tables); + + return 0; } @@ -1701,10 +1711,10 @@ bool Item_func_convert_tz::get_date(TIME *ltime, String str; if (!args[1]->const_item()) - from_tz= my_tz_find(thd, args[1]->val_str(&str)); + from_tz= my_tz_find(args[1]->val_str(&str), tz_tables); if (!args[2]->const_item()) - to_tz= my_tz_find(thd, args[2]->val_str(&str)); + to_tz= my_tz_find(args[2]->val_str(&str), tz_tables); if (from_tz==0 || to_tz==0 || get_arg0_date(ltime, 0)) { |