Re: [BUG] Remove self joins causes 'variable not found in subplan target lists' error

From: Richard Guo <guofenglinux(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Sergey Soloviev <sergey(dot)soloviev(at)tantorlabs(dot)ru>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: [BUG] Remove self joins causes 'variable not found in subplan target lists' error
Date: 2025-08-26 09:50:26
Message-ID: CAMbWs4_ED8iqBKooVar=VOyz-1VZ4RrcJXViuGcjEw8soLU0_Q@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Aug 26, 2025 at 4:16 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> I wrote:
> > Yeah. I think this is an oversight in create_unique_paths(): it's
> > building an ORDER BY list without consideration for the possibility
> > that some of the entries are known to be constant. In fact, because
> > make_pathkeys_for_sortclauses will get rid of redundancies, this
> > example actually ends up with a unique_rel whose unique_pathkeys
> > are shorter than the unique_groupclause, which is pretty bogus.
>
> Here is a patch that fixes it that way. I like this better than
> Sergey's approach because it is making the plans better not worse.

Another question we need to consider is how to fix this error in v18,
where it seems we'll need to remove redundant expressions during
createplan.c.

Thanks
Richard

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Ashutosh Bapat 2025-08-26 09:53:59 Re: Report reorder buffer size
Previous Message Bertrand Drouvot 2025-08-26 09:48:04 Re: Report reorder buffer size