Re: BUG #18131: PL/pgSQL: regclass procedure parameter wrongly memoized(?)
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: cstork+postgresql@gmail.com
Cc: pgsql-bugs@lists.postgresql.org,
Peter Eisentraut <peter.eisentraut@enterprisedb.com>
Date: 2023-09-23T16:39:04Z
Lists: pgsql-bugs
Attachments
- v1-track-dependencies-of-CallStmt.patch (text/x-diff) patch v1
PG Bug reporting form <noreply@postgresql.org> writes:
> The following condensed recipe reproduces the error:
> create procedure callee(t regclass)
> language plpgsql as
> $body$
> begin
> raise notice 'callee: oid = %', t::oid;
> execute 'table ' || t;
> end;
> $body$;
> create procedure caller()
> language plpgsql as
> $body$
> begin
> create table table_name ();
> raise notice 'caller: oid = %', 'table_name'::regclass::oid;
> call callee('table_name');
> drop table table_name;
> end;
> $body$;
> call caller(); -- OK
> call caller(); -- ERROR: callee executed with OID of previous invocation!
Hmm. It's not just regclass: we're failing to track *any* dependencies
of the compiled CallStmt. So you can also break it by, say, dropping
and recreating the "callee" procedure.
The attached quick hack fixes the reported symptoms, but I wonder
if there is a better place to do it.
regards, tom lane
Commits
-
Collect dependency information for parsed CallStmts.
- dc8d72c1c213 17.0 landed
- 055f786ea6a8 16.1 landed
- fdc7cf73b424 11.22 landed
- 8cfc3e80b612 13.13 landed
- 5cff431bc9b8 14.10 landed
- 4435a8d5dbab 12.17 landed
- 0e59266a5daf 15.5 landed