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:
@ -1054,7 +1054,6 @@ bool mysql_derived_fill(THD *thd, LEX *lex, TABLE_LIST *derived)
|
||||
DBUG_ASSERT(derived->table && derived->table->is_created());
|
||||
select_union *derived_result= derived->derived_result;
|
||||
SELECT_LEX *save_current_select= lex->current_select;
|
||||
bool derived_recursive_is_filled= false;
|
||||
|
||||
if (derived_is_recursive)
|
||||
{
|
||||
@ -1067,7 +1066,6 @@ bool mysql_derived_fill(THD *thd, LEX *lex, TABLE_LIST *derived)
|
||||
{
|
||||
/* In this case all iteration are performed */
|
||||
res= derived->fill_recursive(thd);
|
||||
derived_recursive_is_filled= true;
|
||||
}
|
||||
}
|
||||
else if (unit->is_union())
|
||||
@ -1123,9 +1121,7 @@ bool mysql_derived_fill(THD *thd, LEX *lex, TABLE_LIST *derived)
|
||||
}
|
||||
}
|
||||
|
||||
if (res || (!lex->describe &&
|
||||
(!derived_is_recursive ||
|
||||
derived_recursive_is_filled)))
|
||||
if (res || (!lex->describe && !derived_is_recursive))
|
||||
unit->cleanup();
|
||||
lex->current_select= save_current_select;
|
||||
|
||||
|
Reference in New Issue
Block a user