diff options
Diffstat (limited to 'src/backend/utils/error')
| -rw-r--r-- | src/backend/utils/error/Makefile | 4 | ||||
| -rw-r--r-- | src/backend/utils/error/assert.c | 41 | ||||
| -rw-r--r-- | src/backend/utils/error/exc.c | 198 | ||||
| -rw-r--r-- | src/backend/utils/error/excabort.c | 28 | ||||
| -rw-r--r-- | src/backend/utils/error/excid.c | 54 |
5 files changed, 12 insertions, 313 deletions
diff --git a/src/backend/utils/error/Makefile b/src/backend/utils/error/Makefile index 147f03c077..04d7103983 100644 --- a/src/backend/utils/error/Makefile +++ b/src/backend/utils/error/Makefile @@ -4,7 +4,7 @@ # Makefile for utils/error # # IDENTIFICATION -# $Header: /cvsroot/pgsql/src/backend/utils/error/Makefile,v 1.9 2000/08/31 16:10:48 petere Exp $ +# $Header: /cvsroot/pgsql/src/backend/utils/error/Makefile,v 1.10 2002/08/10 20:29:18 momjian Exp $ # #------------------------------------------------------------------------- @@ -12,7 +12,7 @@ subdir = src/backend/utils/error top_builddir = ../../../.. include $(top_builddir)/src/Makefile.global -OBJS = assert.o elog.o exc.o excabort.o excid.o format.o +OBJS = assert.o elog.o all: SUBSYS.o diff --git a/src/backend/utils/error/assert.c b/src/backend/utils/error/assert.c index eee458020d..81fe83c4b4 100644 --- a/src/backend/utils/error/assert.c +++ b/src/backend/utils/error/assert.c @@ -8,65 +8,44 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/error/assert.c,v 1.21 2002/06/20 20:29:39 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/error/assert.c,v 1.22 2002/08/10 20:29:18 momjian Exp $ * * NOTE - * This should eventually work with elog(), dlog(), etc. + * This should eventually work with elog() * *------------------------------------------------------------------------- */ #include "postgres.h" -#include <stdio.h> #include <unistd.h> -#include "utils/exc.h" - +/* + * ExceptionalCondition - Handles the failure of an Assert() + */ int ExceptionalCondition(char *conditionName, - Exception *exceptionP, - char *detail, + char *errorType, char *fileName, int lineNumber) { - ExcFileName = fileName; - ExcLineNumber = lineNumber; - if (!PointerIsValid(conditionName) || !PointerIsValid(fileName) - || !PointerIsValid(exceptionP)) + || !PointerIsValid(errorType)) { fprintf(stderr, "TRAP: ExceptionalCondition: bad arguments\n"); - - ExcAbort(exceptionP, - (ExcDetail) detail, - (ExcData) NULL, - (ExcMessage) NULL); } else { - fprintf(stderr, "TRAP: %s(\"%s:%s\", File: \"%s\", Line: %d)\n", - exceptionP->message, conditionName, - (detail == NULL ? "" : detail), + fprintf(stderr, "TRAP: %s(\"%s\", File: \"%s\", Line: %d)\n", + errorType, conditionName, fileName, lineNumber); } -#ifdef ABORT_ON_ASSERT - abort(); -#endif #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 */ + abort(); - /* XXX FIXME: detail is lost */ - ExcRaise(exceptionP, (ExcDetail) 0, (ExcData) NULL, conditionName); return 0; } diff --git a/src/backend/utils/error/exc.c b/src/backend/utils/error/exc.c deleted file mode 100644 index 3dcf999154..0000000000 --- a/src/backend/utils/error/exc.c +++ /dev/null @@ -1,198 +0,0 @@ -/*------------------------------------------------------------------------- - * - * exc.c - * POSTGRES exception handling code. - * - * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group - * Portions Copyright (c) 1994, Regents of the University of California - * - * - * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/error/Attic/exc.c,v 1.39 2002/06/20 20:29:39 momjian Exp $ - * - * NOTE - * XXX this code needs improvement--check for state violations and - * XXX reset after handling an exception. - * XXX Probably should be merged with elog.c. - * - *------------------------------------------------------------------------- - */ -#include "postgres.h" - -#include <errno.h> - -#include "storage/ipc.h" -#include "utils/exc.h" - -extern int errno; - - -static void ExcUnCaught(Exception *excP, ExcDetail detail, ExcData data, - ExcMessage message); -static void ExcPrint(Exception *excP, ExcDetail detail, ExcData data, - ExcMessage message); - -/* - * Global Variables - */ -static bool ExceptionHandlingEnabled = false; - -char *ExcFileName = NULL; -Index ExcLineNumber = 0; - -ExcFrame *ExcCurFrameP = NULL; - -static ExcProc *ExcUnCaughtP = NULL; - -/* - * Exported Functions - */ - -/* - * EnableExceptionHandling - * Enables/disables the exception handling system. - * - * Note: - * This must be called before any exceptions occur. I.e., call this first! - * This routine will not return if an error is detected. - * This does not follow the usual Enable... protocol. - * This should be merged more closely with the error logging and tracing - * packages. - * - * Exceptions: - * none - */ -/* - * Excection handling should be supported by the language, thus there should - * be no need to explicitly enable exception processing. - * - * This function should probably not be called, ever. Currently it does - * almost nothing. If there is a need for this intialization and checking. - * then this function should be converted to the new-style Enable code and - * called by all the other module Enable functions. - */ -void -EnableExceptionHandling(bool on) -{ - if (on == ExceptionHandlingEnabled) - { - /* XXX add logging of failed state */ - proc_exit(255); - /* ExitPostgres(FatalExitStatus); */ - } - - if (on) - { /* initialize */ - ; - } - else - { /* cleanup */ - ExcFileName = NULL; - ExcLineNumber = 0; - ExcCurFrameP = NULL; - ExcUnCaughtP = NULL; - } - - ExceptionHandlingEnabled = on; -} - -static void -ExcPrint(Exception *excP, - ExcDetail detail, - ExcData data, - ExcMessage message) -{ - /* this buffer is only used if errno has a bogus value: */ - char errorstr_buf[32]; - const char *errorstr; - -#ifdef lint - data = data; -#endif - - /* Save error str before calling any function that might change errno */ - errorstr = strerror(errno); - - /* - * Some strerror()s return an empty string for out-of-range errno. - * This is ANSI C spec compliant, but not exactly useful. - */ - if (errorstr == NULL || *errorstr == '\0') - { - sprintf(errorstr_buf, "error %d", errno); - errorstr = errorstr_buf; - } - - fflush(stdout); /* In case stderr is buffered */ - - if (message != NULL) - fprintf(stderr, "%s", message); - else if (excP->message != NULL) - fprintf(stderr, "%s", excP->message); - else - fprintf(stderr, "UNNAMED EXCEPTION %p", excP); - - fprintf(stderr, " (%ld) [%s]\n", detail, errorstr); - - fflush(stderr); -} - -#ifdef NOT_USED -ExcProc * -ExcGetUnCaught(void) -{ - return ExcUnCaughtP; -} -#endif - -#ifdef NOT_USED -ExcProc * -ExcSetUnCaught(ExcProc *newP) -{ - ExcProc *oldP = ExcUnCaughtP; - - ExcUnCaughtP = newP; - - return oldP; -} -#endif - -static void -ExcUnCaught(Exception *excP, - ExcDetail detail, - ExcData data, - ExcMessage message) -{ - ExcPrint(excP, detail, data, message); - - ExcAbort(excP, detail, data, message); -} - -void -ExcRaise(Exception *excP, - ExcDetail detail, - ExcData data, - ExcMessage message) -{ - ExcFrame *efp; - - efp = ExcCurFrameP; - if (efp == NULL) - { - if (ExcUnCaughtP != NULL) - (*ExcUnCaughtP) (excP, detail, data, message); - - ExcUnCaught(excP, detail, data, message); - } - else - { - efp->id = excP; - efp->detail = detail; - efp->data = data; - efp->message = message; - - ExcCurFrameP = efp->link; - - siglongjmp(efp->context, 1); - } -} diff --git a/src/backend/utils/error/excabort.c b/src/backend/utils/error/excabort.c deleted file mode 100644 index 00fb075b26..0000000000 --- a/src/backend/utils/error/excabort.c +++ /dev/null @@ -1,28 +0,0 @@ -/*------------------------------------------------------------------------- - * - * excabort.c - * Default exception abort code. - * - * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group - * Portions Copyright (c) 1994, Regents of the University of California - * - * - * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/error/Attic/excabort.c,v 1.10 2002/06/20 20:29:39 momjian Exp $ - * - *------------------------------------------------------------------------- - */ - -#include "postgres.h" - -#include "utils/exc.h" - -void -ExcAbort(const Exception *excP, - ExcDetail detail, - ExcData data, - ExcMessage message) -{ - /* dump core */ - abort(); -} diff --git a/src/backend/utils/error/excid.c b/src/backend/utils/error/excid.c deleted file mode 100644 index b32080a5fd..0000000000 --- a/src/backend/utils/error/excid.c +++ /dev/null @@ -1,54 +0,0 @@ -/*------------------------------------------------------------------------- - * - * excid.c - * POSTGRES known exception identifier code. - * - * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group - * Portions Copyright (c) 1994, Regents of the University of California - * - * - * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/error/Attic/excid.c,v 1.11 2002/06/20 20:29:39 momjian Exp $ - * - *------------------------------------------------------------------------- - */ - -#include "postgres.h" - -/***************************************************************************** - * Generic Recoverable Exceptions * - *****************************************************************************/ - - -/* - * FailedAssertion - * Indicates an Assert(...) failed. - */ -Exception FailedAssertion = {"Failed Assertion"}; - -/* - * BadState - * Indicates a function call request is inconsistent with module state. - */ -Exception BadState = {"Bad State for Function Call"}; - -/* - * BadArg - * Indicates a function call argument or arguments is out-of-bounds. - */ -Exception BadArg = {"Bad Argument to Function Call"}; - -/***************************************************************************** - * Specific Recoverable Exceptions * - *****************************************************************************/ - -/* - * Unimplemented - * Indicates a function call request requires unimplemented code. - */ -Exception Unimplemented = {"Unimplemented Functionality"}; - -Exception CatalogFailure = {"Catalog failure"}; /* XXX inconsistent */ -Exception InternalError = {"Internal Error"}; /* XXX inconsistent */ -Exception SemanticError = {"Semantic Error"}; /* XXX inconsistent */ -Exception SystemError = {"System Error"}; /* XXX inconsistent */ |
