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.cc32
1 files changed, 8 insertions, 24 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 57038c1a64a..feb79990796 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -7459,17 +7459,16 @@ static bool setup_natural_join_row_types(THD *thd,
****************************************************************************/
int setup_wild(THD *thd, TABLE_LIST *tables, List<Item> &fields,
- List<Item> *sum_func_list,
- uint wild_num, uint *hidden_bit_fields)
+ List<Item> *sum_func_list, SELECT_LEX *select_lex)
{
- if (!wild_num)
- return(0);
-
Item *item;
List_iterator<Item> it(fields);
Query_arena *arena, backup;
DBUG_ENTER("setup_wild");
+ if (!select_lex->with_wild)
+ DBUG_RETURN(0);
+
/*
Don't use arena if we are not in prepared statements or stored procedures
For PS/SP we have to use arena to remember the changes
@@ -7477,7 +7476,7 @@ int setup_wild(THD *thd, TABLE_LIST *tables, List<Item> &fields,
arena= thd->activate_stmt_arena_if_needed(&backup);
thd->lex->current_select->cur_pos_in_select_list= 0;
- while (wild_num && (item= it++))
+ while (select_lex->with_wild && (item= it++))
{
if (item->type() == Item::FIELD_ITEM &&
((Item_field*) item)->field_name.str == star_clex_str.str &&
@@ -7500,7 +7499,7 @@ int setup_wild(THD *thd, TABLE_LIST *tables, List<Item> &fields,
else if (insert_fields(thd, ((Item_field*) item)->context,
((Item_field*) item)->db_name.str,
((Item_field*) item)->table_name.str, &it,
- any_privileges, hidden_bit_fields))
+ any_privileges, &select_lex->hidden_bit_fields))
{
if (arena)
thd->restore_active_arena(arena, &backup);
@@ -7515,30 +7514,15 @@ int setup_wild(THD *thd, TABLE_LIST *tables, List<Item> &fields,
*/
sum_func_list->elements+= fields.elements - elem;
}
- wild_num--;
+ select_lex->with_wild--;
}
else
thd->lex->current_select->cur_pos_in_select_list++;
}
+ DBUG_ASSERT(!select_lex->with_wild);
thd->lex->current_select->cur_pos_in_select_list= UNDEF_POS;
if (arena)
- {
- /* make * substituting permanent */
- SELECT_LEX *select_lex= thd->lex->current_select;
- select_lex->with_wild= 0;
-#ifdef HAVE_valgrind
- if (&select_lex->item_list != &fields) // Avoid warning
-#endif
- /*
- The assignment below is translated to memcpy() call (at least on some
- platforms). memcpy() expects that source and destination areas do not
- overlap. That problem was detected by valgrind.
- */
- if (&select_lex->item_list != &fields)
- select_lex->item_list= fields;
-
thd->restore_active_arena(arena, &backup);
- }
DBUG_RETURN(0);
}