summaryrefslogtreecommitdiff
path: root/sql/sql_cte.cc
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2020-06-06 11:38:38 -0700
committerIgor Babaev <igor@askmonty.org>2020-06-06 11:56:10 -0700
commite9dbbf112041cd9441ec0eee934e526617eb1213 (patch)
treeda5f85ed57540f9ec125106961a47705d1f89013 /sql/sql_cte.cc
parentbe0c46eb9723dd8192e049123483812e6779dd97 (diff)
downloadmariadb-git-e9dbbf112041cd9441ec0eee934e526617eb1213.tar.gz
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.
Diffstat (limited to 'sql/sql_cte.cc')
-rw-r--r--sql/sql_cte.cc1
1 files changed, 1 insertions, 0 deletions
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);