Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gKkn4-0007Ln-9o for pgsql-hackers@arkaria.postgresql.org; Thu, 08 Nov 2018 13:56:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gKkn2-0000od-I5 for pgsql-hackers@arkaria.postgresql.org; Thu, 08 Nov 2018 13:56:08 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gKkn2-0000nV-7K for pgsql-hackers@lists.postgresql.org; Thu, 08 Nov 2018 13:56:08 +0000 Received: from mx2a.mailbox.org ([2001:67c:2050:104:0:2:25:2] helo=mx2.mailbox.org) by makus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gKkmy-0000IY-QB for pgsql-hackers@lists.postgresql.org; Thu, 08 Nov 2018 13:56:06 +0000 Received: from smtp1.mailbox.org (unknown [IPv6:2001:67c:2050:105:465:1:1:0]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mx2.mailbox.org (Postfix) with ESMTPS id 65BB6A1B1A; Thu, 8 Nov 2018 14:55:58 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter04.heinlein-hosting.de (spamfilter04.heinlein-hosting.de [80.241.56.122]) (amavisd-new, port 10030) with ESMTP id uGXbKbm2gtz0; Thu, 8 Nov 2018 14:55:57 +0100 (CET) From: Antonin Houska To: Kyotaro HORIGUCHI cc: asp437@gmail.com, a.bykov@postgrespro.ru, pgsql-hackers@lists.postgresql.org Subject: Re: Optimze usage of immutable functions as relation In-reply-to: <20181024.120245.134697149.horiguchi.kyotaro@lab.ntt.co.jp> References: <20180906185109.661aaef0@asp437-ThinkPad-L380> <153994199621.10161.17815885396545049364.pgcf@coridan.postgresql.org> <20181024.120245.134697149.horiguchi.kyotaro@lab.ntt.co.jp> Comments: In-reply-to Kyotaro HORIGUCHI message dated "Wed, 24 Oct 2018 12:02:45 +0900." MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 08 Nov 2018 14:57:45 +0100 Message-ID: <10981.1541685465@localhost> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Kyotaro HORIGUCHI wrote: > I had the following error with the following query. >=20 > =3D# explain select * from pg_stat_get_activity(NULL) a join log(100000.0= ) p on a.pid =3D p.p; > ERROR: no relation entry for relid 2 >=20 I think that the problem is that RTE_VALUES is wrapped in a subquery by par= ser 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=3Dfalse regardless stric= tness 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). --=20 Antonin Houska Cybertec Sch=C3=B6nig & Sch=C3=B6nig GmbH Gr=C3=B6hrm=C3=BChlgasse 26, A-2700 Wiener Neustadt Web: https://www.cybertec-postgresql.com