Re: subquery pullup misses lateral refs in join alias Vars

From: Richard Guo <guofenglinux(at)gmail(dot)com>
To: Tatsuya Kawata <kawatatatsuya0913(at)gmail(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: subquery pullup misses lateral refs in join alias Vars
Date: 2026-10-01 01:42:34
Message-ID: CAMbWs4-bhouQZUiry2=GEQ1USefp=r8aA_3rRuh98FLL7wfqmQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Sep 22, 2026 at 3:08 PM Tatsuya Kawata
<kawatatatsuya0913(at)gmail(dot)com> wrote:
> I applied v1 and confirmed it works correctly. I also tested the
> same master without v1. Without assertions, I found a pattern
> where a query silently returns a wrong result rather than hitting
> the Assert, so I wanted to share it. I think this warrants a back-patch.

> select t1.a, ss.x, t2.a
> from t t1,
> lateral (select (j is null)::int
> from ((select t1.a) s left join (select 1) v on false) j)
> ss(x)
> left join t t2 on ss.x = t2.a;

Thanks for looking at this. This query seems to be the same as the
first query in my initial report (with a different targetlist) and has
already been covered in the test cases of v1 patch.

- Richard

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2026-10-01 01:55:12 Re: Report index currently being vacuumed in pg_stat_progress_vacuum
Previous Message Michael Paquier 2026-10-01 00:37:22 Re: Report index currently being vacuumed in pg_stat_progress_vacuum