]> granicus.if.org Git - postgresql/blob - src/backend/utils/error/assert.c
Update copyrights to 2003.
[postgresql] / src / backend / utils / error / assert.c
1 /*-------------------------------------------------------------------------
2  *
3  * assert.c
4  *        Assert code.
5  *
6  * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
7  * Portions Copyright (c) 1994, Regents of the University of California
8  *
9  *
10  * IDENTIFICATION
11  *        $Header: /cvsroot/pgsql/src/backend/utils/error/assert.c,v 1.24 2003/08/04 02:40:06 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                 fprintf(stderr, "TRAP: ExceptionalCondition: bad arguments\n");
35         else
36         {
37                 fprintf(stderr, "TRAP: %s(\"%s\", File: \"%s\", Line: %d)\n",
38                                 errorType, conditionName,
39                                 fileName, lineNumber);
40         }
41
42 #ifdef SLEEP_ON_ASSERT
43         sleep(1000000);
44 #endif
45
46         abort();
47
48         return 0;
49 }