summaryrefslogtreecommitdiff
path: root/sql/item_subselect.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/item_subselect.cc')
-rw-r--r--sql/item_subselect.cc26
1 files changed, 15 insertions, 11 deletions
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index fe2352f3008..ce01fc7a3b8 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -1378,7 +1378,7 @@ Item_in_subselect::Item_in_subselect(Item * left_exp,
{
DBUG_ENTER("Item_in_subselect::Item_in_subselect");
DBUG_PRINT("info", ("in_strategy: %u", (uint)in_strategy));
- left_expr= left_exp;
+ left_expr_orig= left_expr= left_exp;
func= &eq_creator;
init(select_lex, new select_exists_subselect(this));
max_columns= UINT_MAX;
@@ -1401,7 +1401,7 @@ Item_allany_subselect::Item_allany_subselect(Item * left_exp,
:Item_in_subselect(), func_creator(fc), all(all_arg)
{
DBUG_ENTER("Item_allany_subselect::Item_allany_subselect");
- left_expr= left_exp;
+ left_expr_orig= left_expr= left_exp;
func= func_creator(all_arg);
init(select_lex, new select_exists_subselect(this));
max_columns= 1;
@@ -3032,15 +3032,13 @@ Item_in_subselect::select_in_like_transformer(JOIN *join)
arena= thd->activate_stmt_arena_if_needed(&backup);
if (!optimizer)
{
- result= (!(optimizer= new Item_in_optimizer(left_expr, this)));
+ result= (!(optimizer= new Item_in_optimizer(left_expr_orig, this)));
if (result)
goto out;
}
thd->lex->current_select= current->return_after_parsing();
result= optimizer->fix_left(thd);
- /* fix_fields can change reference to left_expr, we need reassign it */
- left_expr= optimizer->arguments()[0];
thd->lex->current_select= current;
if (changed)
@@ -3107,11 +3105,13 @@ bool Item_in_subselect::fix_fields(THD *thd_arg, Item **ref)
{
uint outer_cols_num;
List<Item> *inner_cols;
+ char const *save_where= thd->where;
DBUG_ENTER("Item_in_subselect::fix_fields");
if (test_strategy(SUBS_SEMI_JOIN))
DBUG_RETURN( !( (*ref)= new Item_int(1)) );
+ thd->where= "IN/ALL/ANY subquery";
/*
Check if the outer and inner IN operands match in those cases when we
will not perform IN=>EXISTS transformation. Currently this is when we
@@ -3142,7 +3142,7 @@ bool Item_in_subselect::fix_fields(THD *thd_arg, Item **ref)
if (outer_cols_num != inner_cols->elements)
{
my_error(ER_OPERAND_COLUMNS, MYF(0), outer_cols_num);
- DBUG_RETURN(TRUE);
+ goto err;
}
if (outer_cols_num > 1)
{
@@ -3152,20 +3152,24 @@ bool Item_in_subselect::fix_fields(THD *thd_arg, Item **ref)
{
inner_col= inner_col_it++;
if (inner_col->check_cols(left_expr->element_index(i)->cols()))
- DBUG_RETURN(TRUE);
+ goto err;
}
}
}
- if (thd_arg->lex->is_view_context_analysis() &&
- left_expr && !left_expr->fixed &&
+ if (left_expr && !left_expr->fixed &&
left_expr->fix_fields(thd_arg, &left_expr))
- DBUG_RETURN(TRUE);
+ goto err;
else
if (Item_subselect::fix_fields(thd_arg, ref))
- DBUG_RETURN(TRUE);
+ goto err;
fixed= TRUE;
+ thd->where= save_where;
DBUG_RETURN(FALSE);
+
+err:
+ thd->where= save_where;
+ DBUG_RETURN(TRUE);
}