Re: execution plan and record variable in dynamic sql

From: David G Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Re: execution plan and record variable in dynamic sql
Date: 2014-12-16 06:59:34
Message-ID: 1418713174152-5830851.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-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.html
Sent from the PostgreSQL - bugs mailing list archive at Nabble.com.

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Пушкин Сергей 2014-12-16 09:14:41 Re: execution plan and record variable in dynamic sql
Previous Message Пушкин Сергей 2014-12-16 06:19:52 execution plan and record variable in dynamic sql