postgresql tries to reuse plan but fails because the (dynamic) query has changed

From: Alexey Bashtanov <bashtanov(at)imap(dot)cc>
To: pgsql-bugs(at)postgresql(dot)org
Subject: postgresql tries to reuse plan but fails because the (dynamic) query has changed
Date: 2013-12-26 11:39:30
Message-ID: 52BC1572.9050201@imap.cc
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi, all!

The following behavior found.

[ACTIONS]
execute the following code:
do $$
declare
a text;
cur record;
begin
foreach a in array array['p'] loop
for cur in execute 'select ' || a || ' r from
generate_series(3, 3) p' loop
raise notice '%', cur.r;
end loop;
end loop;
foreach a in array array['p||'',''||p*p'] loop
for cur in execute 'select ' || a || ' r from
generate_series(3, 3) p' loop
raise notice '%', cur.r;
end loop;
end loop;
foreach a in array array['p', 'p||'',''||p*p'] loop
for cur in execute 'select ' || a || ' r from
generate_series(3, 3) p' loop
raise notice '%', cur.r;
end loop;
end loop;
end;
$$;

[EXPECTED]
NOTICE: 3
NOTICE: 3,9
NOTICE: 3
NOTICE: 3,9
DO

[RECEIVED]
NOTICE: 3
NOTICE: 3,9
NOTICE: 3
ERROR: type of parameter 4 (text) does not match that when preparing
the plan (integer)
CONTEXT: PL/pgSQL function inline_code_block line 18 at RAISE

[VERSION]
PostgreSQL 9.3.1 on x86_64-unknown-linux-gnu, compiled by gcc (GCC)
4.4.7 20120313 (Red Hat 4.4.7-3), 64-bit
Linux 2.6.32-358.el6.x86_64 #1 SMP Fri Feb 22 00:31:26 UTC 2013 x86_64
x86_64 x86_64 GNU/Linux

also reproduced at postgresql 9.1.9, 9.3.2

[ALSO]
If current behavior is OK, please treat this bugreport as a bugreport on
documentation.
In what cases record variable is allowed or is not allowed to change its
structure?

Regards,
Alexey Bashtanov

Browse pgsql-bugs by date

  From Date Subject
Next Message Andrew Dunstan 2013-12-26 18:17:10 Re: BUG #8676: Bug Money JSON
Previous Message amutu 2013-12-26 02:47:47 BUG #8701: recover process hang on slave