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 1pbvVu-0006JC-By for pgsql-bugs@arkaria.postgresql.org; Tue, 14 Mar 2023 03:39:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pbvVt-00056c-3V for pgsql-bugs@arkaria.postgresql.org; Tue, 14 Mar 2023 03:39:49 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pbvVs-00056R-RR for pgsql-bugs@lists.postgresql.org; Tue, 14 Mar 2023 03:39:48 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pbvVq-00043z-Lh for pgsql-bugs@lists.postgresql.org; Tue, 14 Mar 2023 03:39:47 +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 32E3dihe2475648; Mon, 13 Mar 2023 23:39:44 -0400 From: Tom Lane To: Tomas Vondra cc: Richard Guo , PostgreSQL mailing lists Subject: Re: ERROR: PlaceHolderVar found where not expected In-reply-to: <2474960.1678764751@sss.pgh.pa.us> References: <2474960.1678764751@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Mon, 13 Mar 2023 23:32:31 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2475646.1678765184.1@sss.pgh.pa.us> Date: Mon, 13 Mar 2023 23:39:44 -0400 Message-ID: <2475647.1678765184@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I wrote: > WindowFuncs should be disallowed in qual clauses, so I think it's okay > to leave those flags out. An Aggref could occur in a HAVING qual though. > I'm not sure if this code could get applied to HAVING ... but it's > not immediately clear that it can't. I'd be inclined to add > PVC_RECURSE_AGGREGATES, as that seems more likely to be okay than not. Actually, on closer look: why don't we just nuke that pull_var_clause call entirely, along with the following loop inspecting its result? The subsequent loop that looks for a matching StatisticExtInfo expression will do just fine at rejecting any expression that contains Vars of the wrong relation. Maybe there is some performance argument why the pull_var_clause precheck is worth the trouble, but I'm inclined to bet that it's actually a net loss. regards, tom lane