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 1tnVVX-005qKu-Q6 for pgsql-bugs@arkaria.postgresql.org; Thu, 27 Feb 2025 04:28:24 +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 1tnVVU-004YyT-KZ for pgsql-bugs@arkaria.postgresql.org; Thu, 27 Feb 2025 04:28:20 +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 1tnVVU-004Ywg-B8 for pgsql-bugs@lists.postgresql.org; Thu, 27 Feb 2025 04:28:20 +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.96) (envelope-from ) id 1tnVVR-000Jpa-1o for pgsql-bugs@lists.postgresql.org; Thu, 27 Feb 2025 04:28:20 +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 51R4SFoG2337384; Wed, 26 Feb 2025 23:28:15 -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> <3818495.1740191559@sss.pgh.pa.us> <1716556.1740551169@sss.pgh.pa.us> Comments: In-reply-to Richard Guo message dated "Wed, 26 Feb 2025 17:46:27 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <2337382.1740630494.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Wed, 26 Feb 2025 23:28:14 -0500 Message-ID: <2337383.1740630494@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Richard Guo writes: >> On Wed, Feb 26, 2025 at 3:26 PM Tom Lane wrote: >>> Thanks for that. The code and comment added to >>> restriction_is_always_true look good, but I can't help wondering >>> whether we don't need the same in restriction_is_always_false. > After some attempts, I failed to find such a query. An IS NULL qual > is not strict, and it makes the outer join not commutable with other > joins per outer-join identity 3. We could add another strict qual to > the join clauses to make the outer join commutable. However, in this > case whether we reduce the IS NULL qual to a constant false would not > affect the join outputs, due to the strict qual. > I'm starting to believe that reducing an IS NULL clone clause to a > constant false should be safe. Any thoughts? Not sure. I think the risk factor here is fooling the clone-clause mechanisms by failing to install some clone of an original outer join clause in a rel's restriction list. Looking at the callers of restriction_is_always_false: add_base_clause_to_rel add_join_clause_to_rels These two replace the clause with a Const "false" that is marked with the same rinfo_serial. Therefore the expectation that every group of clones will have a representative is still satisfied, even though the representative doesn't contain quite what you might expect. apply_child_basequals This just summarily rejects the child rel as not needing to be built. I think that might be okay, since we don't really make any further deductions with an appendrel child's quals. I've not actually worked through the bug case to verify my hypothesis that it's the lack of a representative for a clone group that is breaking things. (Maybe you did?) But if that is the direct cause of the failure, then it's plausible that none of these callers are subject to it. I'm a bit inclined to argue that we should put in the no-clone-quals limitation anyway, to protect future callers that might not manage to dodge the problem. OTOH, if we get rid of these functions altogether as I expressed my desire to do nearby, it's all moot. regards, tom lane