summaryrefslogtreecommitdiff
path: root/sql/sql_base.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_base.cc')
-rw-r--r--sql/sql_base.cc43
1 files changed, 22 insertions, 21 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 4efdd3edbcd..eed7012966d 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -2188,14 +2188,15 @@ int setup_wild(THD *thd, TABLE_LIST *tables, List<Item> &fields,
{
if (!wild_num)
return 0;
- Statement *stmt= thd->current_statement, backup;
+ Item_arena *arena= thd->current_arena, backup;
/*
If we are in preparing prepared statement phase then we have change
temporary mem_root to statement mem root to save changes of SELECT list
*/
- if (stmt)
- thd->set_n_backup_item_arena(stmt, &backup);
+ if (arena->is_stmt_prepare())
+ thd->set_n_backup_item_arena(arena, &backup);
+
reg2 Item *item;
List_iterator<Item> it(fields);
while ( wild_num && (item= it++))
@@ -2219,8 +2220,8 @@ int setup_wild(THD *thd, TABLE_LIST *tables, List<Item> &fields,
else if (insert_fields(thd,tables,((Item_field*) item)->db_name,
((Item_field*) item)->table_name, &it))
{
- if (stmt)
- thd->restore_backup_item_arena(stmt, &backup);
+ if (arena->is_stmt_prepare())
+ thd->restore_backup_item_arena(arena, &backup);
return (-1);
}
if (sum_func_list)
@@ -2235,8 +2236,8 @@ int setup_wild(THD *thd, TABLE_LIST *tables, List<Item> &fields,
wild_num--;
}
}
- if (stmt)
- thd->restore_backup_item_arena(stmt, &backup);
+ if (arena->is_stmt_prepare())
+ thd->restore_backup_item_arena(arena, &backup);
return 0;
}
@@ -2449,7 +2450,7 @@ insert_fields(THD *thd,TABLE_LIST *tables, const char *db_name,
int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds)
{
table_map not_null_tables= 0;
- Statement *stmt= thd->current_statement, backup;
+ Item_arena *arena= thd->current_arena, backup;
DBUG_ENTER("setup_conds");
thd->set_query_id=1;
@@ -2488,12 +2489,12 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds)
!(specialflag & SPECIAL_NO_NEW_FUNC)))
{
table->outer_join= 0;
- if (stmt)
- thd->set_n_backup_item_arena(stmt, &backup);
+ if (arena->is_stmt_prepare())
+ thd->set_n_backup_item_arena(arena, &backup);
*conds= and_conds(*conds, table->on_expr);
table->on_expr=0;
- if (stmt)
- thd->restore_backup_item_arena(stmt, &backup);
+ if (arena->is_stmt_prepare())
+ thd->restore_backup_item_arena(arena, &backup);
if ((*conds) && !(*conds)->fixed &&
(*conds)->fix_fields(thd, tables, conds))
DBUG_RETURN(1);
@@ -2501,8 +2502,8 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds)
}
if (table->natural_join)
{
- if (stmt)
- thd->set_n_backup_item_arena(stmt, &backup);
+ if (arena->is_stmt_prepare())
+ thd->set_n_backup_item_arena(arena, &backup);
/* Make a join of all fields with have the same name */
TABLE *t1= table->table;
TABLE *t2= table->natural_join->table;
@@ -2543,8 +2544,8 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds)
{
*conds= and_conds(*conds, cond_and);
// fix_fields() should be made with temporary memory pool
- if (stmt)
- thd->restore_backup_item_arena(stmt, &backup);
+ if (arena->is_stmt_prepare())
+ thd->restore_backup_item_arena(arena, &backup);
if (*conds && !(*conds)->fixed)
{
if ((*conds)->fix_fields(thd, tables, conds))
@@ -2555,8 +2556,8 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds)
{
table->on_expr= and_conds(table->on_expr, cond_and);
// fix_fields() should be made with temporary memory pool
- if (stmt)
- thd->restore_backup_item_arena(stmt, &backup);
+ if (arena->is_stmt_prepare())
+ thd->restore_backup_item_arena(arena, &backup);
if (table->on_expr && !table->on_expr->fixed)
{
if (table->on_expr->fix_fields(thd, tables, &table->on_expr))
@@ -2567,7 +2568,7 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds)
}
}
- if (stmt)
+ if (arena->is_stmt_prepare())
{
/*
We are in prepared statement preparation code => we should store
@@ -2580,8 +2581,8 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds)
DBUG_RETURN(test(thd->net.report_error));
err:
- if (stmt)
- thd->restore_backup_item_arena(stmt, &backup);
+ if (arena->is_stmt_prepare())
+ thd->restore_backup_item_arena(arena, &backup);
DBUG_RETURN(1);
}