BUG #8833: nested dynamic cursors may lead to type mismatch compared to the initial plan

From: M(dot)Mamin(at)intershop(dot)de
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #8833: nested dynamic cursors may lead to type mismatch compared to the initial plan
Date: 2014-01-14 16:51:28
Message-ID: 20140114165128.30128.17990@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 8833
Logged by: Marc Mamin
Email address: M(dot)Mamin(at)intershop(dot)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

Browse pgsql-bugs by date

  From Date Subject
Next Message Sergey Konoplev 2014-01-14 21:57:35 An odd thing with postgresql92-debuginfo-9.2.6-1PGDG.rhel6.x86_64.rpm
Previous Message Tom Lane 2014-01-14 15:13:16 Re: BUG #8830: Query with a subquery failes to execute if this subquery does not contain references to own table