1996-08-28 03:59:28 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* elog.h
|
2003-07-27 20:37:52 +02:00
|
|
|
* POSTGRES error reporting/logging definitions.
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
|
|
|
*
|
2002-06-20 22:29:54 +02:00
|
|
|
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
2003-07-27 20:37:52 +02:00
|
|
|
* $Id: elog.h,v 1.60 2003/07/27 18:37:52 tgl Exp $
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
1997-09-07 07:04:48 +02:00
|
|
|
#ifndef ELOG_H
|
1996-08-28 03:59:28 +02:00
|
|
|
#define ELOG_H
|
|
|
|
|
2001-01-14 06:08:17 +01:00
|
|
|
/* Error level codes */
|
2002-09-04 22:31:48 +02:00
|
|
|
#define DEBUG5 10 /* Debugging messages, in categories of
|
|
|
|
* decreasing detail. */
|
2002-03-05 00:59:14 +01:00
|
|
|
#define DEBUG4 11
|
2002-09-04 22:31:48 +02:00
|
|
|
#define DEBUG3 12
|
|
|
|
#define DEBUG2 13
|
2003-05-27 19:49:47 +02:00
|
|
|
#define DEBUG1 14 /* used by GUC debug_* variables */
|
2002-09-04 22:31:48 +02:00
|
|
|
#define LOG 15 /* Server operational messages; sent only
|
|
|
|
* to server log by default. */
|
|
|
|
#define COMMERROR 16 /* Client communication problems; same as
|
|
|
|
* LOG for server reporting, but never
|
|
|
|
* sent to client. */
|
|
|
|
#define INFO 17 /* Informative messages that are always
|
|
|
|
* sent to client; is not affected by
|
|
|
|
* client_min_messages */
|
|
|
|
#define NOTICE 18 /* Helpful messages to users about query
|
|
|
|
* operation; sent to client and server
|
|
|
|
* log by default. */
|
|
|
|
#define WARNING 19 /* Warnings */
|
|
|
|
#define ERROR 20 /* user error - abort transaction; return
|
|
|
|
* to known state */
|
2003-07-15 01:36:15 +02:00
|
|
|
/* Save ERROR value in PGERROR so it can be restored when Win32 includes
|
2003-05-15 18:35:30 +02:00
|
|
|
* modify it. We have to use a constant rather than ERROR because macros
|
|
|
|
* are expanded only when referenced outside macros.
|
|
|
|
*/
|
|
|
|
#ifdef WIN32
|
|
|
|
#define PGERROR 20
|
|
|
|
#endif
|
2002-09-04 22:31:48 +02:00
|
|
|
#define FATAL 21 /* fatal error - abort process */
|
|
|
|
#define PANIC 22 /* take down the other backends with me */
|
2001-06-08 23:16:49 +02:00
|
|
|
|
2002-09-04 22:31:48 +02:00
|
|
|
/*#define DEBUG DEBUG1*/ /* Backward compatibility with pre-7.3 */
|
1996-08-28 03:59:28 +02:00
|
|
|
|
2003-04-24 23:16:45 +02:00
|
|
|
|
|
|
|
/* macros for representing SQLSTATE strings compactly */
|
|
|
|
#define PGSIXBIT(ch) (((ch) - '0') & 0x3F)
|
|
|
|
#define PGUNSIXBIT(val) (((val) & 0x3F) + '0')
|
|
|
|
|
|
|
|
#define MAKE_SQLSTATE(ch1,ch2,ch3,ch4,ch5) \
|
|
|
|
(PGSIXBIT(ch1) + (PGSIXBIT(ch2) << 6) + (PGSIXBIT(ch3) << 12) + \
|
|
|
|
(PGSIXBIT(ch4) << 18) + (PGSIXBIT(ch5) << 24))
|
|
|
|
|
2003-07-27 20:37:52 +02:00
|
|
|
/* SQLSTATE codes for errors are defined in a separate file */
|
|
|
|
#include "utils/errcodes.h"
|
2003-07-19 22:20:53 +02:00
|
|
|
|
2003-04-24 23:16:45 +02:00
|
|
|
|
|
|
|
/* Which __func__ symbol do we have, if any? */
|
|
|
|
#ifdef HAVE_FUNCNAME__FUNC
|
|
|
|
#define PG_FUNCNAME_MACRO __func__
|
|
|
|
#else
|
|
|
|
#ifdef HAVE_FUNCNAME__FUNCTION
|
|
|
|
#define PG_FUNCNAME_MACRO __FUNCTION__
|
|
|
|
#else
|
|
|
|
#define PG_FUNCNAME_MACRO NULL
|
2000-05-31 02:28:42 +02:00
|
|
|
#endif
|
2003-04-24 23:16:45 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/*----------
|
|
|
|
* New-style error reporting API: to be used in this way:
|
|
|
|
* ereport(ERROR,
|
2003-07-19 01:20:33 +02:00
|
|
|
* (errcode(ERRCODE_UNDEFINED_CURSOR),
|
2003-04-24 23:16:45 +02:00
|
|
|
* errmsg("portal \"%s\" not found", stmt->portalname),
|
|
|
|
* ... other errxxx() fields as needed ...));
|
|
|
|
*
|
|
|
|
* The error level is required, and so is a primary error message (errmsg
|
|
|
|
* or errmsg_internal). All else is optional. errcode() defaults to
|
2003-07-19 01:20:33 +02:00
|
|
|
* ERRCODE_INTERNAL_ERROR if elevel is ERROR or more, ERRCODE_WARNING
|
|
|
|
* if elevel is WARNING, or ERRCODE_SUCCESSFUL_COMPLETION if elevel is
|
|
|
|
* NOTICE or below.
|
2003-04-24 23:16:45 +02:00
|
|
|
*----------
|
|
|
|
*/
|
|
|
|
#define ereport(elevel, rest) \
|
|
|
|
(errstart(elevel, __FILE__, __LINE__, PG_FUNCNAME_MACRO) ? \
|
|
|
|
(errfinish rest) : (void) 0)
|
|
|
|
|
|
|
|
extern bool errstart(int elevel, const char *filename, int lineno,
|
|
|
|
const char *funcname);
|
|
|
|
extern void errfinish(int dummy, ...);
|
|
|
|
|
|
|
|
extern int errcode(int sqlerrcode);
|
|
|
|
|
2003-07-19 01:20:33 +02:00
|
|
|
extern int errcode_for_file_access(void);
|
2003-07-22 21:00:12 +02:00
|
|
|
extern int errcode_for_socket_access(void);
|
2003-07-19 01:20:33 +02:00
|
|
|
|
2003-04-24 23:16:45 +02:00
|
|
|
extern int errmsg(const char *fmt, ...)
|
|
|
|
/* This extension allows gcc to check the format string for consistency with
|
|
|
|
the supplied arguments. */
|
|
|
|
__attribute__((format(printf, 1, 2)));
|
|
|
|
|
|
|
|
extern int errmsg_internal(const char *fmt, ...)
|
|
|
|
/* This extension allows gcc to check the format string for consistency with
|
|
|
|
the supplied arguments. */
|
|
|
|
__attribute__((format(printf, 1, 2)));
|
|
|
|
|
|
|
|
extern int errdetail(const char *fmt, ...)
|
|
|
|
/* This extension allows gcc to check the format string for consistency with
|
|
|
|
the supplied arguments. */
|
|
|
|
__attribute__((format(printf, 1, 2)));
|
|
|
|
|
|
|
|
extern int errhint(const char *fmt, ...)
|
|
|
|
/* This extension allows gcc to check the format string for consistency with
|
|
|
|
the supplied arguments. */
|
|
|
|
__attribute__((format(printf, 1, 2)));
|
|
|
|
|
|
|
|
extern int errcontext(const char *fmt, ...)
|
|
|
|
/* This extension allows gcc to check the format string for consistency with
|
|
|
|
the supplied arguments. */
|
|
|
|
__attribute__((format(printf, 1, 2)));
|
|
|
|
|
|
|
|
extern int errfunction(const char *funcname);
|
|
|
|
extern int errposition(int cursorpos);
|
|
|
|
|
|
|
|
|
|
|
|
/*----------
|
|
|
|
* Old-style error reporting API: to be used in this way:
|
|
|
|
* elog(ERROR, "portal \"%s\" not found", stmt->portalname);
|
|
|
|
*----------
|
|
|
|
*/
|
|
|
|
#define elog errstart(ERROR, __FILE__, __LINE__, PG_FUNCNAME_MACRO), elog_finish
|
2000-06-04 17:06:34 +02:00
|
|
|
|
2001-10-25 07:50:21 +02:00
|
|
|
extern void
|
2003-04-24 23:16:45 +02:00
|
|
|
elog_finish(int elevel, const char *fmt, ...)
|
2000-01-13 19:26:18 +01:00
|
|
|
/* This extension allows gcc to check the format string for consistency with
|
|
|
|
the supplied arguments. */
|
2001-03-22 05:01:46 +01:00
|
|
|
__attribute__((format(printf, 2, 3)));
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2003-04-24 23:16:45 +02:00
|
|
|
|
|
|
|
/* Support for attaching context information to error reports */
|
|
|
|
|
|
|
|
typedef struct ErrorContextCallback
|
|
|
|
{
|
|
|
|
struct ErrorContextCallback *previous;
|
|
|
|
void (*callback) (void *arg);
|
|
|
|
void *arg;
|
|
|
|
} ErrorContextCallback;
|
|
|
|
|
2003-05-22 19:20:44 +02:00
|
|
|
extern DLLIMPORT ErrorContextCallback *error_context_stack;
|
2003-04-24 23:16:45 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* GUC-configurable parameters */
|
2003-06-30 18:47:02 +02:00
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
PGERROR_TERSE, /* single-line error messages */
|
|
|
|
PGERROR_DEFAULT, /* recommended style */
|
|
|
|
PGERROR_VERBOSE /* all the facts, ma'am */
|
|
|
|
} PGErrorVerbosity;
|
|
|
|
|
|
|
|
extern PGErrorVerbosity Log_error_verbosity;
|
2003-04-24 23:16:45 +02:00
|
|
|
extern bool Log_timestamp;
|
|
|
|
extern bool Log_pid;
|
|
|
|
#ifdef HAVE_SYSLOG
|
|
|
|
extern int Use_syslog;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/* Other exported functions */
|
|
|
|
extern void DebugFileOpen(void);
|
Commit to match discussed elog() changes. Only update is that LOG is
now just below FATAL in server_min_messages. Added more text to
highlight ordering difference between it and client_min_messages.
---------------------------------------------------------------------------
REALLYFATAL => PANIC
STOP => PANIC
New INFO level the prints to client by default
New LOG level the prints to server log by default
Cause VACUUM information to print only to the client
NOTICE => INFO where purely information messages are sent
DEBUG => LOG for purely server status messages
DEBUG removed, kept as backward compatible
DEBUG5, DEBUG4, DEBUG3, DEBUG2, DEBUG1 added
DebugLvl removed in favor of new DEBUG[1-5] symbols
New server_min_messages GUC parameter with values:
DEBUG[5-1], INFO, NOTICE, ERROR, LOG, FATAL, PANIC
New client_min_messages GUC parameter with values:
DEBUG[5-1], LOG, INFO, NOTICE, ERROR, FATAL, PANIC
Server startup now logged with LOG instead of DEBUG
Remove debug_level GUC parameter
elog() numbers now start at 10
Add test to print error message if older elog() values are passed to elog()
Bootstrap mode now has a -d that requires an argument, like postmaster
2002-03-02 22:39:36 +01:00
|
|
|
|
2001-11-05 18:46:40 +01:00
|
|
|
#endif /* ELOG_H */
|