OSDN Git Service

Update copyright to 2004.
[pg-rex/syncrep.git] / src / backend / utils / error / assert.c
index c100c2e..c0696ea 100644 (file)
@@ -1,64 +1,53 @@
 /*-------------------------------------------------------------------------
  *
- * assert.c--
- *    Assert code.
+ * assert.c
+ *       Assert code.
  *
- * Copyright (c) 1994, Regents of the University of California
+ * Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
  *
  *
  * IDENTIFICATION
- *    $Header: /cvsroot/pgsql/src/backend/utils/error/assert.c,v 1.2 1996/11/11 11:29:15 scrappy Exp $
+ *       $PostgreSQL: pgsql/src/backend/utils/error/assert.c,v 1.28 2004/08/29 04:12:53 momjian Exp $
  *
  * NOTE
- *    This should eventually work with elog(), dlog(), etc.
+ *       This should eventually work with elog()
  *
  *-------------------------------------------------------------------------
  */
-#include <stdio.h>
+#include "postgres.h"
 
-#include "postgres.h"          /* where the declaration goes */
-#include "utils/module.h"
-
-#include "utils/exc.h"
+#include <unistd.h>
 
+/*
+ * ExceptionalCondition - Handles the failure of an Assert()
+ */
 int
-ExceptionalCondition(char* conditionName,
-                    Exception *exceptionP,
-                    char* detail,
-                    char* fileName,
-                    int lineNumber)
+ExceptionalCondition(char *conditionName,
+                                        char *errorType,
+                                        char *fileName,
+                                        int lineNumber)
 {
-    extern char* ExcFileName;  /* XXX */
-    extern Index ExcLineNumber;        /* XXX */
-    
-    ExcFileName = fileName;
-    ExcLineNumber = lineNumber;
-    
-    if (!PointerIsValid(conditionName)
-       || !PointerIsValid(fileName)
-       || !PointerIsValid(exceptionP)) {
-       fprintf(stderr, "ExceptionalCondition: bad arguments\n");
-       
-       ExcAbort(exceptionP, 
-                (ExcDetail)detail,
-                (ExcData)NULL,
-                (ExcMessage)NULL);
-    } else {
-       fprintf(stderr,
-               "%s(\"%s:%s\", File: \"%s\", Line: %d)\n",
-               exceptionP->message, conditionName, detail,
-               fileName, lineNumber);
-    }
-    
-    /*
-     * 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);
-    return(0);
+       if (!PointerIsValid(conditionName)
+               || !PointerIsValid(fileName)
+               || !PointerIsValid(errorType))
+               write_stderr("TRAP: ExceptionalCondition: bad arguments\n");
+       else
+       {
+               write_stderr("TRAP: %s(\"%s\", File: \"%s\", Line: %d)\n",
+                               errorType, conditionName,
+                               fileName, lineNumber);
+       }
+
+#ifdef SLEEP_ON_ASSERT
+       /*
+        *      It would be nice to use pg_usleep() here, but only does 2000 sec
+        *      or 33 minutes, which seems too short.
+        */      
+       sleep(1000000); 
+#endif
+
+       abort();
+
+       return 0;
 }