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

Поиск
Список
Период
Сортировка
От M.Mamin@intershop.de
Тема BUG #8833: nested dynamic cursors may lead to type mismatch compared to the initial plan
Дата
Msg-id 20140114165128.30128.17990@wrigleys.postgresql.org
обсуждение исходный текст
Список pgsql-bugs
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

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Umesh Kirdat
Дата:
Сообщение: Re: Duplicate key violates unique constraint
Следующее
От: Sergey Konoplev
Дата:
Сообщение: An odd thing with postgresql92-debuginfo-9.2.6-1PGDG.rhel6.x86_64.rpm