Skip to content

Commit b022aa6

Browse files
author
Dag Wanvik
committed
Bug#35471471 MySQL Server crashes when executing query [backport]
When pushing ORDER BY down into a redundant nested block, we fail to increment these two counters with the contributions from the ORDER BY. Query_block::n_sum_items Query_block::select_n_where_fields This causes the estimate the max size of base_ref_items allocated in Query_block::setup_base_ref_items to be too low, and we see the crash when trying to add more elements during split_sum_func (due to presence of window function). Solution: when pushing down ORDER BY, increment the counters. We can check that the counters are the same with and without the extra nesting of the repro by activating "info" trace and we should see info: setup_ref_array this 0x... 9 : 1 0 1 1 4 2 0 for both cases with the patch. Change-Id: Ie83653cd371b4c2732985a56ef93a53228f25e1c
1 parent 59bdabd commit b022aa6

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

sql/query_term.cc

+5
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ Query_term *Query_term::pushdown_limit_order_by(Query_term_set_op *parent) {
113113
child_block->order_list = this_block->order_list;
114114
child_block->absorb_limit_of(this_block);
115115
child_block->m_windows.prepend(&this_block->m_windows);
116+
child_block->select_n_where_fields +=
117+
this_block->select_n_where_fields;
118+
child_block->n_sum_items += this_block->n_sum_items;
119+
child_block->n_child_sum_items += this_block->n_child_sum_items;
120+
child_block->n_scalar_subqueries += this_block->n_scalar_subqueries;
116121

117122
if (this_block->first_inner_query_expression() != nullptr) {
118123
// Change context of any items in ORDER BY to child block

0 commit comments

Comments
 (0)