From e9dbbf112041cd9441ec0eee934e526617eb1213 Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Sat, 6 Jun 2020 11:38:38 -0700 Subject: 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. --- sql/sql_cte.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'sql/sql_cte.cc') diff --git a/sql/sql_cte.cc b/sql/sql_cte.cc index d922a7a7551..fe8e0de71b4 100644 --- a/sql/sql_cte.cc +++ b/sql/sql_cte.cc @@ -1099,6 +1099,7 @@ bool TABLE_LIST::set_as_with_table(THD *thd, With_element *with_elem) { derived= with_elem->spec; if (derived != select_lex->master_unit() && + !with_elem->is_recursive && !is_with_table_recursive_reference()) { derived->move_as_slave(select_lex); -- cgit v1.2.1