Commit 6a66ad87 authored by Sergey Petrunya's avatar Sergey Petrunya

MWL#90: Address review feedback part #18

parent 896e9aed
...@@ -371,12 +371,6 @@ class Item_in_subselect :public Item_exists_subselect ...@@ -371,12 +371,6 @@ class Item_in_subselect :public Item_exists_subselect
See also THD::emb_on_expr_nest. See also THD::emb_on_expr_nest.
*/ */
TABLE_LIST *emb_on_expr_nest; TABLE_LIST *emb_on_expr_nest;
/*
Location of the subquery predicate. It is either
- pointer to join nest if the subquery predicate is in the ON expression
- (TABLE_LIST*)1 if the predicate is in the WHERE.
*/
//TABLE_LIST *expr_join_nest;
/* /*
Types of left_expr and subquery's select list allow to perform subquery Types of left_expr and subquery's select list allow to perform subquery
materialization. Currently, we set this to FALSE when it as well could materialization. Currently, we set this to FALSE when it as well could
...@@ -402,6 +396,18 @@ class Item_in_subselect :public Item_exists_subselect ...@@ -402,6 +396,18 @@ class Item_in_subselect :public Item_exists_subselect
TRUE<=>this is a flattenable semi-join, false overwise. TRUE<=>this is a flattenable semi-join, false overwise.
*/ */
bool is_flattenable_semijoin; bool is_flattenable_semijoin;
/*
Used to determine how this subselect item is represented in the item tree,
in case there is a need to locate it there and replace with something else.
Two options are possible:
1. This item is there 'as-is'.
1. This item is wrapped within Item_in_optimizer.
*/
Item *original_item()
{
return is_flattenable_semijoin ? (Item*)this : (Item*)optimizer;
}
bool *get_cond_guard(int i) bool *get_cond_guard(int i)
{ {
......
...@@ -712,16 +712,7 @@ bool convert_join_subqueries_to_semijoins(JOIN *join) ...@@ -712,16 +712,7 @@ bool convert_join_subqueries_to_semijoins(JOIN *join)
{ {
Item **tree= ((*in_subq)->emb_on_expr_nest == NO_JOIN_NEST)? Item **tree= ((*in_subq)->emb_on_expr_nest == NO_JOIN_NEST)?
&join->conds : &((*in_subq)->emb_on_expr_nest->on_expr); &join->conds : &((*in_subq)->emb_on_expr_nest->on_expr);
Item *replace_me= *in_subq; Item *replace_me= (*in_subq)->original_item();
/*
JTBM: the subquery was already mapped with Item_in_optimizer, so we
should search for that, not for original Item_in_subselect.
TODO: what about delaying that rewrite until here?
*/
if (!(*in_subq)->is_flattenable_semijoin)
{
replace_me= (*in_subq)->optimizer;
}
if (replace_where_subcondition(join, tree, replace_me, new Item_int(1), if (replace_where_subcondition(join, tree, replace_me, new Item_int(1),
FALSE)) FALSE))
DBUG_RETURN(TRUE); /* purecov: inspected */ DBUG_RETURN(TRUE); /* purecov: inspected */
...@@ -756,18 +747,7 @@ bool convert_join_subqueries_to_semijoins(JOIN *join) ...@@ -756,18 +747,7 @@ bool convert_join_subqueries_to_semijoins(JOIN *join)
bool do_fix_fields= !(*in_subq)->substitution->fixed; bool do_fix_fields= !(*in_subq)->substitution->fixed;
Item **tree= ((*in_subq)->emb_on_expr_nest == NO_JOIN_NEST)? Item **tree= ((*in_subq)->emb_on_expr_nest == NO_JOIN_NEST)?
&join->conds : &((*in_subq)->emb_on_expr_nest->on_expr); &join->conds : &((*in_subq)->emb_on_expr_nest->on_expr);
Item *replace_me= (*in_subq)->original_item();
Item *replace_me= *in_subq;
/*
JTBM: the subquery was already mapped with Item_in_optimizer, so we
should search for that, not for original Item_in_subselect.
TODO: what about delaying that rewrite until here?
*/
if (!(*in_subq)->is_flattenable_semijoin)
{
replace_me= (*in_subq)->optimizer;
}
if (replace_where_subcondition(join, tree, replace_me, substitute, if (replace_where_subcondition(join, tree, replace_me, substitute,
do_fix_fields)) do_fix_fields))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment