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
|
|
|
*
|
2009-01-01 12:24:05 -05:00
|
|
|
* Portions Copyright (c) 1996-2009, 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
|
2009-01-01 12:24:05 -05:00
|
|
|
* $PostgreSQL: pgsql/src/backend/utils/error/assert.c,v 1.36 2009/01/01 17:23:51 momjian Exp $
|
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()
|
2007-05-03 22:01:02 -04:00
|
|
|
*
|
|
|
|
|
* Note: this can't actually return, but we declare it as returning int
|
|
|
|
|
* because the TrapMacro() macro might get wonky otherwise.
|
2002-08-10 16:29:18 -04:00
|
|
|
*/
|
1996-07-09 02:22:35 -04:00
|
|
|
int
|
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();
|
1997-09-07 01:04:48 -04:00
|
|
|
|
1998-08-31 23:29:17 -04:00
|
|
|
return 0;
|
1996-07-09 02:22:35 -04:00
|
|
|
}
|