Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rNxV4-00HSNd-RP for pgsql-bugs@arkaria.postgresql.org; Thu, 11 Jan 2024 16:01:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rNxV3-00CzL8-PD for pgsql-bugs@arkaria.postgresql.org; Thu, 11 Jan 2024 16:01:45 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rNxV3-00CzL0-GE for pgsql-bugs@lists.postgresql.org; Thu, 11 Jan 2024 16:01:45 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rNxUz-0012Fc-CE for pgsql-bugs@lists.postgresql.org; Thu, 11 Jan 2024 16:01:44 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 40BG1d4W074951; Thu, 11 Jan 2024 11:01:39 -0500 From: Tom Lane To: holger.reise@vitagroup.ag cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18284: Filter in left lateral join not respected In-reply-to: <18284-47505a20c23647f8@postgresql.org> References: <18284-47505a20c23647f8@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Thu, 11 Jan 2024 14:34:55 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <74949.1704988899.1@sss.pgh.pa.us> Date: Thu, 11 Jan 2024 11:01:39 -0500 Message-ID: <74950.1704988899@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Bug reporting form writes: > 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; Hmph ... this has been broken for a good long while. Bisecting shows it gave the right answer before 4be058fe9ec5e630239b656af21fc083371f30ed is the first bad commit commit 4be058fe9ec5e630239b656af21fc083371f30ed Author: Tom Lane Date: Mon Jan 28 17:54:10 2019 -0500 In the planner, replace an empty FROM clause with a dummy RTE. so I'm betting that missed a condition about when it is safe to flatten RTE_RESULT RTEs. Will look, thanks for the report! regards, tom lane