Re: subquery pullup misses lateral refs in join alias Vars - Mailing list pgsql-hackers

From Richard Guo
Subject Re: subquery pullup misses lateral refs in join alias Vars
Date
Msg-id CAMbWs4-bhouQZUiry2=GEQ1USefp=r8aA_3rRuh98FLL7wfqmQ@mail.gmail.com
Whole thread
In response to Re: subquery pullup misses lateral refs in join alias Vars  (Tatsuya Kawata <kawatatatsuya0913@gmail.com>)
List pgsql-hackers
On Tue, Sep 22, 2026 at 3:08 PM Tatsuya Kawata
<kawatatatsuya0913@gmail.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



pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: Report index currently being vacuumed in pg_stat_progress_vacuum
Next
From: Michael Paquier
Date:
Subject: Re: Report index currently being vacuumed in pg_stat_progress_vacuum