Thread

Commits

  1. Fix error-cleanup mistakes in exec_stmt_call().

  1. repeated procedure call error

    Pavel Stehule <pavel.stehule@gmail.com> — 2018-11-09T19:05:07Z

    Hi
    
    There are some broken. I tried to fix plpgsql_check regression tests and I
    found new error.
    
    Looks it is fresh regression.
    
    CREATE OR REPLACE PROCEDURE public.proc(a integer, INOUT b integer, c
    integer)
     LANGUAGE plpgsql
    AS $procedure$
    begin
      b := a + c + c;
    end;
    $procedure$
    
    CREATE OR REPLACE PROCEDURE public.testproc()
     LANGUAGE plpgsql
    AS $procedure$
    declare r int;
    begin
      call proc(10, r + 10, 20);
    end;
    $procedure$
    
    postgres=# call testproc();
    ERROR:  procedure parameter "b" is an output parameter but corresponding
    argument is not writable
    CONTEXT:  PL/pgSQL function testproc() line 4 at CALL
    
    first error message is correct,
    
    Second call fails with unexpected error
    
    ERROR:  SPI_execute_plan_with_paramlist failed executing query "CALL
    proc(10, r + 10, 20)": SPI_ERROR_ARGUMENT
    CONTEXT:  PL/pgSQL function testproc() line 4 at CALL
    
    regards
    
    Pavel
    
  2. Re: repeated procedure call error

    Pavel Stehule <pavel.stehule@gmail.com> — 2018-11-09T19:07:58Z

    pá 9. 11. 2018 v 20:05 odesílatel Pavel Stehule <pavel.stehule@gmail.com>
    napsal:
    
    > Hi
    >
    > There are some broken. I tried to fix plpgsql_check regression tests and I
    > found new error.
    >
    > Looks it is fresh regression.
    >
    > CREATE OR REPLACE PROCEDURE public.proc(a integer, INOUT b integer, c
    > integer)
    >  LANGUAGE plpgsql
    > AS $procedure$
    > begin
    >   b := a + c + c;
    > end;
    > $procedure$
    >
    > CREATE OR REPLACE PROCEDURE public.testproc()
    >  LANGUAGE plpgsql
    > AS $procedure$
    > declare r int;
    > begin
    >   call proc(10, r + 10, 20);
    > end;
    > $procedure$
    >
    > postgres=# call testproc();
    > ERROR:  procedure parameter "b" is an output parameter but corresponding
    > argument is not writable
    > CONTEXT:  PL/pgSQL function testproc() line 4 at CALL
    >
    > first error message is correct,
    >
    > Second call fails with unexpected error
    >
    > ERROR:  SPI_execute_plan_with_paramlist failed executing query "CALL
    > proc(10, r + 10, 20)": SPI_ERROR_ARGUMENT
    > CONTEXT:  PL/pgSQL function testproc() line 4 at CALL
    >
    
    Maybe plan cache is broken due exception?
    
    
    
    > regards
    >
    > Pavel
    >
    >
    >
    
  3. Re: repeated procedure call error

    Pavel Stehule <pavel.stehule@gmail.com> — 2018-11-09T19:37:10Z

    pá 9. 11. 2018 v 20:07 odesílatel Pavel Stehule <pavel.stehule@gmail.com>
    napsal:
    
    >
    >
    > pá 9. 11. 2018 v 20:05 odesílatel Pavel Stehule <pavel.stehule@gmail.com>
    > napsal:
    >
    >> Hi
    >>
    >> There are some broken. I tried to fix plpgsql_check regression tests and
    >> I found new error.
    >>
    >> Looks it is fresh regression.
    >>
    >> CREATE OR REPLACE PROCEDURE public.proc(a integer, INOUT b integer, c
    >> integer)
    >>  LANGUAGE plpgsql
    >> AS $procedure$
    >> begin
    >>   b := a + c + c;
    >> end;
    >> $procedure$
    >>
    >> CREATE OR REPLACE PROCEDURE public.testproc()
    >>  LANGUAGE plpgsql
    >> AS $procedure$
    >> declare r int;
    >> begin
    >>   call proc(10, r + 10, 20);
    >> end;
    >> $procedure$
    >>
    >> postgres=# call testproc();
    >> ERROR:  procedure parameter "b" is an output parameter but corresponding
    >> argument is not writable
    >> CONTEXT:  PL/pgSQL function testproc() line 4 at CALL
    >>
    >> first error message is correct,
    >>
    >> Second call fails with unexpected error
    >>
    >> ERROR:  SPI_execute_plan_with_paramlist failed executing query "CALL
    >> proc(10, r + 10, 20)": SPI_ERROR_ARGUMENT
    >> CONTEXT:  PL/pgSQL function testproc() line 4 at CALL
    >>
    >
    > Maybe plan cache is broken due exception?
    >
    
    The problem is unsaved plan - probably there should be big PG_TRY block.
    Ugly fix just for testing
    
    diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c
    index 8dc716bee4..acb93f918c 100644
    --- a/src/pl/plpgsql/src/pl_exec.c
    +++ b/src/pl/plpgsql/src/pl_exec.c
    @@ -2186,6 +2186,10 @@ exec_stmt_call(PLpgSQL_execstate *estate,
    PLpgSQL_stmt_call *stmt)
                        }
                        else
                        {
    +
    +                       if (expr->plan && !expr->plan->saved)
    +                           expr->plan = NULL;
    +
                            /* report error using parameter name, if available
    */
                            if (argnames && argnames[i] && argnames[i][0])
                                ereport(ERROR,
    
    
    
    >
    >
    >
    >> regards
    >>
    >> Pavel
    >>
    >>
    >>
    
  4. Re: repeated procedure call error

    Tom Lane <tgl@sss.pgh.pa.us> — 2018-11-10T03:05:08Z

    Pavel Stehule <pavel.stehule@gmail.com> writes:
    > The problem is unsaved plan - probably there should be big PG_TRY block.
    
    Yeah, agreed.  Done -- thanks for the report!
    
    			regards, tom lane