Skip to content

Commit c1c7b33

Browse files
committed
Reconsider context for calling callback functions --- original idea
that they aren't part of error processing is clearly faulty.
1 parent 0b96bad commit c1c7b33

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

src/backend/utils/error/elog.c

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
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, ...)
318318
MemoryContext oldcontext;
319319
ErrorContextCallback *econtext;
320320

321+
recursion_depth++;
321322
CHECK_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
*/
328335
for (econtext = error_context_stack;
329336
econtext != 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 */
345343
if (edata->output_to_server)
346344
send_message_to_server_log(edata);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy