Re: ERROR: PlaceHolderVar found where not expected

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Richard Guo <guofenglinux(at)gmail(dot)com>
Cc: PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>, Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>
Subject: Re: ERROR: PlaceHolderVar found where not expected
Date: 2023-03-14 03:32:31
Message-ID: 2474960.1678764751@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Richard Guo <guofenglinux(at)gmail(dot)com> 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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2023-03-14 03:39:44 Re: ERROR: PlaceHolderVar found where not expected
Previous Message Richard Guo 2023-03-14 03:01:40 ERROR: PlaceHolderVar found where not expected