summaryrefslogtreecommitdiff
path: root/src/test/regress/expected/with.out
diff options
context:
space:
mode:
authorTom Lane2025-04-05 19:01:33 +0000
committerTom Lane2025-04-05 19:01:48 +0000
commit691836405f1ecae2368a0f2fdbfee3b2cb53375b (patch)
tree28b7513db5d7381433230debbc9fc0c45e3707a6 /src/test/regress/expected/with.out
parent749a9e20c9790006f3af47f7a8faf4ad8dc358d9 (diff)
Fix parse_cte.c's failure to examine sub-WITHs in DML statements.
makeDependencyGraphWalker thought that only SelectStmt nodes could contain a WithClause. Which was true in our original implementation of WITH, but astonishingly we missed updating this code when we added the ability to attach WITH to INSERT/UPDATE/DELETE (and later MERGE). Moreover, since it was coded to deliberately block recursion to a WithClause, even updating raw_expression_tree_walker didn't save it. The upshot of this was that we didn't see references to outer CTE names appearing within an inner WITH, and would neither complain about disallowed recursion nor account for such references when sorting CTEs into a usable order. The lack of complaints about this is perhaps not so surprising, because typical usage of WITH wouldn't hit either case. Still, it's pretty broken; failing to detect recursion here leads to assert failures or worse later on. Fix by factoring out the processing of sub-WITHs into a new function WalkInnerWith, and invoking that for all the statement types that can have WITH. Bug: #18878 Reported-by: Yu Liang <[email protected]> Author: Tom Lane <[email protected]> Discussion: https://postgr.es/m/[email protected] Backpatch-through: 13
Diffstat (limited to 'src/test/regress/expected/with.out')
-rw-r--r--src/test/regress/expected/with.out8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/test/regress/expected/with.out b/src/test/regress/expected/with.out
index 7a51e2eb757..26c88505140 100644
--- a/src/test/regress/expected/with.out
+++ b/src/test/regress/expected/with.out
@@ -2104,6 +2104,14 @@ WITH RECURSIVE x(n) AS (
ERROR: ORDER BY in a recursive query is not implemented
LINE 3: ORDER BY (SELECT n FROM x))
^
+-- and this
+WITH RECURSIVE x(n) AS (
+ WITH sub_cte AS (SELECT * FROM x)
+ DELETE FROM graph RETURNING f)
+ SELECT * FROM x;
+ERROR: recursive query "x" must not contain data-modifying statements
+LINE 1: WITH RECURSIVE x(n) AS (
+ ^
CREATE TEMPORARY TABLE y (a INTEGER);
INSERT INTO y SELECT generate_series(1, 10);
-- LEFT JOIN