mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
cleanup: don't pass wild_num to setup_wild()
because internally setup_wild() adjusts select_lex->with_wild directly anyway, so there is no reason to pretend that the number of '*' may be anything else but select_lex->with_wild And don't update select_lex->item_list, because fields can come from anywhere and don't necessarily have to be copied into select_lex.
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user