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 1tHE6W-004saG-26 for pgsql-committers@arkaria.postgresql.org; Sat, 30 Nov 2024 03:25:08 +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 1tHE6T-00CsZO-7o for pgsql-committers@arkaria.postgresql.org; Sat, 30 Nov 2024 03:25:06 +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 1tHE6T-00CsZD-08 for pgsql-committers@lists.postgresql.org; Sat, 30 Nov 2024 03:25:06 +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 1tHE6R-000GL5-S4 for pgsql-committers@lists.postgresql.org; Sat, 30 Nov 2024 03:25:05 +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 4AU3P2Q5824292; Fri, 29 Nov 2024 22:25:02 -0500 From: Tom Lane To: Richard Guo cc: pgsql-committers@lists.postgresql.org Subject: Re: pgsql: Avoid mislabeling of lateral references when pulling up a subque In-reply-to: References: <397371.1732844670@sss.pgh.pa.us> <530989.1732907849@sss.pgh.pa.us> <590235.1732915884@sss.pgh.pa.us> Comments: In-reply-to Richard Guo message dated "Sat, 30 Nov 2024 12:09:18 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <824290.1732937102.1@sss.pgh.pa.us> Date: Fri, 29 Nov 2024 22:25:02 -0500 Message-ID: <824291.1732937102@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Richard Guo writes: > This patch can also simplify my other patch, which is to avoid > unnecessary wrapping for plain Vars/PHVs. We can check the new > nullingrel_info to see if the nullingrels of the subquery RTE are a > subset of the nullingrels of the lateral referenced rel, to determine > if the referenced rel is under the same lowest nulling outer join. > And this eliminates the need to introduce lowest_nullable_side. Right, because that's more or less the same problem. Or indeed it's exactly the same problem, we're just making fast paths for the easiest cases. Another thought: the reason I made get_nullingrels return a new struct rather than tying it directly to filling some fields in pullup_replace_vars_context was that I think we might want to reconsider where to call it from. Perhaps it'd be useful to have the info during is_simple_subquery, for example. regards, tom lane