pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Avoid unhelpful internal error for incorrect recursive-WITH quer
Date: Sun, 14 Jul 2024 17:50:04 +0000
Message-ID: <E1sT3MK-001eq6-EL@gemulon.postgresql.org> (raw)

Avoid unhelpful internal error for incorrect recursive-WITH queries.

checkWellFormedRecursion would issue "missing recursive reference"
if a WITH RECURSIVE query contained a single self-reference but
that self-reference was inside a top-level WITH, ORDER BY, LIMIT,
etc, rather than inside the second arm of the UNION as expected.
We already intended to throw more-on-point errors for such cases,
but those error checks must be done before examining the UNION arm
in order to have the desired results.  So this patch need only
move some code (and improve the comments).

Per bug #18536 from Alexander Lakhin.  Back-patch to all supported
branches.

Discussion: https://postgr.es/m/18536-0a342ec07901203e@postgresql.org

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/cf588e10f664be37a0804e9a8662facd0e163800

Modified Files
--------------
src/backend/parser/parse_cte.c     | 53 ++++++++++++++++++++++++--------------
src/test/regress/expected/with.out | 40 ++++++++++++++++++++++++++++
src/test/regress/sql/with.sql      | 29 +++++++++++++++++++++
3 files changed, 102 insertions(+), 20 deletions(-)



view thread (7+ messages)

Message-ID: <E1sT3MK-001eq6-EL@gemulon.postgresql.org>
Permalink:  ../E1sT3MK-001eq6-EL@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1sT3MK-001eq6-EL@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Avoid unhelpful internal error for incorrect recursive-WITH quer
  In-Reply-To: <E1sT3MK-001eq6-EL@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox