Thread: BUG #8833: nested dynamic cursors may lead to type mismatch compared to the initial plan
BUG #8833: nested dynamic cursors may lead to type mismatch compared to the initial plan
From
M.Mamin@intershop.de
Date:
The following bug has been logged on the website: Bug reference: 8833 Logged by: Marc Mamin Email address: M.Mamin@intershop.de PostgreSQL version: 9.3.2 Operating system: Linux Description: Hello, The example below yelds an error. To avoid this, it seems that the internal cursor (rec2) should be replanned dynamically at each iteration (of rec). Not sure if you would consider it as a bug... Regards, Marc Mamin create temp table t1 (id int, val text); create temp table t2 (id int8, val text); insert into t1 values(1,'foo1'); insert into t2 values(1,'foo2'); DO $$ DECLARE rec record; rec2 record; target text; BEGIN for rec in select 't1' as tname UNION select 't2' loop for rec2 in EXECUTE 'select id from '||rec.tname loop EXECUTE 'select val from '||rec.tname||' where id = '|| rec2.id into target; end loop; end loop; END; $$ language plpgsql ERROR: type of parameter 7 (bigint) does not match that when preparing the plan (integer) SQL state: 42804 Context: PL/pgSQL function inline_code_block line 16 at EXECUTE statement