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 1pbvS3-00068l-Bo for pgsql-bugs@arkaria.postgresql.org; Tue, 14 Mar 2023 03:35:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pbvS2-0004Y7-4K for pgsql-bugs@arkaria.postgresql.org; Tue, 14 Mar 2023 03:35:50 +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 1pbvOz-0000ME-Kf for pgsql-bugs@lists.postgresql.org; Tue, 14 Mar 2023 03:32:41 +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 1pbvOs-00040D-Vx for pgsql-bugs@lists.postgresql.org; Tue, 14 Mar 2023 03:32:40 +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 32E3WVlR2474961; Mon, 13 Mar 2023 23:32:31 -0400 From: Tom Lane To: Richard Guo cc: PostgreSQL mailing lists , Tomas Vondra Subject: Re: ERROR: PlaceHolderVar found where not expected In-reply-to: References: Comments: In-reply-to Richard Guo message dated "Tue, 14 Mar 2023 11:01:40 +0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2474959.1678764751.1@sss.pgh.pa.us> Date: Mon, 13 Mar 2023 23:32:31 -0400 Message-ID: <2474960.1678764751@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Richard Guo writes: > I came across an ERROR as $subject with query below. > ... > This is due to that we use 0 flags for pull_var_clause in > dependency_is_compatible_expression, assuming that the 'clause_expr' > cannot contain Aggrefs, WindowFuncs or PlaceHolderVars. This should be > an oversight as we can see that it's possible to find PHVs here. Nice catch. > But I'm not sure if Aggrefs and WindowFuncs are possible to be found > here. 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. regards, tom lane