mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +03:00
Massive commit to run PGINDENT on all *.c and *.h files.
This commit is contained in:
@@ -1,67 +1,71 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* assert.c--
|
||||
* Assert code.
|
||||
* Assert code.
|
||||
*
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/error/assert.c,v 1.4 1997/04/17 20:38:26 scrappy Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/error/assert.c,v 1.5 1997/09/07 04:53:11 momjian Exp $
|
||||
*
|
||||
* NOTE
|
||||
* This should eventually work with elog(), dlog(), etc.
|
||||
* This should eventually work with elog(), dlog(), etc.
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
#include "postgres.h" /* where the declaration goes */
|
||||
#include "postgres.h" /* where the declaration goes */
|
||||
#include "utils/module.h"
|
||||
|
||||
#include "utils/exc.h"
|
||||
|
||||
int
|
||||
ExceptionalCondition(char* conditionName,
|
||||
Exception *exceptionP,
|
||||
char* detail,
|
||||
char* fileName,
|
||||
int lineNumber)
|
||||
ExceptionalCondition(char *conditionName,
|
||||
Exception * exceptionP,
|
||||
char *detail,
|
||||
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",
|
||||
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 == NULL ? "" : detail,
|
||||
fileName, lineNumber);
|
||||
}
|
||||
fileName, lineNumber);
|
||||
}
|
||||
|
||||
#ifdef ABORT_ON_ASSERT
|
||||
abort();
|
||||
abort();
|
||||
#endif
|
||||
/*
|
||||
* 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);
|
||||
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* elog.c--
|
||||
* error logger
|
||||
* error logger
|
||||
*
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.17 1997/08/12 22:54:44 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.18 1997/09/07 04:53:15 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -17,7 +17,7 @@
|
||||
#include <fcntl.h>
|
||||
#ifndef O_RDONLY
|
||||
#include <sys/file.h>
|
||||
#endif /* O_RDONLY */
|
||||
#endif /* O_RDONLY */
|
||||
#include <sys/types.h>
|
||||
#include <stdarg.h>
|
||||
#include <errno.h>
|
||||
@@ -29,204 +29,236 @@
|
||||
#include "libpq/libpq.h"
|
||||
#include "storage/proc.h"
|
||||
|
||||
static int Debugfile = -1;
|
||||
static int Err_file = -1;
|
||||
static int ElogDebugIndentLevel = 0;
|
||||
static int Debugfile = -1;
|
||||
static int Err_file = -1;
|
||||
static int ElogDebugIndentLevel = 0;
|
||||
|
||||
extern char OutputFileName[];
|
||||
extern char OutputFileName[];
|
||||
|
||||
/*
|
||||
* elog --
|
||||
* Old error logging function.
|
||||
* Old error logging function.
|
||||
*/
|
||||
void
|
||||
elog(int lev, const char *fmt, ... )
|
||||
elog(int lev, const char *fmt,...)
|
||||
{
|
||||
va_list ap;
|
||||
char buf[ELOG_MAXLEN], line[ELOG_MAXLEN];
|
||||
register char *bp;
|
||||
register const char *cp;
|
||||
extern int errno, sys_nerr;
|
||||
va_list ap;
|
||||
char buf[ELOG_MAXLEN],
|
||||
line[ELOG_MAXLEN];
|
||||
register char *bp;
|
||||
register const char *cp;
|
||||
extern int errno,
|
||||
sys_nerr;
|
||||
|
||||
#ifndef PG_STANDALONE
|
||||
extern FILE *Pfout;
|
||||
#endif /* !PG_STANDALONE */
|
||||
extern FILE *Pfout;
|
||||
|
||||
#endif /* !PG_STANDALONE */
|
||||
#ifdef ELOG_TIMESTAMPS
|
||||
time_t tim;
|
||||
time_t tim;
|
||||
|
||||
#endif
|
||||
int len;
|
||||
int i = 0;
|
||||
|
||||
va_start(ap, fmt);
|
||||
if (lev == DEBUG && Debugfile < 0) {
|
||||
return;
|
||||
}
|
||||
switch (lev) {
|
||||
case NOIND:
|
||||
i = ElogDebugIndentLevel-1;
|
||||
if (i < 0) i = 0;
|
||||
if (i > 30) i = i%30;
|
||||
cp = "DEBUG:";
|
||||
break;
|
||||
case DEBUG:
|
||||
i = ElogDebugIndentLevel;
|
||||
if (i < 0) i = 0;
|
||||
if (i > 30) i = i%30;
|
||||
cp = "DEBUG:";
|
||||
break;
|
||||
case NOTICE:
|
||||
cp = "NOTICE:";
|
||||
break;
|
||||
case WARN:
|
||||
cp = "WARN:";
|
||||
break;
|
||||
default:
|
||||
sprintf(line, "FATAL %d:", lev);
|
||||
cp = line;
|
||||
}
|
||||
#ifdef ELOG_TIMESTAMPS
|
||||
time(&tim);
|
||||
strcat(strcpy(buf, cp), ctime(&tim)+4);
|
||||
bp = buf+strlen(buf)-6;
|
||||
*bp++ = ':';
|
||||
#else
|
||||
strcpy(buf,cp);
|
||||
bp = buf+strlen(buf);
|
||||
#endif
|
||||
while (i-- >0) *bp++ = ' ';
|
||||
for (cp = fmt; *cp; cp++)
|
||||
if (*cp == '%' && *(cp+1) == 'm') {
|
||||
if (errno < sys_nerr && errno >= 0)
|
||||
strcpy(bp, strerror(errno));
|
||||
else
|
||||
sprintf(bp, "error %d", errno);
|
||||
bp += strlen(bp);
|
||||
cp++;
|
||||
} else
|
||||
*bp++ = *cp;
|
||||
*bp = '\0';
|
||||
vsprintf(line, buf, ap);
|
||||
va_end(ap);
|
||||
len = strlen(strcat(line, "\n"));
|
||||
if (Debugfile > -1)
|
||||
write(Debugfile, line, len);
|
||||
if (lev == DEBUG || lev == NOIND)
|
||||
return;
|
||||
|
||||
/*
|
||||
* If there's an error log file other than our channel to the
|
||||
* front-end program, write to it first. This is important
|
||||
* because there's a bug in the socket code on ultrix. If the
|
||||
* front end has gone away (so the channel to it has been closed
|
||||
* at the other end), then writing here can cause this backend
|
||||
* to exit without warning -- that is, write() does an exit().
|
||||
* In this case, our only hope of finding out what's going on
|
||||
* is if Err_file was set to some disk log. This is a major pain.
|
||||
*/
|
||||
|
||||
if (Err_file > -1 && Debugfile != Err_file) {
|
||||
if (write(Err_file, line, len) < 0) {
|
||||
write(open("/dev/console", O_WRONLY, 0666), line, len);
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
exitpg(lev);
|
||||
int len;
|
||||
int i = 0;
|
||||
|
||||
va_start(ap, fmt);
|
||||
if (lev == DEBUG && Debugfile < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
fsync(Err_file);
|
||||
}
|
||||
|
||||
switch (lev)
|
||||
{
|
||||
case NOIND:
|
||||
i = ElogDebugIndentLevel - 1;
|
||||
if (i < 0)
|
||||
i = 0;
|
||||
if (i > 30)
|
||||
i = i % 30;
|
||||
cp = "DEBUG:";
|
||||
break;
|
||||
case DEBUG:
|
||||
i = ElogDebugIndentLevel;
|
||||
if (i < 0)
|
||||
i = 0;
|
||||
if (i > 30)
|
||||
i = i % 30;
|
||||
cp = "DEBUG:";
|
||||
break;
|
||||
case NOTICE:
|
||||
cp = "NOTICE:";
|
||||
break;
|
||||
case WARN:
|
||||
cp = "WARN:";
|
||||
break;
|
||||
default:
|
||||
sprintf(line, "FATAL %d:", lev);
|
||||
cp = line;
|
||||
}
|
||||
#ifdef ELOG_TIMESTAMPS
|
||||
time(&tim);
|
||||
strcat(strcpy(buf, cp), ctime(&tim) + 4);
|
||||
bp = buf + strlen(buf) - 6;
|
||||
*bp++ = ':';
|
||||
#else
|
||||
strcpy(buf, cp);
|
||||
bp = buf + strlen(buf);
|
||||
#endif
|
||||
while (i-- > 0)
|
||||
*bp++ = ' ';
|
||||
for (cp = fmt; *cp; cp++)
|
||||
if (*cp == '%' && *(cp + 1) == 'm')
|
||||
{
|
||||
if (errno < sys_nerr && errno >= 0)
|
||||
strcpy(bp, strerror(errno));
|
||||
else
|
||||
sprintf(bp, "error %d", errno);
|
||||
bp += strlen(bp);
|
||||
cp++;
|
||||
}
|
||||
else
|
||||
*bp++ = *cp;
|
||||
*bp = '\0';
|
||||
vsprintf(line, buf, ap);
|
||||
va_end(ap);
|
||||
len = strlen(strcat(line, "\n"));
|
||||
if (Debugfile > -1)
|
||||
write(Debugfile, line, len);
|
||||
if (lev == DEBUG || lev == NOIND)
|
||||
return;
|
||||
|
||||
/*
|
||||
* If there's an error log file other than our channel to the
|
||||
* front-end program, write to it first. This is important because
|
||||
* there's a bug in the socket code on ultrix. If the front end has
|
||||
* gone away (so the channel to it has been closed at the other end),
|
||||
* then writing here can cause this backend to exit without warning --
|
||||
* that is, write() does an exit(). In this case, our only hope of
|
||||
* finding out what's going on is if Err_file was set to some disk
|
||||
* log. This is a major pain.
|
||||
*/
|
||||
|
||||
if (Err_file > -1 && Debugfile != Err_file)
|
||||
{
|
||||
if (write(Err_file, line, len) < 0)
|
||||
{
|
||||
write(open("/dev/console", O_WRONLY, 0666), line, len);
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
exitpg(lev);
|
||||
}
|
||||
fsync(Err_file);
|
||||
}
|
||||
|
||||
#ifndef PG_STANDALONE
|
||||
/* Send IPC message to the front-end program */
|
||||
if (Pfout != NULL && lev > DEBUG) {
|
||||
/* notices are not exactly errors, handle it differently */
|
||||
if (lev == NOTICE)
|
||||
pq_putnchar("N", 1);
|
||||
else
|
||||
pq_putnchar("E", 1);
|
||||
/* pq_putint(-101, 4);*/ /* should be query id */
|
||||
pq_putstr(line);
|
||||
pq_flush();
|
||||
}
|
||||
#endif /* !PG_STANDALONE */
|
||||
|
||||
if (lev == WARN) {
|
||||
extern int InWarn;
|
||||
ProcReleaseSpins(NULL); /* get rid of spinlocks we hold */
|
||||
if (!InWarn) {
|
||||
kill(getpid(), 1); /* abort to traffic cop */
|
||||
pause();
|
||||
}
|
||||
/*
|
||||
* The pause(3) is just to avoid race conditions where the
|
||||
* thread of control on an MP system gets past here (i.e.,
|
||||
* the signal is not received instantaneously).
|
||||
*/
|
||||
}
|
||||
|
||||
if (lev == FATAL) {
|
||||
/*
|
||||
* Assume that if we have detected the failure we can
|
||||
* exit with a normal exit status. This will prevent
|
||||
* the postmaster from cleaning up when it's not needed.
|
||||
*/
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
ProcReleaseSpins(NULL); /* get rid of spinlocks we hold */
|
||||
ProcReleaseLocks(); /* get rid of real locks we hold */
|
||||
exitpg(0);
|
||||
}
|
||||
|
||||
if (lev > FATAL) {
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
exitpg(lev);
|
||||
}
|
||||
/* Send IPC message to the front-end program */
|
||||
if (Pfout != NULL && lev > DEBUG)
|
||||
{
|
||||
/* notices are not exactly errors, handle it differently */
|
||||
if (lev == NOTICE)
|
||||
pq_putnchar("N", 1);
|
||||
else
|
||||
pq_putnchar("E", 1);
|
||||
/* pq_putint(-101, 4); *//* should be query id */
|
||||
pq_putstr(line);
|
||||
pq_flush();
|
||||
}
|
||||
#endif /* !PG_STANDALONE */
|
||||
|
||||
if (lev == WARN)
|
||||
{
|
||||
extern int InWarn;
|
||||
|
||||
ProcReleaseSpins(NULL); /* get rid of spinlocks we hold */
|
||||
if (!InWarn)
|
||||
{
|
||||
kill(getpid(), 1); /* abort to traffic cop */
|
||||
pause();
|
||||
}
|
||||
|
||||
/*
|
||||
* The pause(3) is just to avoid race conditions where the thread
|
||||
* of control on an MP system gets past here (i.e., the signal is
|
||||
* not received instantaneously).
|
||||
*/
|
||||
}
|
||||
|
||||
if (lev == FATAL)
|
||||
{
|
||||
|
||||
/*
|
||||
* Assume that if we have detected the failure we can exit with a
|
||||
* normal exit status. This will prevent the postmaster from
|
||||
* cleaning up when it's not needed.
|
||||
*/
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
ProcReleaseSpins(NULL); /* get rid of spinlocks we hold */
|
||||
ProcReleaseLocks(); /* get rid of real locks we hold */
|
||||
exitpg(0);
|
||||
}
|
||||
|
||||
if (lev > FATAL)
|
||||
{
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
exitpg(lev);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef PG_STANDALONE
|
||||
int
|
||||
DebugFileOpen(void)
|
||||
{
|
||||
int fd, istty;
|
||||
|
||||
Err_file = Debugfile = -1;
|
||||
ElogDebugIndentLevel = 0;
|
||||
|
||||
if (OutputFileName[0]) {
|
||||
OutputFileName[MAXPGPATH-1] = '\0';
|
||||
if ((fd = open(OutputFileName, O_CREAT|O_APPEND|O_WRONLY,
|
||||
0666)) < 0)
|
||||
elog(FATAL, "DebugFileOpen: open of %s: %m",
|
||||
OutputFileName);
|
||||
istty = isatty(fd);
|
||||
close(fd);
|
||||
/* If the file is a tty and we're running under the
|
||||
* postmaster, try to send stdout there as well (if it
|
||||
* isn't a tty then stderr will block out stdout, so we
|
||||
* may as well let stdout go wherever it was going before).
|
||||
int fd,
|
||||
istty;
|
||||
|
||||
Err_file = Debugfile = -1;
|
||||
ElogDebugIndentLevel = 0;
|
||||
|
||||
if (OutputFileName[0])
|
||||
{
|
||||
OutputFileName[MAXPGPATH - 1] = '\0';
|
||||
if ((fd = open(OutputFileName, O_CREAT | O_APPEND | O_WRONLY,
|
||||
0666)) < 0)
|
||||
elog(FATAL, "DebugFileOpen: open of %s: %m",
|
||||
OutputFileName);
|
||||
istty = isatty(fd);
|
||||
close(fd);
|
||||
|
||||
/*
|
||||
* If the file is a tty and we're running under the postmaster,
|
||||
* try to send stdout there as well (if it isn't a tty then stderr
|
||||
* will block out stdout, so we may as well let stdout go wherever
|
||||
* it was going before).
|
||||
*/
|
||||
if (istty &&
|
||||
IsUnderPostmaster &&
|
||||
!freopen(OutputFileName, "a", stdout))
|
||||
elog(FATAL, "DebugFileOpen: %s reopen as stdout: %m",
|
||||
OutputFileName);
|
||||
if (!freopen(OutputFileName, "a", stderr))
|
||||
elog(FATAL, "DebugFileOpen: %s reopen as stderr: %m",
|
||||
OutputFileName);
|
||||
Err_file = Debugfile = fileno(stderr);
|
||||
return (Debugfile);
|
||||
}
|
||||
|
||||
/*
|
||||
* If no filename was specified, send debugging output to stderr. If
|
||||
* stderr has been hosed, try to open a file.
|
||||
*/
|
||||
if (istty &&
|
||||
IsUnderPostmaster &&
|
||||
!freopen(OutputFileName, "a", stdout))
|
||||
elog(FATAL, "DebugFileOpen: %s reopen as stdout: %m",
|
||||
OutputFileName);
|
||||
if (!freopen(OutputFileName, "a", stderr))
|
||||
elog(FATAL, "DebugFileOpen: %s reopen as stderr: %m",
|
||||
OutputFileName);
|
||||
Err_file = Debugfile = fileno(stderr);
|
||||
return(Debugfile);
|
||||
}
|
||||
/* If no filename was specified, send debugging output to stderr.
|
||||
* If stderr has been hosed, try to open a file.
|
||||
*/
|
||||
fd = fileno(stderr);
|
||||
if (fcntl(fd, F_GETFD, 0) < 0) {
|
||||
sprintf(OutputFileName, "%s/pg.errors.%d",
|
||||
DataDir, (int)getpid());
|
||||
fd = open(OutputFileName, O_CREAT|O_APPEND|O_WRONLY, 0666);
|
||||
}
|
||||
if (fd < 0)
|
||||
elog(FATAL, "DebugFileOpen: could not open debugging file");
|
||||
|
||||
Err_file = Debugfile = fd;
|
||||
return(Debugfile);
|
||||
fd = fileno(stderr);
|
||||
if (fcntl(fd, F_GETFD, 0) < 0)
|
||||
{
|
||||
sprintf(OutputFileName, "%s/pg.errors.%d",
|
||||
DataDir, (int) getpid());
|
||||
fd = open(OutputFileName, O_CREAT | O_APPEND | O_WRONLY, 0666);
|
||||
}
|
||||
if (fd < 0)
|
||||
elog(FATAL, "DebugFileOpen: could not open debugging file");
|
||||
|
||||
Err_file = Debugfile = fd;
|
||||
return (Debugfile);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* exc.c--
|
||||
* POSTGRES exception handling code.
|
||||
* POSTGRES exception handling code.
|
||||
*
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/error/Attic/exc.c,v 1.15 1997/08/19 21:35:17 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/error/Attic/exc.c,v 1.16 1997/09/07 04:53:16 momjian Exp $
|
||||
*
|
||||
* NOTE
|
||||
* XXX this code needs improvement--check for state violations and
|
||||
* XXX reset after handling an exception.
|
||||
* XXX this code needs improvement--check for state violations and
|
||||
* XXX reset after handling an exception.
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#include <stdio.h> /* XXX use own I/O routines */
|
||||
#include <stdio.h> /* XXX use own I/O routines */
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -24,24 +24,26 @@
|
||||
#include "utils/exc.h"
|
||||
#include "storage/ipc.h"
|
||||
|
||||
static void ExcUnCaught(Exception *excP, ExcDetail detail, ExcData data,
|
||||
static void
|
||||
ExcUnCaught(Exception * excP, ExcDetail detail, ExcData data,
|
||||
ExcMessage message);
|
||||
static void ExcPrint(Exception *excP, ExcDetail detail, ExcData data,
|
||||
ExcMessage message);
|
||||
static void
|
||||
ExcPrint(Exception * excP, ExcDetail detail, ExcData data,
|
||||
ExcMessage message);
|
||||
|
||||
/*
|
||||
* Global Variables
|
||||
*/
|
||||
static bool ExceptionHandlingEnabled = false;
|
||||
static bool ExceptionHandlingEnabled = false;
|
||||
|
||||
char* ExcFileName = NULL;
|
||||
char *ExcFileName = NULL;
|
||||
Index ExcLineNumber = 0;
|
||||
|
||||
ExcFrame *ExcCurFrameP = NULL;
|
||||
ExcFrame *ExcCurFrameP = NULL;
|
||||
|
||||
static ExcProc *ExcUnCaughtP = NULL;
|
||||
static ExcProc *ExcUnCaughtP = NULL;
|
||||
|
||||
extern char* ProgramName;
|
||||
extern char *ProgramName;
|
||||
|
||||
/*
|
||||
* Exported Functions
|
||||
@@ -49,148 +51,157 @@ extern char* ProgramName;
|
||||
|
||||
/*
|
||||
* EnableExceptionHandling --
|
||||
* Enables/disables the exception handling system.
|
||||
* Enables/disables the exception handling system.
|
||||
*
|
||||
* Note:
|
||||
* This must be called before any exceptions occur. I.e., call this first!
|
||||
* This routine will not return if an error is detected.
|
||||
* This does not follow the usual Enable... protocol.
|
||||
* This should be merged more closely with the error logging and tracing
|
||||
* packages.
|
||||
* This must be called before any exceptions occur. I.e., call this first!
|
||||
* This routine will not return if an error is detected.
|
||||
* This does not follow the usual Enable... protocol.
|
||||
* This should be merged more closely with the error logging and tracing
|
||||
* packages.
|
||||
*
|
||||
* Exceptions:
|
||||
* none
|
||||
* none
|
||||
*/
|
||||
/*
|
||||
* Excection handling should be supported by the language, thus there should
|
||||
* be no need to explicitly enable exception processing.
|
||||
*
|
||||
* This function should probably not be called, ever. Currently it does
|
||||
* almost nothing. If there is a need for this intialization and checking.
|
||||
* almost nothing. If there is a need for this intialization and checking.
|
||||
* then this function should be converted to the new-style Enable code and
|
||||
* called by all the other module Enable functions.
|
||||
*/
|
||||
void
|
||||
EnableExceptionHandling(bool on)
|
||||
{
|
||||
if (on == ExceptionHandlingEnabled) {
|
||||
/* XXX add logging of failed state */
|
||||
exitpg(255);
|
||||
/* ExitPostgres(FatalExitStatus); */
|
||||
}
|
||||
|
||||
if (on) { /* initialize */
|
||||
;
|
||||
} else { /* cleanup */
|
||||
ExcFileName = NULL;
|
||||
ExcLineNumber = 0;
|
||||
ExcCurFrameP = NULL;
|
||||
ExcUnCaughtP = NULL;
|
||||
}
|
||||
|
||||
ExceptionHandlingEnabled = on;
|
||||
if (on == ExceptionHandlingEnabled)
|
||||
{
|
||||
/* XXX add logging of failed state */
|
||||
exitpg(255);
|
||||
/* ExitPostgres(FatalExitStatus); */
|
||||
}
|
||||
|
||||
if (on)
|
||||
{ /* initialize */
|
||||
;
|
||||
}
|
||||
else
|
||||
{ /* cleanup */
|
||||
ExcFileName = NULL;
|
||||
ExcLineNumber = 0;
|
||||
ExcCurFrameP = NULL;
|
||||
ExcUnCaughtP = NULL;
|
||||
}
|
||||
|
||||
ExceptionHandlingEnabled = on;
|
||||
}
|
||||
|
||||
static void
|
||||
ExcPrint(Exception *excP,
|
||||
ExcDetail detail,
|
||||
ExcData data,
|
||||
ExcMessage message)
|
||||
ExcPrint(Exception * excP,
|
||||
ExcDetail detail,
|
||||
ExcData data,
|
||||
ExcMessage message)
|
||||
{
|
||||
extern int errno;
|
||||
extern int sys_nerr;
|
||||
|
||||
extern int errno;
|
||||
extern int sys_nerr;
|
||||
|
||||
#ifdef lint
|
||||
data = data;
|
||||
data = data;
|
||||
#endif
|
||||
|
||||
fflush(stdout); /* In case stderr is buffered */
|
||||
|
||||
#if 0
|
||||
if (ProgramName != NULL && *ProgramName != '\0')
|
||||
fprintf(stderr, "%s: ", ProgramName);
|
||||
|
||||
fflush(stdout); /* In case stderr is buffered */
|
||||
|
||||
#if 0
|
||||
if (ProgramName != NULL && *ProgramName != '\0')
|
||||
fprintf(stderr, "%s: ", ProgramName);
|
||||
#endif
|
||||
|
||||
if (message != NULL)
|
||||
fprintf(stderr, "%s", message);
|
||||
else if (excP->message != NULL)
|
||||
fprintf(stderr, "%s", excP->message);
|
||||
else
|
||||
|
||||
if (message != NULL)
|
||||
fprintf(stderr, "%s", message);
|
||||
else if (excP->message != NULL)
|
||||
fprintf(stderr, "%s", excP->message);
|
||||
else
|
||||
#ifdef lint
|
||||
fprintf(stderr, "UNNAMED EXCEPTION 0x%lx", excP);
|
||||
fprintf(stderr, "UNNAMED EXCEPTION 0x%lx", excP);
|
||||
#else
|
||||
fprintf(stderr, "UNNAMED EXCEPTION 0x%lx", (long)excP);
|
||||
fprintf(stderr, "UNNAMED EXCEPTION 0x%lx", (long) excP);
|
||||
#endif
|
||||
|
||||
fprintf(stderr, " (%ld)", detail);
|
||||
|
||||
if (errno > 0 && errno < sys_nerr)
|
||||
fprintf(stderr, " [%s]", strerror(errno));
|
||||
else if (errno != 0)
|
||||
fprintf(stderr, " [Error %d]", errno);
|
||||
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
fflush(stderr);
|
||||
|
||||
fprintf(stderr, " (%ld)", detail);
|
||||
|
||||
if (errno > 0 && errno < sys_nerr)
|
||||
fprintf(stderr, " [%s]", strerror(errno));
|
||||
else if (errno != 0)
|
||||
fprintf(stderr, " [Error %d]", errno);
|
||||
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
fflush(stderr);
|
||||
}
|
||||
|
||||
#ifdef NOT_USED
|
||||
ExcProc *
|
||||
ExcProc *
|
||||
ExcGetUnCaught(void)
|
||||
{
|
||||
return (ExcUnCaughtP);
|
||||
return (ExcUnCaughtP);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef NOT_USED
|
||||
ExcProc *
|
||||
ExcSetUnCaught(ExcProc *newP)
|
||||
ExcProc *
|
||||
ExcSetUnCaught(ExcProc * newP)
|
||||
{
|
||||
ExcProc *oldP = ExcUnCaughtP;
|
||||
|
||||
ExcUnCaughtP = newP;
|
||||
|
||||
return (oldP);
|
||||
ExcProc *oldP = ExcUnCaughtP;
|
||||
|
||||
ExcUnCaughtP = newP;
|
||||
|
||||
return (oldP);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static void
|
||||
ExcUnCaught(Exception *excP,
|
||||
ExcDetail detail,
|
||||
ExcData data,
|
||||
ExcMessage message)
|
||||
ExcUnCaught(Exception * excP,
|
||||
ExcDetail detail,
|
||||
ExcData data,
|
||||
ExcMessage message)
|
||||
{
|
||||
ExcPrint(excP, detail, data, message);
|
||||
|
||||
ExcAbort(excP, detail, data, message);
|
||||
ExcPrint(excP, detail, data, message);
|
||||
|
||||
ExcAbort(excP, detail, data, message);
|
||||
}
|
||||
|
||||
void
|
||||
ExcRaise(Exception *excP,
|
||||
ExcDetail detail,
|
||||
ExcData data,
|
||||
ExcMessage message)
|
||||
ExcRaise(Exception * excP,
|
||||
ExcDetail detail,
|
||||
ExcData data,
|
||||
ExcMessage message)
|
||||
{
|
||||
register ExcFrame *efp;
|
||||
|
||||
efp = ExcCurFrameP;
|
||||
if (efp == NULL) {
|
||||
if (ExcUnCaughtP != NULL)
|
||||
(*ExcUnCaughtP)(excP, detail, data, message);
|
||||
|
||||
ExcUnCaught(excP, detail, data, message);
|
||||
} else {
|
||||
efp->id = excP;
|
||||
efp->detail = detail;
|
||||
efp->data = data;
|
||||
efp->message = message;
|
||||
|
||||
ExcCurFrameP = efp->link;
|
||||
|
||||
register ExcFrame *efp;
|
||||
|
||||
efp = ExcCurFrameP;
|
||||
if (efp == NULL)
|
||||
{
|
||||
if (ExcUnCaughtP != NULL)
|
||||
(*ExcUnCaughtP) (excP, detail, data, message);
|
||||
|
||||
ExcUnCaught(excP, detail, data, message);
|
||||
}
|
||||
else
|
||||
{
|
||||
efp->id = excP;
|
||||
efp->detail = detail;
|
||||
efp->data = data;
|
||||
efp->message = message;
|
||||
|
||||
ExcCurFrameP = efp->link;
|
||||
|
||||
#if defined (JMP_BUF)
|
||||
longjmp(efp->context, 1);
|
||||
longjmp(efp->context, 1);
|
||||
#else
|
||||
siglongjmp(efp->context, 1);
|
||||
siglongjmp(efp->context, 1);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,31 +1,31 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* excabort.c--
|
||||
* Default exception abort code.
|
||||
* Default exception abort code.
|
||||
*
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/error/Attic/excabort.c,v 1.2 1996/11/03 06:53:32 scrappy Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/error/Attic/excabort.c,v 1.3 1997/09/07 04:53:18 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "postgres.h"
|
||||
|
||||
#include "utils/exc.h" /* where function declarations go */
|
||||
#include "utils/exc.h" /* where function declarations go */
|
||||
|
||||
void
|
||||
ExcAbort(const Exception *excP,
|
||||
ExcDetail detail,
|
||||
ExcData data,
|
||||
ExcMessage message)
|
||||
ExcAbort(const Exception * excP,
|
||||
ExcDetail detail,
|
||||
ExcData data,
|
||||
ExcMessage message)
|
||||
{
|
||||
#ifdef __SABER__
|
||||
saber_stop();
|
||||
saber_stop();
|
||||
#else
|
||||
/* dump core */
|
||||
abort();
|
||||
/* dump core */
|
||||
abort();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* excid.c--
|
||||
* POSTGRES known exception identifier code.
|
||||
* POSTGRES known exception identifier code.
|
||||
*
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/error/Attic/excid.c,v 1.2 1996/11/03 06:53:35 scrappy Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/error/Attic/excid.c,v 1.3 1997/09/07 04:53:19 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -17,51 +17,51 @@
|
||||
#include "utils/excid.h"
|
||||
|
||||
/*****************************************************************************
|
||||
* Generic Recoverable Exceptions *
|
||||
* Generic Recoverable Exceptions *
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
/*
|
||||
* FailedAssertion --
|
||||
* Indicates an Assert(...) failed.
|
||||
* Indicates an Assert(...) failed.
|
||||
*/
|
||||
Exception FailedAssertion = { "Failed Assertion" };
|
||||
Exception FailedAssertion = {"Failed Assertion"};
|
||||
|
||||
/*
|
||||
* BadState --
|
||||
* Indicates a function call request is inconsistent with module state.
|
||||
* Indicates a function call request is inconsistent with module state.
|
||||
*/
|
||||
Exception BadState = { "Bad State for Function Call" };
|
||||
Exception BadState = {"Bad State for Function Call"};
|
||||
|
||||
/*
|
||||
* BadArg --
|
||||
* Indicates a function call argument or arguments is out-of-bounds.
|
||||
* Indicates a function call argument or arguments is out-of-bounds.
|
||||
*/
|
||||
Exception BadArg = { "Bad Argument to Function Call" };
|
||||
Exception BadArg = {"Bad Argument to Function Call"};
|
||||
|
||||
/*****************************************************************************
|
||||
* Specific Recoverable Exceptions *
|
||||
* Specific Recoverable Exceptions *
|
||||
*****************************************************************************/
|
||||
|
||||
/*
|
||||
* BadAllocSize --
|
||||
* Indicates that an allocation request is of unreasonable size.
|
||||
* Indicates that an allocation request is of unreasonable size.
|
||||
*/
|
||||
Exception BadAllocSize = { "Too Large Allocation Request" };
|
||||
Exception BadAllocSize = {"Too Large Allocation Request"};
|
||||
|
||||
/*
|
||||
* ExhaustedMemory --
|
||||
* Indicates an dynamic memory allocation failed.
|
||||
* Indicates an dynamic memory allocation failed.
|
||||
*/
|
||||
Exception ExhaustedMemory = { "Memory Allocation Failed" };
|
||||
Exception ExhaustedMemory = {"Memory Allocation Failed"};
|
||||
|
||||
/*
|
||||
* Unimplemented --
|
||||
* Indicates a function call request requires unimplemented code.
|
||||
* Indicates a function call request requires unimplemented code.
|
||||
*/
|
||||
Exception Unimplemented = { "Unimplemented Functionality" };
|
||||
Exception Unimplemented = {"Unimplemented Functionality"};
|
||||
|
||||
Exception CatalogFailure = {"Catalog failure"}; /* XXX inconsistent */
|
||||
Exception InternalError = {"Internal Error"}; /* XXX inconsistent */
|
||||
Exception SemanticError = {"Semantic Error"}; /* XXX inconsistent */
|
||||
Exception SystemError = {"System Error"}; /* XXX inconsistent */
|
||||
Exception CatalogFailure = {"Catalog failure"}; /* XXX inconsistent */
|
||||
Exception InternalError = {"Internal Error"}; /* XXX inconsistent */
|
||||
Exception SemanticError = {"Semantic Error"}; /* XXX inconsistent */
|
||||
Exception SystemError = {"System Error"}; /* XXX inconsistent */
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* format.c--
|
||||
* a wrapper around code that does what vsprintf does.
|
||||
* a wrapper around code that does what vsprintf does.
|
||||
*
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/error/Attic/format.c,v 1.3 1997/08/12 22:54:47 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/error/Attic/format.c,v 1.4 1997/09/07 04:53:20 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -15,26 +15,26 @@
|
||||
#include <stdarg.h>
|
||||
#include "c.h"
|
||||
|
||||
#define FormMaxSize 1024
|
||||
#define FormMinSize (FormMaxSize / 8)
|
||||
#define FormMaxSize 1024
|
||||
#define FormMinSize (FormMaxSize / 8)
|
||||
|
||||
static char FormBuf[FormMaxSize];
|
||||
static char FormBuf[FormMaxSize];
|
||||
|
||||
|
||||
/* ----------------
|
||||
* form
|
||||
* form
|
||||
* ----------------
|
||||
*/
|
||||
char *
|
||||
form(const char *fmt, ... )
|
||||
char *
|
||||
form(const char *fmt,...)
|
||||
{
|
||||
va_list args;
|
||||
va_list args;
|
||||
|
||||
va_start(args, fmt);
|
||||
|
||||
vsprintf(FormBuf, fmt, args);
|
||||
va_start(args, fmt);
|
||||
|
||||
va_end(args);
|
||||
|
||||
return (FormBuf);
|
||||
vsprintf(FormBuf, fmt, args);
|
||||
|
||||
va_end(args);
|
||||
|
||||
return (FormBuf);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user