summaryrefslogtreecommitdiff
path: root/sql/item_subselect.cc
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2017-06-19 17:28:08 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2017-06-19 17:28:08 +0300
commit1e3886ae80c44a39ec3e4061b4ea3131cdcef213 (patch)
treece95518792d1432b669ba13a248928e74e81a9bb /sql/item_subselect.cc
parent0fe7d8a2a221196d977e5efe3f3dedb22806bb53 (diff)
parent3a7201ea922f6d3373924c413fdb4b108f6208c5 (diff)
downloadmariadb-git-1e3886ae80c44a39ec3e4061b4ea3131cdcef213.tar.gz
Merge bb-10.2-ext into 10.3
Diffstat (limited to 'sql/item_subselect.cc')
-rw-r--r--sql/item_subselect.cc29
1 files changed, 27 insertions, 2 deletions
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index 09fbf3e239c..dd362cbc15e 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -1425,8 +1425,9 @@ Item_in_subselect::Item_in_subselect(THD *thd, Item * left_exp,
st_select_lex *select_lex):
Item_exists_subselect(thd), left_expr_cache(0), first_execution(TRUE),
in_strategy(SUBS_NOT_TRANSFORMED),
- pushed_cond_guards(NULL), is_jtbm_merged(FALSE), is_jtbm_const_tab(FALSE),
- is_flattenable_semijoin(FALSE), is_registered_semijoin(FALSE),
+ pushed_cond_guards(NULL), do_not_convert_to_sj(FALSE), is_jtbm_merged(FALSE),
+ is_jtbm_const_tab(FALSE), is_flattenable_semijoin(FALSE),
+ is_registered_semijoin(FALSE),
upper_item(0)
{
DBUG_ENTER("Item_in_subselect::Item_in_subselect");
@@ -2587,6 +2588,27 @@ bool Item_in_subselect::inject_in_to_exists_cond(JOIN *join_arg)
DBUG_ENTER("Item_in_subselect::inject_in_to_exists_cond");
DBUG_ASSERT(thd == join_arg->thd);
+ if (select_lex->min_max_opt_list.elements)
+ {
+ /*
+ MIN/MAX optimizations have been applied to Item_sum objects
+ of the subquery this subquery predicate in opt_sum_query().
+ Injection of new condition invalidates this optimizations.
+ Thus those optimizations must be rolled back.
+ */
+ List_iterator_fast<Item_sum> it(select_lex->min_max_opt_list);
+ Item_sum *item;
+ while ((item= it++))
+ {
+ item->clear();
+ item->reset_forced_const();
+ }
+ if (where_item)
+ where_item->update_used_tables();
+ if (having_item)
+ having_item->update_used_tables();
+ }
+
if (where_item)
{
List<Item> *and_args= NULL;
@@ -3761,7 +3783,10 @@ int subselect_single_select_engine::exec()
}
}
if (item->engine_changed(this))
+ {
+ thd->lex->current_select= save_select;
DBUG_RETURN(1);
+ }
}
if (select_lex->uncacheable &&
select_lex->uncacheable != UNCACHEABLE_EXPLAIN