mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-22748 MariaDB crash on WITH RECURSIVE large query
This bug is the same as the bug MDEV-17024. The crashes caused by these bugs were due to premature cleanups of the unit specifying recursive CTEs that happened in some cases when there were several outer references the same recursive CTE. The problem of premature cleanups for recursive CTEs could be already resolved by the correction in TABLE_LIST::set_as_with_table() introduced in this patch. ALL other changes introduced by the patches for MDEV-17024 and MDEV-22748 guarantee that this clean-ups are performed as soon as possible: when the select containing the last outer reference to a recursive CTE is being cleaned up the specification of the recursive CTE should be cleaned up as well.
This commit is contained in:
@ -1540,6 +1540,19 @@ bool st_select_lex::cleanup()
|
||||
delete join;
|
||||
join= 0;
|
||||
}
|
||||
for (TABLE_LIST *tbl= get_table_list(); tbl; tbl= tbl->next_local)
|
||||
{
|
||||
if (tbl->is_recursive_with_table() &&
|
||||
!tbl->is_with_table_recursive_reference())
|
||||
{
|
||||
/*
|
||||
If query is killed before open_and_process_table() for tbl
|
||||
is called then 'with' is already set, but 'derived' is not.
|
||||
*/
|
||||
st_select_lex_unit *unit= tbl->with->spec;
|
||||
error|= (bool) error | (uint) unit->cleanup();
|
||||
}
|
||||
}
|
||||
for (SELECT_LEX_UNIT *lex_unit= first_inner_unit(); lex_unit ;
|
||||
lex_unit= lex_unit->next_unit())
|
||||
{
|
||||
|
Reference in New Issue
Block a user