1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-09 06:21:09 +03:00

Simplify our Assert infrastructure a little.

Remove the Trap and TrapMacro macros, which were nearly unused
and confusingly had the opposite condition polarity from the
otherwise-functionally-equivalent Assert macros.

Having done that, it's very hard to justify carrying the errorType
argument of ExceptionalCondition, so drop that too, and just
let it assume everything's an Assert.  This saves about 64K
of code space as of current HEAD.

Discussion: https://postgr.es/m/3928703.1665345117@sss.pgh.pa.us
This commit is contained in:
Tom Lane
2022-10-10 15:16:56 -04:00
parent 6291b2546c
commit 235eb4db98
5 changed files with 24 additions and 53 deletions

View File

@@ -28,20 +28,17 @@
*/
void
ExceptionalCondition(const char *conditionName,
const char *errorType,
const char *fileName,
int lineNumber)
{
/* Report the failure on stderr (or local equivalent) */
if (!PointerIsValid(conditionName)
|| !PointerIsValid(fileName)
|| !PointerIsValid(errorType))
|| !PointerIsValid(fileName))
write_stderr("TRAP: ExceptionalCondition: bad arguments in PID %d\n",
(int) getpid());
else
write_stderr("TRAP: %s(\"%s\", File: \"%s\", Line: %d, PID: %d)\n",
errorType, conditionName,
fileName, lineNumber, (int) getpid());
write_stderr("TRAP: failed Assert(\"%s\"), File: \"%s\", Line: %d, PID: %d\n",
conditionName, fileName, lineNumber, (int) getpid());
/* Usually this shouldn't be needed, but make sure the msg went out */
fflush(stderr);

View File

@@ -1832,8 +1832,7 @@ pg_re_throw(void)
}
/* Doesn't return ... */
ExceptionalCondition("pg_re_throw tried to return", "FailedAssertion",
__FILE__, __LINE__);
ExceptionalCondition("pg_re_throw tried to return", __FILE__, __LINE__);
}