Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Y0m6g-0004rH-8N for pgsql-bugs@arkaria.postgresql.org; Tue, 16 Dec 2014 06:59:42 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Y0m6f-00017G-Jl for pgsql-bugs@arkaria.postgresql.org; Tue, 16 Dec 2014 06:59:41 +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 1Y0m6e-00015A-25 for pgsql-bugs@postgresql.org; Tue, 16 Dec 2014 06:59:40 +0000 Received: from mwork.nabble.com ([162.253.133.43]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Y0m6a-00008m-6n for pgsql-bugs@postgresql.org; Tue, 16 Dec 2014 06:59:38 +0000 Received: from msam.nabble.com (unknown [162.253.133.85]) by mwork.nabble.com (Postfix) with ESMTP id 1595CDD47F8 for ; Mon, 15 Dec 2014 22:59:35 -0800 (PST) Date: Mon, 15 Dec 2014 23:59:34 -0700 (MST) From: David G Johnston To: pgsql-bugs@postgresql.org Message-ID: <1418713174152-5830851.post@n5.nabble.com> In-Reply-To: References: Subject: Re: execution plan and record variable in dynamic sql MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Pg-Spam-Score: -0.3 (/) 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 =D0=9F=D1=83=D1=88=D0=BA=D0=B8=D0=BD =D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9 w= rote > Hello! >=20 > The following code results in error, if executed in one session: >=20 > select * from exec($$ select 1 as status $$); > select * from exec($$ select 'test' as status $$); >=20 > Version: > PostgreSQL 9.4rc1 on x86_64-unknown-linux-gnu, compiled by gcc (Debian=20= =20 > 4.9.2-2) 4.9.2, 64-bit > also checked on PostgreSQL 9.1.9 SQL is a strongly typed language and this is a natural consequence of dealing with dynamic queries in such an environment. The performance gains of caching outweigh the ability to make code like your example work. You may wish to share a real use case that you think requires this to not error - and explain what it is you think it should do instead. The first notice works only because any record type can be converted to text regardless of the underlying fields but as soon as you want fields it matters that what you request matches the stored model. I think parameter 4 is the % in the format string...that string is cached with an integer type input and then is confused when an unknown is provided the next time around... I'm not sure how Line 8 is calculated in your example... David J. -- View this message in context: http://postgresql.nabble.com/execution-plan-a= nd-record-variable-in-dynamic-sql-tp5830846p5830851.html Sent from the PostgreSQL - bugs mailing list archive at Nabble.com. --=20 Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs