Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit681690f

Browse files
committed
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 thecurrent query string; for example, that it's too long to include in the logmessage without running out of memory. This problem has existed since thelog_min_error_statement feature was introduced. No doubt the reason itwasn't detected long ago is that 8.2 is the first release that defaultslog_min_error_statement to less than PANIC level.Per report from Bill Moran.
1 parentc556447 commit681690f

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

‎src/backend/utils/error/elog.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.104.2.1 2005/10/14 16:41:41 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.104.2.2 2007/07/21 22:12:38 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -429,13 +429,18 @@ elog(int lev, const char *fmt,...)
429429
free(msg_buf);
430430

431431
/*
432-
* If the user wants this elog() generating query logged, do so. We
433-
*only want to log if the query has been written to
434-
* debug_query_string. Also, avoid infinite loops.
432+
* If the user wants this elog() generating query logged, do so.
433+
*To avoid possible infinite recursion, temporarily clear
434+
* debug_query_string while recursing.
435435
*/
436+
if (lev >=log_min_error_statement&&debug_query_string)
437+
{
438+
char*q_str=debug_query_string;
436439

437-
if (lev!=LOG&&lev >=log_min_error_statement&&debug_query_string)
438-
elog(LOG,"statement: %s",debug_query_string);
440+
debug_query_string=NULL;
441+
elog(LOG,"statement: %s",q_str);
442+
debug_query_string=q_str;
443+
}
439444

440445
/*
441446
* Perform error recovery action as specified by lev.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp