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
|
|
|
*
|
2004-12-31 17:04:05 -05:00
|
|
|
* Portions Copyright (c) 1996-2005, 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
|
2004-12-31 17:04:05 -05:00
|
|
|
* $PostgreSQL: pgsql/src/backend/utils/error/assert.c,v 1.30 2004/12/31 22:01:27 pgsql 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()
|
|
|
|
|
*/
|
1996-07-09 02:22:35 -04:00
|
|
|
int
|
1997-09-07 01:04:48 -04:00
|
|
|
ExceptionalCondition(char *conditionName,
|
2002-08-10 16:29:18 -04:00
|
|
|
char *errorType,
|
1997-09-07 01:04:48 -04:00
|
|
|
char *fileName,
|
|
|
|
|
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
|
|
|
|
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
|
|
|
/*
|
2004-08-29 01:07:03 -04:00
|
|
|
* It would be nice to use pg_usleep() here, but only does 2000 sec or
|
|
|
|
|
* 33 minutes, which seems too short.
|
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
}
|