diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2007-07-21 22:12:24 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2007-07-21 22:12:24 +0000 |
commit | 680a261529694e87ec30c788d3a057f67ff20286 (patch) | |
tree | b507d1d441e44206cba57e60274d0258da3c4e7c | |
parent | c216584b09a921001f2908efbbb991d9dee6307a (diff) |
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.
-rw-r--r-- | src/backend/utils/error/elog.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index 61039b66d8b..3faef16851e 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -42,7 +42,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.155.4.6 2007/07/19 19:15:25 adunstan Exp $ + * $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.155.4.7 2007/07/21 22:12:24 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -258,11 +258,16 @@ errstart(int elevel, const char *filename, int lineno, MemoryContextReset(ErrorContext); /* - * If we recurse more than once, the problem might be something - * broken in a context traceback routine. Abandon them too. + * If we recurse more than once, the problem might be something broken + * 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) + { error_context_stack = NULL; + debug_query_string = NULL; + } } if (++errordata_stack_depth >= ERRORDATA_STACK_SIZE) { |