Skip to content

Commit 8d35691

Browse files
committed
Bug#35621842: Rollup subquery segv
This is a simplified patch for 8.0. The problem here is that a nameless field is presented to the function find_item_in_list(). Since the search is name-based, it will fail. The culprit is in Item::split_sum_func2(), which when presented with an expression that contains a GROUPING field is supposed to split the function's arguments, however it adds a reference to the expression. The function is enhanced so that it also checks for this case. Change-Id: Ib272698e2718c4a65eb8a71a8022d6ac527723e8
1 parent 75f3d8e commit 8d35691

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

sql/item.cc

+2
Original file line numberDiff line numberDiff line change
@@ -2212,6 +2212,8 @@ void Item::split_sum_func2(THD *thd, Ref_item_array ref_item_array,
22122212
const bool is_sum_func = type() == SUM_FUNC_ITEM && !m_is_window_function;
22132213
if ((!is_sum_func && has_aggregation() && !m_is_window_function) ||
22142214
(!m_is_window_function && has_wf()) ||
2215+
(has_grouping_func() &&
2216+
!is_function_of_type(this, Item_func::GROUPING_FUNC)) ||
22152217
(type() == FUNC_ITEM && ((down_cast<Item_func *>(this))->functype() ==
22162218
Item_func::ISNOTNULLTEST_FUNC ||
22172219
(down_cast<Item_func *>(this))->functype() ==

sql/sql_base.cc

+5
Original file line numberDiff line numberDiff line change
@@ -8114,6 +8114,11 @@ bool find_item_in_list(THD *thd, Item *find, mem_root_deque<Item *> *items,
81148114
find->type() == Item::FIELD_ITEM || find->type() == Item::REF_ITEM
81158115
? down_cast<Item_ident *>(find)
81168116
: nullptr;
8117+
/*
8118+
Some items, such as Item_aggregate_ref, do not have a name and hence
8119+
can never be found.
8120+
*/
8121+
assert(find_ident == nullptr || find_ident->field_name != nullptr);
81178122

81188123
int i = 0;
81198124
for (auto it = VisibleFields(*items).begin();

0 commit comments

Comments
 (0)