mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-24925: Server crashes in Item_subselect::init_expr_cache_tracker
(trivial backport to 10.2) The optimizer removes redundant GROUP BY operations. If GROUP BY element is a subselect, it is "eliminated". However one must not eliminate the item if it is used both in the select list and in the GROUP BY, like so: select (select ... ) as SUBQ from ... group by SUBQ Do not eliminate such items.
This commit is contained in:
@ -585,7 +585,16 @@ void remove_redundant_subquery_clauses(st_select_lex *subq_select_lex)
|
||||
{
|
||||
for (ORDER *ord= subq_select_lex->group_list.first; ord; ord= ord->next)
|
||||
{
|
||||
(*ord->item)->walk(&Item::eliminate_subselect_processor, FALSE, NULL);
|
||||
/*
|
||||
Do not remove the item if it is used in select list and then referred
|
||||
from GROUP BY clause by its name or number. Example:
|
||||
|
||||
select (select ... ) as SUBQ ... group by SUBQ
|
||||
|
||||
Here SUBQ cannot be removed.
|
||||
*/
|
||||
if (!ord->in_field_list)
|
||||
(*ord->item)->walk(&Item::eliminate_subselect_processor, FALSE, NULL);
|
||||
}
|
||||
subq_select_lex->join->group_list= NULL;
|
||||
subq_select_lex->group_list.empty();
|
||||
|
Reference in New Issue
Block a user