Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q9aKw-0005Cl-TO for pgsql-bugs@arkaria.postgresql.org; Wed, 14 Jun 2023 23:55:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1q9aKu-0004QN-R3 for pgsql-bugs@arkaria.postgresql.org; Wed, 14 Jun 2023 23:55:36 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q9aKu-0004J3-Ij for pgsql-bugs@lists.postgresql.org; Wed, 14 Jun 2023 23:55:36 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q9aKp-002QNC-Eg for pgsql-bugs@lists.postgresql.org; Wed, 14 Jun 2023 23:55:35 +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 35ENtRkb2025425; Wed, 14 Jun 2023 19:55:27 -0400 From: Tom Lane To: David Rowley cc: zuming.jiang@inf.ethz.ch, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #17976: Inconsistent results of SELECT using CASE WHEN clause In-reply-to: References: <17976-4b638b525e9a983b@postgresql.org> Comments: In-reply-to David Rowley message dated "Thu, 15 Jun 2023 11:22:55 +1200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2025423.1686786927.1@sss.pgh.pa.us> Date: Wed, 14 Jun 2023 19:55:27 -0400 Message-ID: <2025424.1686786927@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk David Rowley writes: > The first bad commit seems to be b448f1c8 Yeah, I think the proximate cause is the removal of the delay_upper_joins restrictions in analyzejoins.c. That allows us to remove the join to ref_0, which prior versions didn't do; but then that exposes the need to clean up dead references in EquivalenceClasses. I'm wondering a bit now if there are variants of this that'd fail in pre-v16 branches. It's not obvious to me offhand why delay_upper_joins would have prevented all cases where a removable rel could be mentioned in an EquivalenceClass member (presumably via the ph_rels set of a PHV). regards, tom lane