From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: branko.radovanovic.zg@gmail.com
Subject: BUG #18081: Spurious "function with OID ###### does not exist" error
Date: Mon, 04 Sep 2023 09:12:06 +0000
Message-ID: <18081-c32695387b4971ac@postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 18081
Logged by: Branko Radovanovic
Email address: branko.radovanovic.zg@gmail.com
PostgreSQL version: 13.5
Operating system: Debian 8.3.0
Description:
When executing the following sequence of statements:
CREATE OR REPLACE PROCEDURE proc(param text default 'n/a')
LANGUAGE plpgsql
AS $procedure$
BEGIN
raise info 'proc(%)', param;
END;
$procedure$;
CREATE OR REPLACE PROCEDURE test1()
LANGUAGE plpgsql
AS $procedure$
BEGIN
call proc();
END;
$procedure$;
CREATE OR REPLACE PROCEDURE proc()
LANGUAGE plpgsql
AS $procedure$
BEGIN
raise info 'proc()';
END;
$procedure$;
DROP PROCEDURE proc(text);
CREATE OR REPLACE PROCEDURE test2()
LANGUAGE plpgsql
AS $procedure$
BEGIN
call proc();
END;
$procedure$;
call test2(); --#A
call test1(); --#B
...statement #A will output:
proc()
...which is as expected, while statement #B will throw an error:
SQL Error [42883]: ERROR: function with OID 102048 does not exist
Where: SQL statement "CALL proc()"
PL/pgSQL function test1() line 3 at CALL
I get this behavior in versions 13.5 and 14.9. This is strange because it
would imply that:
1) It is possible to have two procedures with identical bodies, one of which
works while the other does not
2) The way a procedure behaves is dependent on the state of the database in
the instant the procedure was created
Both of these conclusions break the mental model of plpgsql as being fully
interpreted. On top of that, this sort of situation cannot be detected by
parsing tools such as plpgsql_check nor by human review, as nothing is wrong
with the code itself. I would argue that #B should work exactly the same as
#A.
Best regards,
Branko Radovanovic
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, branko.radovanovic.zg@gmail.com
Subject: Re: BUG #18081: Spurious "function with OID ###### does not exist" error
In-Reply-To: <18081-c32695387b4971ac@postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox