Re: BUG #18284: Filter in left lateral join not respected

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Richard Guo <guofenglinux(at)gmail(dot)com>
Cc: holger(dot)reise(at)vitagroup(dot)ag, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18284: Filter in left lateral join not respected
Date: 2024-01-12 14:59:39
Message-ID: 465818.1705071579@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Richard Guo <guofenglinux(at)gmail(dot)com> writes:
> On Fri, Jan 12, 2024 at 1:30 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> Somehow that didn't cause any visible
>> problems before 4be058fe9, or more likely we just didn't get any
>> relevant trouble reports.

> I believe it should be the latter case. It's not hard to show this
> problem before 4be058fe9.

> create table t (a int);
> insert into t values (1);

> # select t2a_lateral from t t1
> left join (select coalesce(t2.a) as a from t t2) s on true
> left join lateral (select s.a as t2a_lateral from t t3) ss on false;
> t2a_lateral
> -------------
> 1
> (1 row)

Ah, of course. The previous test case had FROM-less subselects,
so prior to 4be058fe9 we couldn't flatten those and the bug didn't
manifest. But with ordinary FROM clauses, boom!

Now I'm fairly astonished that this was never reported before.
You'd think in ten years somebody would've noticed.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message David G. Johnston 2024-01-12 15:31:06 Re: BUG #18287: pg_restore with -C and -c options does not do what is said in the documentation
Previous Message Robert Haas 2024-01-12 14:56:01 Re: BUG #17798: Incorrect memory access occurs when using BEFORE ROW UPDATE trigger