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 1oknro-0001ap-F5 for pgsql-hackers@arkaria.postgresql.org; Tue, 18 Oct 2022 14:46:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oknrn-0001Qi-9G for pgsql-hackers@arkaria.postgresql.org; Tue, 18 Oct 2022 14:46:51 +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 1oknrn-0001QA-08 for pgsql-hackers@lists.postgresql.org; Tue, 18 Oct 2022 14:46:51 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oknrk-0001vY-TV for pgsql-hackers@lists.postgresql.org; Tue, 18 Oct 2022 14:46:50 +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 29IEkkQg2647068; Tue, 18 Oct 2022 10:46:46 -0400 From: Tom Lane To: Etsuro Fujita cc: Richard Guo , pgsql-hackers@lists.postgresql.org Subject: Re: havingQual vs hasHavingQual buglets In-reply-to: References: <2503888.1666042643@sss.pgh.pa.us> Comments: In-reply-to Etsuro Fujita message dated "Tue, 18 Oct 2022 18:23:49 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2647066.1666104406.1@sss.pgh.pa.us> Date: Tue, 18 Oct 2022 10:46:46 -0400 Message-ID: <2647067.1666104406@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Etsuro Fujita writes: > On Tue, Oct 18, 2022 at 9:47 AM Richard Guo wrote: >> On Tue, Oct 18, 2022 at 5:37 AM Tom Lane wrote: >>> I came across a couple of places in the planner that are checking >>> for nonempty havingQual; but since these bits run after >>> const-simplification of the HAVING clause, that produces the wrong >>> answer for a constant-true HAVING clause (which'll be folded to >>> empty). Correct code is to check root->hasHavingQual instead. > The postgres_fdw bits would be my oversight. :-( No worries --- I think the one in set_subquery_pathlist is probably my fault :-( > +1 HEAD only seems reasonable. Pushed that way; thanks for looking. regards, tom lane