summaryrefslogtreecommitdiff
path: root/sql/item_cmpfunc.cc
diff options
context:
space:
mode:
authorunknown <tsmith@quadxeon.mysql.com>2007-05-21 20:50:08 +0200
committerunknown <tsmith@quadxeon.mysql.com>2007-05-21 20:50:08 +0200
commit221e23ad721cb98156ff313d6ee924c88765782e (patch)
tree250875cd3699ebe9837bdd77ab3f2b35ff4eb6e0 /sql/item_cmpfunc.cc
parentf40047df9c72d1516d9a2f7d121dc7ce165ef419 (diff)
parent8b33c41554b1f9ac173a047f55fa0c522f28af35 (diff)
downloadmariadb-git-221e23ad721cb98156ff313d6ee924c88765782e.tar.gz
Merge quadxeon.mysql.com:/benchmarks/ext3/TOSAVE/tsmith/bk/50
into quadxeon.mysql.com:/benchmarks/ext3/TOSAVE/tsmith/bk/maint/50 configure.in: Auto merged mysql-test/r/strict.result: Auto merged mysql-test/r/type_datetime.result: Auto merged mysql-test/t/type_datetime.test: Auto merged sql/item.cc: Auto merged sql/item_cmpfunc.cc: Auto merged
Diffstat (limited to 'sql/item_cmpfunc.cc')
-rw-r--r--sql/item_cmpfunc.cc20
1 files changed, 15 insertions, 5 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 92a6f5c06da..0de9ef3e9ad 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -637,7 +637,13 @@ Arg_comparator::can_compare_as_dates(Item *a, Item *b, ulonglong *const_value)
if (cmp_type != CMP_DATE_DFLT)
{
- if (cmp_type != CMP_DATE_WITH_DATE && str_arg->const_item())
+ /*
+ Do not cache GET_USER_VAR() function as its const_item() may return TRUE
+ for the current thread but it still may change during the execution.
+ */
+ if (cmp_type != CMP_DATE_WITH_DATE && str_arg->const_item() &&
+ (str_arg->type() != Item::FUNC_ITEM ||
+ ((Item_func*)str_arg)->functype() != Item_func::GUSERVAR_FUNC))
{
THD *thd= current_thd;
ulonglong value;
@@ -665,7 +671,7 @@ int Arg_comparator::set_cmp_func(Item_bool_func2 *owner_arg,
Item_result type)
{
enum enum_date_cmp_type cmp_type;
- ulonglong const_value;
+ ulonglong const_value= (ulonglong)-1;
a= a1;
b= a2;
@@ -678,8 +684,7 @@ int Arg_comparator::set_cmp_func(Item_bool_func2 *owner_arg,
a_cache= 0;
b_cache= 0;
- if (cmp_type != CMP_DATE_WITH_DATE &&
- ((*b)->const_item() || (*a)->const_item()))
+ if (const_value != (ulonglong)-1)
{
Item_cache_int *cache= new Item_cache_int();
/* Mark the cache as non-const to prevent re-caching. */
@@ -785,7 +790,12 @@ get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg,
MYSQL_TYPE_DATE ? MYSQL_TIMESTAMP_DATE : MYSQL_TIMESTAMP_DATETIME;
value= get_date_from_str(thd, str, t_type, warn_item->name, &error);
}
- if (item->const_item() && cache_arg)
+ /*
+ Do not cache GET_USER_VAR() function as its const_item() may return TRUE
+ for the current thread but it still may change during the execution.
+ */
+ if (item->const_item() && cache_arg && (item->type() != Item::FUNC_ITEM ||
+ ((Item_func*)item)->functype() != Item_func::GUSERVAR_FUNC))
{
Item_cache_int *cache= new Item_cache_int();
/* Mark the cache as non-const to prevent re-caching. */