execution plan and record variable in dynamic sql - Mailing list pgsql-bugs

From Пушкин Сергей
Subject execution plan and record variable in dynamic sql
Date
Msg-id op.xqx6jed6gskoan@pushkinsv.ood.local
Whole thread Raw
Responses Re: execution plan and record variable in dynamic sql
List pgsql-bugs
Hello!

The following code results in error, if executed in one session:


create or replace function exec(sql text)
returns void language plpgsql as $_$
declarer record;
beginexecute sql into r;
-- works ok everytimeraise notice 'r %', r;
-- fails if type of r.status differs from first exec invocation-- making r.status inaccessibleraise notice 'r.status
%',r.status; 
end;
$_$;

select * from exec($$ select 1 as status $$);
select * from exec($$ select 'test' as status $$);

Results:

NOTICE:  r (1)
NOTICE:  r.status 1 exec
------

(1 row)

NOTICE:  r (test)
ERROR:  type of parameter 4 (iso-8859-1) does not match that when preparing
the plan (integer)
Context:  PL/pgSQL function exec(text) line 8 at RAISE


Version:
PostgreSQL 9.4rc1 on x86_64-iso-8859-1-linux-gnu, compiled by gcc (Debian
4.9.2-2) 4.9.2, 64-bit
also checked on PostgreSQL 9.1.9

Thanks!
--
Serge Pushkin



pgsql-bugs by date:

Previous
From: David G Johnston
Date:
Subject: Re: BUG #12241: uninitialized value $lib_path
Next
From: David G Johnston
Date:
Subject: Re: execution plan and record variable in dynamic sql