From 5c81c50f107896feb930cd3aaf795fe8e1635eec Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 30 Jun 2023 21:03:29 +0200 Subject: [PATCH] MDEV-31214 Recursive CTE execution is interrupted without errors or warnings --- mysql-test/main/cte_recursive.result | 4 ++++ sql/sql_derived.cc | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/mysql-test/main/cte_recursive.result b/mysql-test/main/cte_recursive.result index 8de8a571052..0b7b216f1fe 100644 --- a/mysql-test/main/cte_recursive.result +++ b/mysql-test/main/cte_recursive.result @@ -1214,6 +1214,8 @@ generation name 2 Grandma Ann 2 Grandma Sally 2 Grandpa Ben +Warnings: +Warning 1931 Query execution was interrupted. The query exceeded max_recursive_iterations = 1. The query result may be incomplete # query with recursive tables using key access alter table folks add primary key (id); explain @@ -2592,6 +2594,8 @@ select * from applied_modules; m m1 m2 +Warnings: +Warning 1931 Query execution was interrupted. The query exceeded max_recursive_iterations = 2. The query result may be incomplete drop table value_nodes, module_nodes, module_arguments, module_results; # # mdev-12519: recursive references in subqueries diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index c8a335497e9..107ac31cd4e 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -1142,7 +1142,14 @@ bool TABLE_LIST::fill_recursive(THD *thd) while (!rc && !with->all_are_stabilized()) { if (with->level > thd->variables.max_recursive_iterations) + { + push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, + ER_QUERY_RESULT_INCOMPLETE, + ER_THD(thd, ER_QUERY_RESULT_INCOMPLETE), + "max_recursive_iterations =", + (ulonglong)thd->variables.max_recursive_iterations); break; + } with->prepare_for_next_iteration(); rc= unit->exec_recursive(); }