diff --git a/src/backend/storage/ipc/ipc.c b/src/backend/storage/ipc/ipc.c index dfe7161f42..d6eaf2a5ef 100644 --- a/src/backend/storage/ipc/ipc.c +++ b/src/backend/storage/ipc/ipc.c @@ -13,7 +13,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/storage/ipc/ipc.c,v 1.100.2.1 2008/04/16 23:59:51 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/storage/ipc/ipc.c,v 1.100.2.2 2010/03/20 00:58:21 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -28,6 +28,7 @@ #include "postmaster/autovacuum.h" #endif #include "storage/ipc.h" +#include "tcop/tcopprot.h" /* @@ -95,6 +96,19 @@ proc_exit(int code) InterruptHoldoffCount = 1; CritSectionCount = 0; + /* + * Also clear the error context stack, to prevent error callbacks + * from being invoked by any elog/ereport calls made during proc_exit. + * Whatever context they might want to offer is probably not relevant, + * and in any case they are likely to fail outright after we've done + * things like aborting any open transaction. (In normal exit scenarios + * the context stack should be empty anyway, but it might not be in the + * case of elog(FATAL) for example.) + */ + error_context_stack = NULL; + /* For the same reason, reset debug_query_string before it's clobbered */ + debug_query_string = NULL; + elog(DEBUG3, "proc_exit(%d)", code); /* do our shared memory exits first */