mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-14959: Moved calculation the number of items reserved for exists to in transformation
It is done now before call of select_lex->setup_ref_array() in order to avoid allocation of SP/PS's memory on its second invocation.
This commit is contained in:
@ -727,8 +727,7 @@ setup_without_group(THD *thd, Ref_ptr_array ref_pointer_array,
|
|||||||
ORDER *group,
|
ORDER *group,
|
||||||
List<Window_spec> &win_specs,
|
List<Window_spec> &win_specs,
|
||||||
List<Item_window_func> &win_funcs,
|
List<Item_window_func> &win_funcs,
|
||||||
bool *hidden_group_fields,
|
bool *hidden_group_fields)
|
||||||
uint *reserved)
|
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
enum_parsing_place save_place;
|
enum_parsing_place save_place;
|
||||||
@ -743,13 +742,6 @@ setup_without_group(THD *thd, Ref_ptr_array ref_pointer_array,
|
|||||||
|
|
||||||
thd->lex->allow_sum_func.clear_bit(select->nest_level);
|
thd->lex->allow_sum_func.clear_bit(select->nest_level);
|
||||||
res= setup_conds(thd, tables, leaves, conds);
|
res= setup_conds(thd, tables, leaves, conds);
|
||||||
if (thd->lex->current_select->first_cond_optimization)
|
|
||||||
{
|
|
||||||
if (!res && *conds && ! thd->lex->current_select->merged_into)
|
|
||||||
(*reserved)= (*conds)->exists2in_reserved_items();
|
|
||||||
else
|
|
||||||
(*reserved)= 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* it's not wrong to have non-aggregated columns in a WHERE */
|
/* it's not wrong to have non-aggregated columns in a WHERE */
|
||||||
select->set_non_agg_field_used(saved_non_agg_field_used);
|
select->set_non_agg_field_used(saved_non_agg_field_used);
|
||||||
@ -1318,6 +1310,15 @@ JOIN::prepare(TABLE_LIST *tables_init,
|
|||||||
if (setup_wild(thd, tables_list, fields_list, &all_fields, wild_num,
|
if (setup_wild(thd, tables_list, fields_list, &all_fields, wild_num,
|
||||||
&select_lex->hidden_bit_fields))
|
&select_lex->hidden_bit_fields))
|
||||||
DBUG_RETURN(-1);
|
DBUG_RETURN(-1);
|
||||||
|
|
||||||
|
if (thd->lex->current_select->first_cond_optimization)
|
||||||
|
{
|
||||||
|
if ( conds && ! thd->lex->current_select->merged_into)
|
||||||
|
select_lex->select_n_reserved= conds->exists2in_reserved_items();
|
||||||
|
else
|
||||||
|
select_lex->select_n_reserved= 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (select_lex->setup_ref_array(thd, real_og_num))
|
if (select_lex->setup_ref_array(thd, real_og_num))
|
||||||
DBUG_RETURN(-1);
|
DBUG_RETURN(-1);
|
||||||
|
|
||||||
@ -1336,8 +1337,7 @@ JOIN::prepare(TABLE_LIST *tables_init,
|
|||||||
all_fields, &conds, order, group_list,
|
all_fields, &conds, order, group_list,
|
||||||
select_lex->window_specs,
|
select_lex->window_specs,
|
||||||
select_lex->window_funcs,
|
select_lex->window_funcs,
|
||||||
&hidden_group_fields,
|
&hidden_group_fields))
|
||||||
&select_lex->select_n_reserved))
|
|
||||||
DBUG_RETURN(-1);
|
DBUG_RETURN(-1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user