You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bug#36421727 mysql server 8.3.0 failed at Query_expression::optimize
In the repro, we have a query which has a deeply nested aggregate
function (AVG) containing a subquery. The aggregate function
aggregates in the outermost query block - it contains no outer
reference, but all intervening query blocks forbid aggregation (the
aggregate function is contained in their WHERE clauses).
Now, transformation to derived table merge, transformation to semi-join,
and elimination of an impossible where clause subsequently removed parts
of the query tree, including the subquery which is an argument of the
aggregate function. But the subquery is still needed for the evaluation
of the aggregate function in the outermost query block, so we end up
trying to evaluate a destroyed query expression, hence the server exit.
This happens because the cleanup procedure for the aggregate function
is never called. The culprit is the implementation of
Query_block::build_sj_cond(), which is called as part of subquery
transformation. It is called with a Table_ref object containing two
equality predicates, a const one and a predicate involving the aggregate
function. Since the first predicate is false and it evaluates to true,
the entire condition is abandoned and replaced with FALSE. However, no
cleanup code is invoked for the aggregate function, hence the problems.
Solution: change build_sj_cond() so that it generates a full condition,
and then apply Item::clean_up_after_removal on the condition when all
predicates have been processed.
Change-Id: Iaa51de16017179bfbc1224798beaa321ba767166
0 commit comments