summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <timour@askmonty.org>2012-12-19 15:56:57 +0200
committerunknown <timour@askmonty.org>2012-12-19 15:56:57 +0200
commite99aa91e90adfd54cc1f460dd8cdd19614f30abc (patch)
tree81d722dbf846e83e0c68c80266e5c0a7e52bcc69 /sql
parent0aad592f49f0fb790f712aa6a644653cf9a0218f (diff)
downloadmariadb-git-e99aa91e90adfd54cc1f460dd8cdd19614f30abc.tar.gz
MDEV-3928: Assertion `example' failed in Item_cache::is_expensive_processor with a 2-level IN subquery
Analysis: The following call stack shows that it is possible to set Item_cache::value_cached, and the relevant value without setting Item_cache::example. #0 Item_cache_temporal::store_packed at item.cc:8395 #1 get_datetime_value at item_cmpfunc.cc:915 #2 resolve_const_item at item.cc:7987 #3 propagate_cond_constants at sql_select.cc:12264 #4 propagate_cond_constants at sql_select.cc:12227 #5 optimize_cond at sql_select.cc:13026 #6 JOIN::optimize at sql_select.cc:1016 #7 st_select_lex::optimize_unflattened_subqueries at sql_lex.cc:3161 #8 JOIN::optimize_unflattened_subqueries at opt_subselect.cc:4880 #9 JOIN::optimize at sql_select.cc:1554 The fix is to set Item_cache_temporal::example even when the value is set directly by Item_cache_temporal::store_packed. This makes the Item_cache_temporal object consistent.
Diffstat (limited to 'sql')
-rw-r--r--sql/item.cc3
-rw-r--r--sql/item.h4
-rw-r--r--sql/item_cmpfunc.cc2
3 files changed, 5 insertions, 4 deletions
diff --git a/sql/item.cc b/sql/item.cc
index 98c27266415..16dbd011f22 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -8388,9 +8388,10 @@ int Item_cache_temporal::save_in_field(Field *field, bool no_conversions)
}
-void Item_cache_temporal::store_packed(longlong val_arg)
+void Item_cache_temporal::store_packed(longlong val_arg, Item *example)
{
/* An explicit values is given, save it. */
+ store(example);
value_cached= true;
value= val_arg;
null_value= false;
diff --git a/sql/item.h b/sql/item.h
index 6324e900f24..0852287cc7f 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -3799,7 +3799,7 @@ public:
bool cache_value();
bool get_date(MYSQL_TIME *ltime, uint fuzzydate);
int save_in_field(Field *field, bool no_conversions);
- void store_packed(longlong val_arg);
+ void store_packed(longlong val_arg, Item *example);
/*
Having a clone_item method tells optimizer that this object
is a constant and need not be optimized further.
@@ -3808,7 +3808,7 @@ public:
Item *clone_item()
{
Item_cache_temporal *item= new Item_cache_temporal(cached_field_type);
- item->store_packed(value);
+ item->store_packed(value, example);
return item;
}
};
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index fed246ef812..b3b20a55ed9 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -912,7 +912,7 @@ get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg,
if (save_arena)
thd->set_query_arena(save_arena);
- cache->store_packed(value);
+ cache->store_packed(value, item);
*cache_arg= cache;
*item_arg= cache_arg;
}