Re: plpgsql functions crash cvs

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Kris Jurka <books(at)ejurka(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: plpgsql functions crash cvs
Date: 2006-03-02 01:22:25
Message-ID: 20060302012224.GA11359@surnet.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Kris Jurka wrote:
>
> eKol in #postgresql reported a problem with a plpgsql function crashing
> the server. I tested the attached against 8.2cvs as of this morning
> and got this stacktrace:

Interesting. 8.1 also crashes. 8.0 instead gives this output:

psql:/home/alvherre/funcs.sql:86: ERROR: control reached end of function without RETURN
CONTEXT: PL/pgSQL function "fn_revoke_all_functions_from"
SQL statement "SELECT admin.fn_revoke_all_functions_from( $1 , $2 )"
PL/pgSQL function "fn_revoke_all" line 11 at perform
psql:/home/alvherre/funcs.sql:88: ERROR: control reached end of function without RETURN
CONTEXT: PL/pgSQL function "fn_revoke_all_functions_from"
SQL statement "SELECT admin.fn_revoke_all_functions_from( $1 , $2 )"
PL/pgSQL function "fn_revoke_all" line 11 at perform
psql:/home/alvherre/funcs.sql:89: ERROR: control reached end of function without RETURN
CONTEXT: PL/pgSQL function "fn_revoke_all_functions_from"
SQL statement "SELECT admin.fn_revoke_all_functions_from( $1 , $2 )"
PL/pgSQL function "fn_revoke_all" line 11 at perform
psql:/home/alvherre/funcs.sql:90: ERROR: control reached end of function without RETURN
CONTEXT: PL/pgSQL function "fn_revoke_all_functions_from"
SQL statement "SELECT admin.fn_revoke_all_functions_from( $1 , $2 )"
PL/pgSQL function "fn_revoke_all" line 11 at perform

In 8.1, the backtrace reads thus:

(gdb) bt
#0 plpgsql_xact_cb (event=XACT_EVENT_COMMIT, arg=0x0)
at /pgsql/source/81_rel/src/pl/plpgsql/src/pl_exec.c:4525
#1 0x080b37ed in CallXactCallbacks (event=XACT_EVENT_COMMIT)
at /pgsql/source/81_rel/src/backend/access/transam/xact.c:2618
#2 0x080b5923 in CommitTransaction ()
at /pgsql/source/81_rel/src/backend/access/transam/xact.c:1534
#3 0x080b73d9 in CommitTransactionCommand ()
at /pgsql/source/81_rel/src/backend/access/transam/xact.c:2184
#4 0x081e2d8d in finish_xact_command ()
at /pgsql/source/81_rel/src/backend/tcop/postgres.c:2006
#5 0x081e40c5 in exec_simple_query (
query_string=0x83d011c "SELECT admin.fn_revoke_all('public');")
at /pgsql/source/81_rel/src/backend/tcop/postgres.c:1032
#6 0x081e593d in PostgresMain (argc=4, argv=0x8372898,
username=0x8372860 "alvherre")
at /pgsql/source/81_rel/src/backend/tcop/postgres.c:3217
#7 0x081b771a in ServerLoop ()
at /pgsql/source/81_rel/src/backend/postmaster/postmaster.c:2853
#8 0x081b88d4 in PostmasterMain (argc=1, argv=0x8371860)
at /pgsql/source/81_rel/src/backend/postmaster/postmaster.c:941
#9 0x081753c9 in main (argc=1, argv=0x8371860)
at /pgsql/source/81_rel/src/backend/main/main.c:265
(gdb) info locals
expr = (PLpgSQL_expr *) 0x7f7f7f7f
enext = <value optimized out>

So the problem seems to be that the context containing the PLpgSQL_expr
was reset too early. I'll investigate more after dinner, if somebody
doesn't beat me to it.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2006-03-02 01:35:34 Re: plpgsql functions crash cvs
Previous Message Kris Jurka 2006-03-02 00:58:50 plpgsql functions crash cvs