From: Tom Lane <tgl@sss.pgh.pa.us>
To: Nitin Motiani <nitinmotiani@google.com>
Cc: tharakan@gmail.com, pgsql-bugs@lists.postgresql.org, Peter Eisentraut <peter@eisentraut.org>
Subject: Re: BUG #19922: CYCLE/SEARCH with a window in the recursive term: could not find replacement targetlist entry
Date: Fri, 20 Nov 2026 11:57:16 -0500
Message-ID: <1533786.1795193836@sss.pgh.pa.us> (raw)
In-Reply-To: <CAH5HC97oEGSV4g5z=qxM=UpiJUtGJRNRvRv8NH7i77o0LAyGiw@mail.gmail.com>
References: <19922-a0d338245d361a4c@postgresql.org>
<1250317.1795124832@sss.pgh.pa.us>
<CAH5HC97oEGSV4g5z=qxM=UpiJUtGJRNRvRv8NH7i77o0LAyGiw@mail.gmail.com>
Nitin Motiani <nitinmotiani@google.com> writes:
> On Fri, Nov 20, 2026 at 3:17 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> I think the problem is that rewriteSearchAndCycle() is appending extra
>> items to the right subquery's tlist without regard for the possibility
>> that there are resjunk items in it.
> Thanks for the idea. I checked this and it indeed seemed to be the case.
> I'm attaching a patch with the fix in this area.
Thanks for doing the legwork. I pushed this after rewriting the
initial hunk a little: I didn't like just assuming that we know the
number of non-resjunk columns. rewriteTargetListIU() splits the
tlist using explicit checks on the resjunk flags, and I think this
code should do the same. We can assert that the result matches the
CTE column list afterwards.
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, nitinmotiani@google.com, peter@eisentraut.org
Subject: Re: BUG #19922: CYCLE/SEARCH with a window in the recursive term: could not find replacement targetlist entry
In-Reply-To: <1533786.1795193836@sss.pgh.pa.us>
References: <19922-a0d338245d361a4c@postgresql.org> <1250317.1795124832@sss.pgh.pa.us> <CAH5HC97oEGSV4g5z=qxM=UpiJUtGJRNRvRv8NH7i77o0LAyGiw@mail.gmail.com> <1533786.1795193836@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