1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-25 20:23:07 +03:00
Files
postgres/src/backend/utils/error/assert.c
Peter Eisentraut 81107282a5 Change return type of ExceptionalCondition to void and mark it noreturn
In ancient times, it was thought that this wouldn't work because of
TrapMacro/AssertMacro, but changing those to use a comma operator
appears to work without compiler warnings.
2012-04-29 21:20:14 +03:00

56 lines
1.2 KiB
C

/*-------------------------------------------------------------------------
*
* assert.c
* Assert code.
*
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* src/backend/utils/error/assert.c
*
* NOTE
* This should eventually work with elog()
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include <unistd.h>
/*
* ExceptionalCondition - Handles the failure of an Assert()
*/
void
ExceptionalCondition(const char *conditionName,
const char *errorType,
const char *fileName,
int lineNumber)
{
if (!PointerIsValid(conditionName)
|| !PointerIsValid(fileName)
|| !PointerIsValid(errorType))
write_stderr("TRAP: ExceptionalCondition: bad arguments\n");
else
{
write_stderr("TRAP: %s(\"%s\", File: \"%s\", Line: %d)\n",
errorType, conditionName,
fileName, lineNumber);
}
/* Usually this shouldn't be needed, but make sure the msg went out */
fflush(stderr);
#ifdef SLEEP_ON_ASSERT
/*
* It would be nice to use pg_usleep() here, but only does 2000 sec or 33
* minutes, which seems too short.
*/
sleep(1000000);
#endif
abort();
}