3737 *
3838 *
3939 * IDENTIFICATION
40- * $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.115 2003/07/27 21:49:54 tgl Exp $
40+ * $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.116 2003/08/03 23:44:44 tgl Exp $
4141 *
4242 *-------------------------------------------------------------------------
4343 */
@@ -318,12 +318,19 @@ errfinish(int dummy, ...)
318318MemoryContext oldcontext ;
319319ErrorContextCallback * econtext ;
320320
321+ recursion_depth ++ ;
321322CHECK_STACK_DEPTH ();
322323
323324/*
324- * Call any context callback functions. We can treat ereports occuring
325- * in callback functions as re-entrant rather than recursive case, so
326- * don't increment recursion_depth yet.
325+ * Do processing in ErrorContext, which we hope has enough reserved space
326+ * to report an error.
327+ */
328+ oldcontext = MemoryContextSwitchTo (ErrorContext );
329+
330+ /*
331+ * Call any context callback functions. Errors occurring in callback
332+ * functions will be treated as recursive errors --- this ensures we
333+ * will avoid infinite recursion (see errstart).
327334 */
328335for (econtext = error_context_stack ;
329336econtext != NULL ;
@@ -332,15 +339,6 @@ errfinish(int dummy, ...)
332339(* econtext -> callback ) (econtext -> arg );
333340}
334341
335- /* Now we are ready to process the error. */
336- recursion_depth ++ ;
337-
338- /*
339- * Do processing in ErrorContext, which we hope has enough reserved space
340- * to report an error.
341- */
342- oldcontext = MemoryContextSwitchTo (ErrorContext );
343-
344342/* Send to server log, if enabled */
345343if (edata -> output_to_server )
346344send_message_to_server_log (edata );