summaryrefslogtreecommitdiff
path: root/sql/item_timefunc.cc
diff options
context:
space:
mode:
authordlenev@mysql.com <>2005-01-28 10:22:50 +0300
committerdlenev@mysql.com <>2005-01-28 10:22:50 +0300
commit2276bfa37470806bca135c83fcfb9c7678ec0164 (patch)
tree654d19586759f3b5343d53fba8af67eb8e5ce42f /sql/item_timefunc.cc
parentaf12846505834548225cfa636641379756ae7dc8 (diff)
parentc80c503a1b869bfde11b104fdde9d05f3d0de5a0 (diff)
downloadmariadb-git-2276bfa37470806bca135c83fcfb9c7678ec0164.tar.gz
Manual merge of fixes for bugs #7899 "CREATE TABLE .. SELECT .. and
CONVERT_TZ() function does not work well together" and bug #7705 "CONVERT_TZ() crashes with subquery/WHERE on index column" in 5.0 tree.
Diffstat (limited to 'sql/item_timefunc.cc')
-rw-r--r--sql/item_timefunc.cc30
1 files changed, 19 insertions, 11 deletions
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index 5a069aee554..3d1feee1f8c 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -1662,6 +1662,7 @@ void Item_func_convert_tz::fix_length_and_dec()
collation.set(&my_charset_bin);
decimals= 0;
max_length= MAX_DATETIME_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
+ maybe_null= 1;
}
@@ -1674,12 +1675,6 @@ Item_func_convert_tz::fix_fields(THD *thd_arg, TABLE_LIST *tables_arg, Item **re
tz_tables= thd_arg->lex->time_zone_tables_used;
- if (args[1]->const_item())
- from_tz= my_tz_find(args[1]->val_str(&str), tz_tables);
-
- if (args[2]->const_item())
- to_tz= my_tz_find(args[2]->val_str(&str), tz_tables);
-
return FALSE;
}
@@ -1719,13 +1714,19 @@ bool Item_func_convert_tz::get_date(TIME *ltime,
my_time_t my_time_tmp;
bool not_used;
String str;
-
- if (!args[1]->const_item())
+
+ if (!from_tz_cached)
+ {
from_tz= my_tz_find(args[1]->val_str(&str), tz_tables);
-
- if (!args[2]->const_item())
+ from_tz_cached= args[1]->const_item();
+ }
+
+ if (!to_tz_cached)
+ {
to_tz= my_tz_find(args[2]->val_str(&str), tz_tables);
-
+ to_tz_cached= args[2]->const_item();
+ }
+
if (from_tz==0 || to_tz==0 || get_arg0_date(ltime, TIME_NO_ZERO_DATE))
{
null_value= 1;
@@ -1747,6 +1748,13 @@ bool Item_func_convert_tz::get_date(TIME *ltime,
}
+void Item_func_convert_tz::cleanup()
+{
+ from_tz_cached= to_tz_cached= 0;
+ Item_date_func::cleanup();
+}
+
+
void Item_date_add_interval::fix_length_and_dec()
{
enum_field_types arg0_field_type;