Re: BUG #18536: Using WITH inside WITH RECURSIVE triggers a "shouldn't happen" error
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: exclusion@gmail.com
Cc: pgsql-bugs@lists.postgresql.org
Date: 2024-07-14T17:30:55Z
Lists: pgsql-bugs
Attachments
- v2-fix-bug-18536.patch (text/x-diff) patch v2
I wrote: > Hmm, that is probably too strong: it will break some queries we've > historically accepted. What we need is just to forbid self-references > within the WITH clause. The code actually does that already, it's > just doing it too late; so we can fix this with a simple re-ordering > of the error checks, as attached. Oh ... regression=# WITH RECURSIVE x(n) AS ( select 0 union select 1 order by (select n from x)) select * from x; ERROR: missing recursive reference We have to move *all* of those subsidiary-clause checks to before the tests of the UNION proper. regards, tom lane
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