summaryrefslogtreecommitdiff
path: root/sql/sql_cte.cc
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2021-07-20 23:14:43 -0700
committerIgor Babaev <igor@askmonty.org>2021-07-21 08:29:31 -0700
commit4aeb2b1c6c542e09be2474644358038279197529 (patch)
treeb91caa494bcad64459388be9ba4188105bdb9880 /sql/sql_cte.cc
parentbd711d4f3de386479ba10df2ee07e6fc7c2a02e5 (diff)
downloadmariadb-git-4aeb2b1c6c542e09be2474644358038279197529.tar.gz
MDEV-26189 Missing handling of unknown column in WHERE of recursive CTE
SQL processor failed to catch references to unknown columns and other errors of the phase of semantic analysis in the specification of a hanging recursive CTE. This happened because the function With_clause::prepare_unreferenced_elements() failed to detect a CTE as a hanging CTE if the CTE was recursive. Fixing this problem in the code of the mentioned function opened another problem: EXPLAIN started including the lines for the specifications of hanging recursive CTEs in its output. This problem also was fixed in this patch. Approved by Dmitry Shulga <dmitry.shulga@mariadb.com>
Diffstat (limited to 'sql/sql_cte.cc')
-rw-r--r--sql/sql_cte.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/sql/sql_cte.cc b/sql/sql_cte.cc
index b720eac2317..22a99842f6a 100644
--- a/sql/sql_cte.cc
+++ b/sql/sql_cte.cc
@@ -911,7 +911,8 @@ bool With_clause::prepare_unreferenced_elements(THD *thd)
with_elem;
with_elem= with_elem->next)
{
- if (!with_elem->is_referenced() && with_elem->prepare_unreferenced(thd))
+ if ((with_elem->is_hanging_recursive() || !with_elem->is_referenced()) &&
+ with_elem->prepare_unreferenced(thd))
return true;
}