BUG #18284: Filter in left lateral join not respected

The Post Office <noreply@postgresql.org>

From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: holger.reise@vitagroup.ag
Date: 2024-01-11T14:34:55Z
Lists: pgsql-bugs
The following bug has been logged on the website:

Bug reference:      18284
Logged by:          Holger Reise
Email address:      holger.reise@vitagroup.ag
PostgreSQL version: 16.1
Operating system:   Alpine 13.2.1, 64-bit
Description:        

The following script returns two rows with `666`, whereas `null` is to be
expected:

WITH r1 AS (VALUES(null)),
r2 AS (VALUES(null), (null))
SELECT ljl.val_filtered
FROM r1
LEFT JOIN(
	SELECT j666.val FROM r2
	JOIN (SELECT 666 AS val) as j666 ON true
)AS lj_r2 ON true
LEFT JOIN LATERAL(
	SELECT lj_r2.val AS val_filtered
	WHERE false
) AS ljl ON true;

Commits

  1. Allow subquery pullup to wrap a PlaceHolderVar in another one.

  2. In the planner, replace an empty FROM clause with a dummy RTE.