Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YZh8j-00020M-MK for pgsql-bugs@arkaria.postgresql.org; Sun, 22 Mar 2015 14:46:09 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YZh8j-0004vr-18 for pgsql-bugs@arkaria.postgresql.org; Sun, 22 Mar 2015 14:46:09 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YZh8i-0004vj-2t for pgsql-bugs@postgresql.org; Sun, 22 Mar 2015 14:46:08 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YZh8d-0003Ox-M3 for pgsql-bugs@postgresql.org; Sun, 22 Mar 2015 14:46:07 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id t2MEk0KY014131; Sun, 22 Mar 2015 10:46:00 -0400 From: Tom Lane To: "David G. Johnston" cc: Paragon Corporation , "pgsql-bugs@postgresql.org" Subject: Re: BUG #12869: PostGIS 2.2 can't compile against 9.5 dev branch In-reply-to: References: <001c01d0647a$397bb260$ac731720$@pcorp.us> Comments: In-reply-to "David G. Johnston" message dated "Sun, 22 Mar 2015 02:07:35 -0700" Date: Sun, 22 Mar 2015 10:46:00 -0400 Message-ID: <14130.1427035560@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org "David G. Johnston" writes: > On Sunday, March 22, 2015, Paragon Corporation wrote: >> SELECT v[1] As v1, v[2] As v2, v[3] As v3 >> FROM >> (SELECT dummy_notice(1,2,3) As v) As t; > I suspect Tom's optimization: > http://git.postgresql.org/pg/commitdiff/f4abd0241de20d5d6a79b84992b9e88603d44134 > is flattening the array returning function into the select-list of the > outer query so it effectively reads: > Select Dummy_notice(1,2,3)[1], dummy_notice(1,2,3)[2], etc... Yeah. You could put "OFFSET 0" into the sub-select if you want to ensure it will not be flattened. > The flatten would work if the result could be cached...it is defined to > be immutable...but that would not be reliable generally... Note that "immutable" effectively means "having no side-effects of interest", so emitting a NOTICE from such a function is really cheating. Another solution would be to mark the function VOLATILE. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs