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

MDEV-31219 Assertion `fixed' failed in Item_func_hybrid_field_type / Frame_positional_cursor

add_special_frame_cursors() did not check the return
value offset_func->fix_fields(). It can return an error
if the data type does not support the operator "minus".
This commit is contained in:
Alexander Barkov
2024-11-29 21:03:16 +04:00
committed by Oleksandr Byelkin
parent 432856c473
commit 0b7fa4c267
3 changed files with 30 additions and 6 deletions

View File

@ -2528,7 +2528,7 @@ Frame_cursor *get_frame_cursor(THD *thd, Window_spec *spec, bool is_top_bound)
}
static
void add_special_frame_cursors(THD *thd, Cursor_manager *cursor_manager,
bool add_special_frame_cursors(THD *thd, Cursor_manager *cursor_manager,
Item_window_func *window_func)
{
Window_spec *spec= window_func->window_spec;
@ -2615,7 +2615,9 @@ void add_special_frame_cursors(THD *thd, Cursor_manager *cursor_manager,
Item *offset_func= new (thd->mem_root)
Item_func_minus(thd, item_sum->get_arg(1),
int_item);
offset_func->fix_fields(thd, &offset_func);
if (offset_func->fix_fields(thd, &offset_func))
return true;
fc= new Frame_positional_cursor(*top_bound,
*top_bound, *bottom_bound,
*offset_func, false);
@ -2648,6 +2650,7 @@ void add_special_frame_cursors(THD *thd, Cursor_manager *cursor_manager,
fc->add_sum_func(item_sum);
cursor_manager->add_cursor(fc);
}
return false;
}
@ -2675,7 +2678,7 @@ static bool is_computed_with_remove(Item_sum::Sumfunctype sum_func)
If the window functions share the same frame specification,
those window functions will be registered to the same cursor.
*/
void get_window_functions_required_cursors(
bool get_window_functions_required_cursors(
THD *thd,
List<Item_window_func>& window_functions,
List<Cursor_manager> *cursor_managers)
@ -2726,7 +2729,8 @@ void get_window_functions_required_cursors(
if (item_win_func->is_frame_prohibited() ||
item_win_func->requires_special_cursors())
{
add_special_frame_cursors(thd, cursor_manager, item_win_func);
if (add_special_frame_cursors(thd, cursor_manager, item_win_func))
return true;
cursor_managers->push_back(cursor_manager);
continue;
}
@ -2760,6 +2764,7 @@ void get_window_functions_required_cursors(
}
cursor_managers->push_back(cursor_manager);
}
return false;
}
/**
@ -3034,8 +3039,9 @@ bool Window_func_runner::exec(THD *thd, TABLE *tbl, SORT_INFO *filesort_result)
it.rewind();
List<Cursor_manager> cursor_managers;
get_window_functions_required_cursors(thd, window_functions,
&cursor_managers);
if (get_window_functions_required_cursors(thd, window_functions,
&cursor_managers))
return true;
/* Go through the sorted array and compute the window function */
bool is_error= compute_window_func(thd,