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

Commit79ca7ff

Browse files
committed
A few fixups in error handling: mark pg_re_throw() as noreturn for gcc,
and for other compilers, insert a dummy exit() call so that they understandPG_RE_THROW() doesn't return. Insert fflush(stderr) in ExceptionalCondition,per recent buildfarm evidence that that might not happen automatically on someplatforms. And const-ify ExceptionalCondition's declaration while at it.
1 parentd26559d commit79ca7ff

File tree

4 files changed

+36
-10
lines changed

4 files changed

+36
-10
lines changed

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/error/assert.c,v 1.33 2007/01/05 22:19:43 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/error/assert.c,v 1.34 2007/05/04 02:01:02 tgl Exp $
1212
*
1313
* NOTE
1414
* This should eventually work with elog()
@@ -21,11 +21,14 @@
2121

2222
/*
2323
* ExceptionalCondition - Handles the failure of an Assert()
24+
*
25+
* Note: this can't actually return, but we declare it as returning int
26+
* because the TrapMacro() macro might get wonky otherwise.
2427
*/
2528
int
26-
ExceptionalCondition(char*conditionName,
27-
char*errorType,
28-
char*fileName,
29+
ExceptionalCondition(constchar*conditionName,
30+
constchar*errorType,
31+
constchar*fileName,
2932
intlineNumber)
3033
{
3134
if (!PointerIsValid(conditionName)
@@ -39,6 +42,9 @@ ExceptionalCondition(char *conditionName,
3942
fileName,lineNumber);
4043
}
4144

45+
/* Usually this shouldn't be needed, but make sure the msg went out */
46+
fflush(stderr);
47+
4248
#ifdefSLEEP_ON_ASSERT
4349

4450
/*

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
*
4343
*
4444
* IDENTIFICATION
45-
* $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.184 2007/05/02 15:32:41 tgl Exp $
45+
* $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.185 2007/05/04 02:01:02 tgl Exp $
4646
*
4747
*-------------------------------------------------------------------------
4848
*/
@@ -1151,6 +1151,16 @@ pg_re_throw(void)
11511151

11521152
errfinish(0);
11531153
}
1154+
1155+
/* We mustn't return... */
1156+
ExceptionalCondition("pg_re_throw tried to return","FailedAssertion",
1157+
__FILE__,__LINE__);
1158+
1159+
/*
1160+
* Since ExceptionalCondition isn't declared noreturn because of
1161+
* TrapMacro(), we need this to keep gcc from complaining.
1162+
*/
1163+
abort();
11541164
}
11551165

11561166

‎src/include/postgres.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
1111
* Portions Copyright (c) 1995, Regents of the University of California
1212
*
13-
* $PostgreSQL: pgsql/src/include/postgres.h,v 1.79 2007/04/06 04:21:44 tgl Exp $
13+
* $PostgreSQL: pgsql/src/include/postgres.h,v 1.80 2007/05/04 02:01:02 tgl Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -694,8 +694,9 @@ extern DLLIMPORT bool assert_enabled;
694694
Trap(!(condition), "BadState")
695695
#endif/* USE_ASSERT_CHECKING */
696696

697-
externintExceptionalCondition(char*conditionName,char*errorType,
698-
char*fileName,intlineNumber);
697+
externintExceptionalCondition(constchar*conditionName,
698+
constchar*errorType,
699+
constchar*fileName,intlineNumber);
699700

700701
/* ----------------------------------------------------------------
701702
*Section 4: genbki macros used by catalog/pg_xxx.h files

‎src/include/utils/elog.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/utils/elog.h,v 1.85 2007/05/02 15:32:42 tgl Exp $
10+
* $PostgreSQL: pgsql/src/include/utils/elog.h,v 1.86 2007/05/04 02:01:02 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -222,8 +222,17 @@ extern DLLIMPORT ErrorContextCallback *error_context_stack;
222222
error_context_stack = save_context_stack; \
223223
} while (0)
224224

225+
/*
226+
* gcc understands __attribute__((noreturn)); for other compilers, insert
227+
* a useless exit() call so that the compiler gets the point.
228+
*/
229+
#ifdef__GNUC__
225230
#definePG_RE_THROW() \
226231
pg_re_throw()
232+
#else
233+
#definePG_RE_THROW() \
234+
(pg_re_throw(), exit(1))
235+
#endif
227236

228237
externDLLIMPORTsigjmp_buf*PG_exception_stack;
229238

@@ -262,7 +271,7 @@ extern ErrorData *CopyErrorData(void);
262271
externvoidFreeErrorData(ErrorData*edata);
263272
externvoidFlushErrorState(void);
264273
externvoidReThrowError(ErrorData*edata);
265-
externvoidpg_re_throw(void);
274+
externvoidpg_re_throw(void) __attribute__((noreturn));
266275

267276

268277
/* GUC-configurable parameters */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp