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.cc50
1 files changed, 22 insertions, 28 deletions
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index 4c1ffeecc97..91a31502780 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -125,7 +125,7 @@ bool Item_subselect::fix_fields(THD *thd_param, TABLE_LIST *tables, Item **ref)
{
DBUG_ASSERT(fixed == 0);
engine->set_thd((thd= thd_param));
- stmt= thd->current_statement;
+ arena= thd->current_arena;
char const *save_where= thd->where;
int res= engine->prepare();
@@ -336,8 +336,8 @@ Item_singlerow_subselect::select_transformer(JOIN *join)
if (join->conds || join->having)
{
Item *cond;
- if (stmt)
- thd->set_n_backup_item_arena(stmt, &backup);
+ if (arena)
+ thd->set_n_backup_item_arena(arena, &backup);
if (!join->having)
cond= join->conds;
@@ -350,15 +350,15 @@ Item_singlerow_subselect::select_transformer(JOIN *join)
new Item_null())))
goto err;
}
- if (stmt)
- thd->restore_backup_item_arena(stmt, &backup);
+ if (arena)
+ thd->restore_backup_item_arena(arena, &backup);
return RES_REDUCE;
}
return RES_OK;
err:
- if (stmt)
- thd->restore_backup_item_arena(stmt, &backup);
+ if (arena)
+ thd->restore_backup_item_arena(arena, &backup);
return RES_ERROR;
}
@@ -638,8 +638,8 @@ Item_in_subselect::single_value_transformer(JOIN *join,
Statement backup;
thd->where= "scalar IN/ALL/ANY subquery";
- if (stmt)
- thd->set_n_backup_item_arena(stmt, &backup);
+ if (arena)
+ thd->set_n_backup_item_arena(arena, &backup);
if (select_lex->item_list.elements > 1)
{
@@ -852,21 +852,21 @@ Item_in_subselect::single_value_transformer(JOIN *join,
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
ER_SELECT_REDUCED, warn_buff);
}
- if (stmt)
- thd->restore_backup_item_arena(stmt, &backup);
+ if (arena)
+ thd->restore_backup_item_arena(arena, &backup);
DBUG_RETURN(RES_REDUCE);
}
}
}
ok:
- if (stmt)
- thd->restore_backup_item_arena(stmt, &backup);
+ if (arena)
+ thd->restore_backup_item_arena(arena, &backup);
DBUG_RETURN(RES_OK);
err:
- if (stmt)
- thd->restore_backup_item_arena(stmt, &backup);
+ if (arena)
+ thd->restore_backup_item_arena(arena, &backup);
DBUG_RETURN(RES_ERROR);
}
@@ -884,8 +884,8 @@ Item_in_subselect::row_value_transformer(JOIN *join)
Item *item= 0;
thd->where= "row IN/ALL/ANY subquery";
- if (stmt)
- thd->set_n_backup_item_arena(stmt, &backup);
+ if (arena)
+ thd->set_n_backup_item_arena(arena, &backup);
SELECT_LEX *select_lex= join->select_lex;
@@ -969,13 +969,13 @@ Item_in_subselect::row_value_transformer(JOIN *join)
if (join->conds->fix_fields(thd, join->tables_list, 0))
goto err;
}
- if (stmt)
- thd->restore_backup_item_arena(stmt, &backup);
+ if (arena)
+ thd->restore_backup_item_arena(arena, &backup);
DBUG_RETURN(RES_OK);
err:
- if (stmt)
- thd->restore_backup_item_arena(stmt, &backup);
+ if (arena)
+ thd->restore_backup_item_arena(arena, &backup);
DBUG_RETURN(RES_ERROR);
}
@@ -1037,13 +1037,7 @@ subselect_single_select_engine(st_select_lex *select,
{
select_lex= select;
SELECT_LEX_UNIT *unit= select_lex->master_unit();
- unit->offset_limit_cnt= unit->global_parameters->offset_limit;
- unit->select_limit_cnt= unit->global_parameters->select_limit+
- unit->global_parameters ->offset_limit;
- if (unit->select_limit_cnt < unit->global_parameters->select_limit)
- unit->select_limit_cnt= HA_POS_ERROR; // no limit
- if (unit->select_limit_cnt == HA_POS_ERROR)
- select_lex->options&= ~OPTION_FOUND_ROWS;
+ unit->set_limit(unit->global_parameters, select_lex);
unit->item= item;
this->select_lex= select_lex;
}