1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-13068 Crash in Item::split_sum_func2 with INSERT SELECT using window functions

When running setup fields during the final step of insert using select
the final setup_fields does not have any sum functions. Our current
condition for calling split_sum_func however would attempt to use an empty
NULL sum_func_list, if the item contained a window function.

The solution is to not perform another split_sum_func for the item
containing a window function if we do not actually have a sum_func_list.
This commit is contained in:
Vicențiu Ciorbaru
2017-06-16 10:12:14 +03:00
parent c73fa2d75f
commit 0992be927e
3 changed files with 181 additions and 2 deletions

View File

@ -7068,10 +7068,13 @@ bool setup_fields(THD *thd, Ref_ptr_array ref_pointer_array,
split_sum_func() must be called for Window Function items, see
Item_window_func::split_sum_func.
*/
if ((item->with_sum_func && item->type() != Item::SUM_FUNC_ITEM &&
sum_func_list) || item->with_window_func)
if (sum_func_list &&
((item->with_sum_func && item->type() != Item::SUM_FUNC_ITEM) ||
item->with_window_func))
{
item->split_sum_func(thd, ref_pointer_array, *sum_func_list,
SPLIT_SUM_SELECT);
}
thd->lex->current_select->select_list_tables|= item->used_tables();
thd->lex->used_tables|= item->used_tables();
thd->lex->current_select->cur_pos_in_select_list++;