~vcs-imports/mammoth-replicator/trunk

« back to all changes in this revision

Viewing changes to src/backend/utils/error/assert.c

  • Committer: alvherre
  • Date: 2005-12-16 21:24:52 UTC
  • Revision ID: svn-v4:db760fc0-0f08-0410-9d63-cc6633f64896:trunk:1
Initial import of the REL8_0_3 sources from the Pgsql CVS repository.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*-------------------------------------------------------------------------
 
2
 *
 
3
 * assert.c
 
4
 *        Assert code.
 
5
 *
 
6
 * Portions Copyright (c) 1996-2005, 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.30 2004-12-31 22:01:27 pgsql 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
}