1/*-------------------------------------------------------------------------
2 *
3 * assert.c
4 * Assert code.
5 *
6 * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
8 *
9 *
10 * IDENTIFICATION
11 * src/backend/utils/error/assert.c
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 */
25void
26ExceptionalCondition(const char *conditionName,
27 const char *errorType,
28 const 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 /* Usually this shouldn't be needed, but make sure the msg went out */
43 fflush(stderr);
44
45#ifdef SLEEP_ON_ASSERT
46
47 /*
48 * It would be nice to use pg_usleep() here, but only does 2000 sec or 33
49 * minutes, which seems too short.
50 */
51 sleep(1000000);
52#endif
53
54 abort();
55}
56