diff options
author | Tom Lane | 2007-07-21 22:12:38 +0000 |
---|---|---|
committer | Tom Lane | 2007-07-21 22:12:38 +0000 |
commit | 4bf79373a50470c5e95502c46ddd4acbedc7cba7 (patch) | |
tree | 3fda830249eb4500448a924193827627c272f124 | |
parent | f244ffe803d097ab194d21135ec79b1af7f75a42 (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 | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index ad561f4178..11d3799717 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -240,10 +240,15 @@ errstart(int elevel, const char *filename, int lineno, /* * If we recurse more than once, the problem might be something 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) + { error_context_stack = NULL; + debug_query_string = NULL; + } } if (++errordata_stack_depth >= ERRORDATA_STACK_SIZE) { |