postgresql/src/backend/utils/error/assert.c

76 lines
1.7 KiB
C
Raw Normal View History

/*-------------------------------------------------------------------------
*
* assert.c
* Assert code.
*
* Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
1999-07-15 23:14:30 -04:00
* $Header: /cvsroot/pgsql/src/backend/utils/error/assert.c,v 1.15 1999/07/16 03:14:20 momjian Exp $
*
* NOTE
* This should eventually work with elog(), dlog(), etc.
*
*-------------------------------------------------------------------------
*/
#include <stdio.h>
1998-06-18 12:35:38 -04:00
#include <unistd.h>
1999-07-15 23:14:30 -04:00
#include "postgres.h"
#include "utils/exc.h"
#include "utils/trace.h"
int
ExceptionalCondition(char *conditionName,
Exception *exceptionP,
char *detail,
char *fileName,
int lineNumber)
{
extern char *ExcFileName; /* XXX */
extern Index ExcLineNumber; /* XXX */
ExcFileName = fileName;
ExcLineNumber = lineNumber;
if (!PointerIsValid(conditionName)
|| !PointerIsValid(fileName)
|| !PointerIsValid(exceptionP))
{
EPRINTF("TRAP: ExceptionalCondition: bad arguments\n");
ExcAbort(exceptionP,
(ExcDetail) detail,
(ExcData) NULL,
(ExcMessage) NULL);
}
else
{
EPRINTF("TRAP: %s(\"%s:%s\", File: \"%s\", Line: %d)\n",
exceptionP->message, conditionName,
(detail == NULL ? "" : detail),
fileName, lineNumber);
}
#ifdef ABORT_ON_ASSERT
abort();
#endif
1998-06-18 12:35:38 -04:00
#ifdef SLEEP_ON_ASSERT
sleep(1000000);
#endif
/*
* XXX Depending on the Exception and tracing conditions, you will XXX
* want to stop here immediately and maybe dump core. XXX This may be
* especially true for Assert(), etc.
*/
/* TraceDump(); dump the trace stack */
/* XXX FIXME: detail is lost */
ExcRaise(exceptionP, (ExcDetail) 0, (ExcData) NULL, conditionName);
1998-08-31 23:29:17 -04:00
return 0;
}