1
0
mirror of https://github.com/postgres/postgres.git synced 2025-05-17 06:41:24 +03:00

Fix elog.c to avoid infinite recursion (leading to backend crash) when

log_min_error_statement is active and there is some problem in logging the
current query string; for example, that it's too long to include in the log
message without running out of memory.  This problem has existed since the
log_min_error_statement feature was introduced.  No doubt the reason it
wasn't detected long ago is that 8.2 is the first release that defaults
log_min_error_statement to less than PANIC level.
Per report from Bill Moran.
This commit is contained in:
Tom Lane 2007-07-21 22:12:32 +00:00
parent 6e606074e1
commit 83630c88b9

View File

@ -37,7 +37,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.125.2.2 2005/10/20 01:31:50 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.125.2.3 2007/07/21 22:12:32 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -254,11 +254,16 @@ errstart(int elevel, const char *filename, int lineno,
MemoryContextReset(ErrorContext); MemoryContextReset(ErrorContext);
/* /*
* If we recurse more than once, the problem might be something * If we recurse more than once, the problem might be something broken
* broken in a context traceback routine. Abandon them too. * in a context traceback routine. Abandon them too. We also
* abandon attempting to print the error statement (which, if long,
* could itself be the source of the recursive failure).
*/ */
if (recursion_depth > 2) if (recursion_depth > 2)
{
error_context_stack = NULL; error_context_stack = NULL;
debug_query_string = NULL;
}
} }
if (++errordata_stack_depth >= ERRORDATA_STACK_SIZE) if (++errordata_stack_depth >= ERRORDATA_STACK_SIZE)
{ {