From: Tom Lane <tgl@sss.pgh.pa.us>
To: Peter Eisentraut <peter@eisentraut.org>
Cc: tharakan@gmail.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #19923: SEARCH/CYCLE with DISTINCT in the recursive term: rows depend on input order
Date: Fri, 20 Nov 2026 13:17:17 -0500
Message-ID: <1537677.1795198637@sss.pgh.pa.us> (raw)
In-Reply-To: <1536293.1795197174@sss.pgh.pa.us>
References: <19923-24cef1e958fa2370@postgresql.org>
<1535856.1795196546@sss.pgh.pa.us>
<1536293.1795197174@sss.pgh.pa.us>
Oh, I have it: the right fix here is to leave the right subquery's
tlist entirely alone, and instead compute the extra columns in its
parent query. The reason we didn't see a problem for #19922 in
the lefthand subquery is that it's done that way for the lefthand
subquery; but for some reason we didn't do it like that for the
righthand one.
Now that I look more closely, I think that the SQL spec's rewrite
rule actually directs us to do it like that. So there's no
semantic hazard in the spec, only in our implementation.
regards, tom lane
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, peter@eisentraut.org, tharakan@gmail.com
Subject: Re: BUG #19923: SEARCH/CYCLE with DISTINCT in the recursive term: rows depend on input order
In-Reply-To: <1537677.1795198637@sss.pgh.pa.us>
References: <19923-24cef1e958fa2370@postgresql.org> <1535856.1795196546@sss.pgh.pa.us> <1536293.1795197174@sss.pgh.pa.us> <1537677.1795198637@sss.pgh.pa.us>
* 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