pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David G Johnston <david.g.johnston@gmail.com>
To: pgsql-bugs@postgresql.org
Subject: Re: execution plan and record variable in dynamic sql
Date: Mon, 15 Dec 2014 23:59:34 -0700 (MST)
Message-ID: <1418713174152-5830851.post@n5.nabble.com> (raw)
In-Reply-To: <op.xqx6jed6gskoan@pushkinsv.ood.local>
References: <op.xqx6jed6gskoan@pushkinsv.ood.local>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

Пушкин Сергей wrote
> Hello!
> 
> The following code results in error, if executed in one session:
> 
> select * from exec($$ select 1 as status $$);
> select * from exec($$ select 'test' as status $$);
> 
> Version:
> PostgreSQL 9.4rc1 on x86_64-unknown-linux-gnu, compiled by gcc (Debian  
> 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-and-record-variable-in-dynamic-sql-tp5830846p5830851.htm...
Sent from the PostgreSQL - bugs mailing list archive at Nabble.com.


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (5+ messages)  latest in thread

Message-ID: <1418713174152-5830851.post@n5.nabble.com>
Permalink:  ../1418713174152-5830851.post@n5.nabble.com/
Also on:    postgresql.org/message-id/1418713174152-5830851.post@n5.nabble.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: david.g.johnston@gmail.com
  Subject: Re: execution plan and record variable in dynamic sql
  In-Reply-To: <1418713174152-5830851.post@n5.nabble.com>
  References: <op.xqx6jed6gskoan@pushkinsv.ood.local> <1418713174152-5830851.post@n5.nabble.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox