BUG #18536: Using WITH inside WITH RECURSIVE triggers a "shouldn't happen" error
The Post Office <noreply@postgresql.org>
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: exclusion@gmail.com
Date: 2024-07-13T09:00:00Z
Lists: pgsql-bugs
The following bug has been logged on the website:
Bug reference: 18536
Logged by: Alexander Lakhin
Email address: exclusion@gmail.com
PostgreSQL version: 17beta2
Operating system: Ubuntu 22.04
Description:
The following query:
WITH RECURSIVE t(n) AS (
WITH t1 AS (SELECT 1 FROM t) SELECT 1
UNION
SELECT 1 FROM t1)
SELECT * FROM t;
triggers an error:
ERROR: XX000: missing recursive reference
LOCATION: checkWellFormedRecursion, parse_cte.c:896
which is seemingly not expected:
if (cstate->selfrefcount != 1) /* shouldn't happen */
elog(ERROR, "missing recursive reference");
Commits
-
Avoid unhelpful internal error for incorrect recursive-WITH queries.
- f96c2c72788c 18.0 landed
- e7f9f44e3bd9 15.8 landed
- cf588e10f664 17.0 landed
- b020a866a22b 13.16 landed
- 8fc4876147fb 16.4 landed
- 236b225ed452 12.20 landed
- 02b4f5e1f26b 14.13 landed