1996-07-09 02:22:35 -04:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
*
|
1999-02-13 18:22:53 -05:00
|
|
|
* assert.c
|
1997-09-07 01:04:48 -04:00
|
|
|
* Assert code.
|
1996-07-09 02:22:35 -04:00
|
|
|
*
|
2015-01-06 11:43:47 -05:00
|
|
|
* Portions Copyright (c) 1996-2015, PostgreSQL Global Development Group
|
2000-01-26 00:58:53 -05:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-07-09 02:22:35 -04:00
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* IDENTIFICATION
|
2010-09-20 16:08:53 -04:00
|
|
|
* src/backend/utils/error/assert.c
|
1996-07-09 02:22:35 -04:00
|
|
|
*
|
|
|
|
|
* NOTE
|
2002-08-10 16:29:18 -04:00
|
|
|
* This should eventually work with elog()
|
1996-07-09 02:22:35 -04:00
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
1999-07-15 23:14:30 -04:00
|
|
|
#include "postgres.h"
|
1996-07-09 02:22:35 -04:00
|
|
|
|
2000-05-30 20:28:42 -04:00
|
|
|
#include <unistd.h>
|
|
|
|
|
|
2002-08-10 16:29:18 -04:00
|
|
|
/*
|
|
|
|
|
* ExceptionalCondition - Handles the failure of an Assert()
|
|
|
|
|
*/
|
2012-04-29 14:07:35 -04:00
|
|
|
void
|
2007-05-03 22:01:02 -04:00
|
|
|
ExceptionalCondition(const char *conditionName,
|
|
|
|
|
const char *errorType,
|
|
|
|
|
const char *fileName,
|
1997-09-07 01:04:48 -04:00
|
|
|
int lineNumber)
|
1996-07-09 02:22:35 -04:00
|
|
|
{
|
1997-09-07 01:04:48 -04:00
|
|
|
if (!PointerIsValid(conditionName)
|
|
|
|
|
|| !PointerIsValid(fileName)
|
2002-08-10 16:29:18 -04:00
|
|
|
|| !PointerIsValid(errorType))
|
2004-06-24 17:03:42 -04:00
|
|
|
write_stderr("TRAP: ExceptionalCondition: bad arguments\n");
|
1997-09-07 01:04:48 -04:00
|
|
|
else
|
|
|
|
|
{
|
2004-06-24 17:03:42 -04:00
|
|
|
write_stderr("TRAP: %s(\"%s\", File: \"%s\", Line: %d)\n",
|
2004-08-29 01:07:03 -04:00
|
|
|
errorType, conditionName,
|
|
|
|
|
fileName, lineNumber);
|
1997-09-07 01:04:48 -04:00
|
|
|
}
|
1996-11-11 06:49:40 -05:00
|
|
|
|
2007-05-03 22:01:02 -04:00
|
|
|
/* Usually this shouldn't be needed, but make sure the msg went out */
|
|
|
|
|
fflush(stderr);
|
|
|
|
|
|
1998-06-18 12:35:38 -04:00
|
|
|
#ifdef SLEEP_ON_ASSERT
|
2004-08-29 01:07:03 -04:00
|
|
|
|
2004-04-19 13:42:59 -04:00
|
|
|
/*
|
2005-10-14 22:49:52 -04:00
|
|
|
* It would be nice to use pg_usleep() here, but only does 2000 sec or 33
|
|
|
|
|
* minutes, which seems too short.
|
2004-08-29 01:07:03 -04:00
|
|
|
*/
|
|
|
|
|
sleep(1000000);
|
1998-06-18 12:35:38 -04:00
|
|
|
#endif
|
1997-09-07 01:04:48 -04:00
|
|
|
|
2002-08-10 16:29:18 -04:00
|
|
|
abort();
|
1996-07-09 02:22:35 -04:00
|
|
|
}
|