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 1tlfJv-00106o-JZ for pgsql-bugs@arkaria.postgresql.org; Sat, 22 Feb 2025 02:32:48 +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 1tlfJt-003NYG-Au for pgsql-bugs@arkaria.postgresql.org; Sat, 22 Feb 2025 02:32:45 +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 1tlfJt-003NXv-2J for pgsql-bugs@lists.postgresql.org; Sat, 22 Feb 2025 02:32:45 +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.96) (envelope-from ) id 1tlfJn-0004Jp-1j for pgsql-bugs@lists.postgresql.org; Sat, 22 Feb 2025 02:32:41 +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 51M2WdUH3818496; Fri, 21 Feb 2025 21:32:39 -0500 From: Tom Lane To: Richard Guo cc: Bruce Momjian , David Rowley , Ronald Cruz , pgsql-bugs@lists.postgresql.org, Peter Ford , "Aaron J. Garcia" Subject: Re: Query result differences between PostgreSQL 17 vs 16 In-reply-to: References: <3736132.1740181858@sss.pgh.pa.us> Comments: In-reply-to Richard Guo message dated "Sat, 22 Feb 2025 10:01:13 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <3818494.1740191559.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Fri, 21 Feb 2025 21:32:39 -0500 Message-ID: <3818495.1740191559@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Richard Guo writes: > On Sat, Feb 22, 2025 at 8:51 AM Tom Lane wrote: >> I've not looked at the code, but I suspect that it is failing >> to check varnullingrels before believing that it can trust >> the applicability of table constraints. > Hmm, we do check varnullingrels in expr_is_nonnullable(). My best > guess is that we have generated two versions of the qual 'customer.cid > IS NOT NULL': one with customer.cid marked as nullable by the left > join to customer, and one without. The latter is dropped because of > the not null constraint on customer.cid, while the former fails to be > applied on the left join to int4_tbl j. If the check against table not-null constraints is applied after we clone outer-join quals, that's probably bad. I think there are assumptions in there that every clone qual will have doppelgangers, so filtering NOT NULLs later would break that. Maybe not applying the filter to quals marked has_clone or is_clone would help? regards, tom lane