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

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

I wrote:
> Hmph ... this has been broken for a good long while. Bisecting
> shows it gave the right answer before
> commit 4be058fe9ec5e630239b656af21fc083371f30ed
> so I'm betting that missed a condition about when it is safe to
> flatten RTE_RESULT RTEs. Will look, thanks for the report!

Huh. It looks like the oversight is actually even more ancient than
that, dating clear back to 9e7e29c75 of 2013-08-17. That commit
recognized that lateral-reference Vars had to be wrapped in
PlaceHolderVars during subquery pullup, but failed to make the same
conclusion for PlaceHolderVars. Somehow that didn't cause any visible
problems before 4be058fe9, or more likely we just didn't get any
relevant trouble reports. This seems to be quite a rare situation:
spot testing says that we never reach this code for a PHV with
target_rte->lateral true in any of our regression tests.

The attached seems to be enough to fix it, though of course it needs
a regression test.

regards, tom lane

Attachment Content-Type Size
fix-PHV-wrap-rules-for-lateral-references.patch text/x-diff 744 bytes

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2024-01-11 21:43:16 Re: BUG #17798: Incorrect memory access occurs when using BEFORE ROW UPDATE trigger
Previous Message Tom Lane 2024-01-11 16:01:39 Re: BUG #18284: Filter in left lateral join not respected