Skip to content

Commit

Permalink
fix the comparison in st_select_lex::setup_ref_array()
Browse files Browse the repository at this point in the history
the array only needs to be reallocated if it's smaller
than needed. Being larger is ok.

also: remove a duplicated check (merge error)
  • Loading branch information
vuvova committed Jul 5, 2017
1 parent 5c30fcf commit c917ba1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 16 deletions.
3 changes: 1 addition & 2 deletions sql/item.cc
Original file line number Diff line number Diff line change
Expand Up @@ -494,8 +494,7 @@ Item::Item(THD *thd):
{
enum_parsing_place place=
thd->lex->current_select->parsing_place;
if (place == SELECT_LIST ||
place == IN_HAVING)
if (place == SELECT_LIST || place == IN_HAVING)
thd->lex->current_select->select_n_having_items++;
}
}
Expand Down
5 changes: 2 additions & 3 deletions sql/item_subselect.cc
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,8 @@ void Item_subselect::init(st_select_lex *select_lex,
do not take into account expression inside aggregate functions because
they can access original table fields
*/
parsing_place= (outer_select->in_sum_expr ?
NO_MATTER :
outer_select->parsing_place);
parsing_place= (outer_select->in_sum_expr ? NO_MATTER
: outer_select->parsing_place);
if (unit->is_union())
engine= new subselect_union_engine(unit, result, this);
else
Expand Down
12 changes: 1 addition & 11 deletions sql/sql_lex.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2665,24 +2665,14 @@ bool st_select_lex::setup_ref_array(THD *thd, uint order_group_num)
order_group_num) * 5;
if (!ref_pointer_array.is_null())
{
/*
We need to take 'n_sum_items' into account when allocating the array,
and this may actually increase during the optimization phase due to
MIN/MAX rewrite in Item_in_subselect::single_value_transformer.
In the usual case we can reuse the array from the prepare phase.
If we need a bigger array, we must allocate a new one.
*/
if (ref_pointer_array.size() == n_elems)
return false;

/*
We need to take 'n_sum_items' into account when allocating the array,
and this may actually increase during the optimization phase due to
MIN/MAX rewrite in Item_in_subselect::single_value_transformer.
In the usual case we can reuse the array from the prepare phase.
If we need a bigger array, we must allocate a new one.
*/
if (ref_pointer_array.size() == n_elems)
if (ref_pointer_array.size() >= n_elems)
return false;
}
Item **array= static_cast<Item**>(arena->alloc(sizeof(Item*) * n_elems));
Expand Down

0 comments on commit c917ba1

Please sign in to comment.