Обсуждение: BUG #18081: Spurious "function with OID ###### does not exist" error

Поиск
Список
Период
Сортировка

BUG #18081: Spurious "function with OID ###### does not exist" error

От
PG Bug reporting form
Дата:
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


Re: BUG #18081: Spurious "function with OID ###### does not exist" error

От
Tom Lane
Дата:
PG Bug reporting form <noreply@postgresql.org> writes:
> PostgreSQL version: 13.5

> When executing the following sequence of statements:
> ...
> ...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

It works as expected for me in current branch tips (including 13.12
and 14.9).  I recall we made some fixes in plancache management that
probably explain your issue, but I don't recall details.

            regards, tom lane



Re: BUG #18081: Spurious "function with OID ###### does not exist" error

От
Branko Radovanovic
Дата:
My mistake apparently, I got this on 13.5 originally and then I tested on what I thought was 14.9, but it seems that was actually 14.4 - can't check at the moment. I hadn't been able to find information on this particular issue. Thanks, glad to see it fixed!

Best regards,
Branko Radovanovic


On Mon, Sep 4, 2023 at 5:30 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
PG Bug reporting form <noreply@postgresql.org> writes:
> PostgreSQL version: 13.5

> When executing the following sequence of statements:
> ...
> ...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

It works as expected for me in current branch tips (including 13.12
and 14.9).  I recall we made some fixes in plancache management that
probably explain your issue, but I don't recall details.

                        regards, tom lane