]> granicus.if.org Git - postgresql/blob - src/backend/utils/error/assert.c
Adjust comments previously moved to column 1 by pgident.
[postgresql] / src / backend / utils / error / assert.c
1 /*-------------------------------------------------------------------------
2  *
3  * assert.c
4  *        Assert code.
5  *
6  * Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
7  * Portions Copyright (c) 1994, Regents of the University of California
8  *
9  *
10  * IDENTIFICATION
11  *        $PostgreSQL: pgsql/src/backend/utils/error/assert.c,v 1.29 2004/08/29 05:06:50 momjian Exp $
12  *
13  * NOTE
14  *        This should eventually work with elog()
15  *
16  *-------------------------------------------------------------------------
17  */
18 #include "postgres.h"
19
20 #include <unistd.h>
21
22 /*
23  * ExceptionalCondition - Handles the failure of an Assert()
24  */
25 int
26 ExceptionalCondition(char *conditionName,
27                                          char *errorType,
28                                          char *fileName,
29                                          int lineNumber)
30 {
31         if (!PointerIsValid(conditionName)
32                 || !PointerIsValid(fileName)
33                 || !PointerIsValid(errorType))
34                 write_stderr("TRAP: ExceptionalCondition: bad arguments\n");
35         else
36         {
37                 write_stderr("TRAP: %s(\"%s\", File: \"%s\", Line: %d)\n",
38                                          errorType, conditionName,
39                                          fileName, lineNumber);
40         }
41
42 #ifdef SLEEP_ON_ASSERT
43
44         /*
45          * It would be nice to use pg_usleep() here, but only does 2000 sec or
46          * 33 minutes, which seems too short.
47          */
48         sleep(1000000);
49 #endif
50
51         abort();
52
53         return 0;
54 }