Re: Optimze usage of immutable functions as relation
Antonin Houska <ah@cybertec.at>
From: Antonin Houska <ah@cybertec.at>
To: Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>
Cc: asp437@gmail.com, a.bykov@postgrespro.ru,
pgsql-hackers@lists.postgresql.org
Date: 2018-11-08T13:57:45Z
Lists: pgsql-hackers
Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp> wrote: > I had the following error with the following query. > > =# explain select * from pg_stat_get_activity(NULL) a join log(100000.0) p on a.pid = p.p; > ERROR: no relation entry for relid 2 > I think that the problem is that RTE_VALUES is wrapped in a subquery by parser while RTE_FUNCTION is not. Thus some additional processing is done by pull_up_simple_subquery() for VALUES. What seems to make difference here is the call of flatten_join_alias_vars() on the query targetlist, although pull_up_simple_subquery() does it for other reasons. Actually the comment about flatten_join_alias_vars() in pull_up_simple_subquery() makes me think if it's o.k. that pull_up_simple_function() sets rvcontext.need_phvs=false regardless strictness of the function: I think PlaceHolderVar might be needed if the function is not strict. (In contrast, pull_up_simple_values() does not have to care because pull_up_simple_subquery() handles such cases when it's processing the owning subquery). -- Antonin Houska Cybertec Schönig & Schönig GmbH Gröhrmühlgasse 26, A-2700 Wiener Neustadt Web: https://www.cybertec-postgresql.com
Commits
-
Prevent bogus pullup of constant-valued functions returning composite.
- a9ae99d01909 13.0 landed
-
Allow functions-in-FROM to be pulled up if they reduce to constants.
- 7266d0997dd2 13.0 landed