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 1rOJ0b-0036BA-QK for pgsql-bugs@arkaria.postgresql.org; Fri, 12 Jan 2024 14:59:46 +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 1rOJ0a-002bRE-Pt for pgsql-bugs@arkaria.postgresql.org; Fri, 12 Jan 2024 14:59:44 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rOJ0a-002bQp-HQ for pgsql-bugs@lists.postgresql.org; Fri, 12 Jan 2024 14:59:44 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rOJ0X-001C2U-W5 for pgsql-bugs@lists.postgresql.org; Fri, 12 Jan 2024 14:59:43 +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 40CExdNO465819; Fri, 12 Jan 2024 09:59:39 -0500 From: Tom Lane To: Richard Guo cc: holger.reise@vitagroup.ag, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18284: Filter in left lateral join not respected In-reply-to: References: <18284-47505a20c23647f8@postgresql.org> <74950.1704988899@sss.pgh.pa.us> <229608.1704994239@sss.pgh.pa.us> Comments: In-reply-to Richard Guo message dated "Fri, 12 Jan 2024 14:50:33 +0800" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <465817.1705071579.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Fri, 12 Jan 2024 09:59:39 -0500 Message-ID: <465818.1705071579@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Richard Guo writes: > On Fri, Jan 12, 2024 at 1:30 AM Tom Lane 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