mirror of
https://github.com/postgres/postgres.git
synced 2025-08-09 17:03:00 +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:
@@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.104.2.1 2005/10/14 16:41:41 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.104.2.2 2007/07/21 22:12:38 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -429,13 +429,18 @@ elog(int lev, const char *fmt,...)
|
|||||||
free(msg_buf);
|
free(msg_buf);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the user wants this elog() generating query logged, do so. We
|
* If the user wants this elog() generating query logged, do so.
|
||||||
* only want to log if the query has been written to
|
* To avoid possible infinite recursion, temporarily clear
|
||||||
* debug_query_string. Also, avoid infinite loops.
|
* debug_query_string while recursing.
|
||||||
*/
|
*/
|
||||||
|
if (lev >= log_min_error_statement && debug_query_string)
|
||||||
|
{
|
||||||
|
char *q_str = debug_query_string;
|
||||||
|
|
||||||
if (lev != LOG && lev >= log_min_error_statement && debug_query_string)
|
debug_query_string = NULL;
|
||||||
elog(LOG, "statement: %s", debug_query_string);
|
elog(LOG, "statement: %s", q_str);
|
||||||
|
debug_query_string = q_str;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Perform error recovery action as specified by lev.
|
* Perform error recovery action as specified by lev.
|
||||||
|
Reference in New Issue
Block a user