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
|
|
|
*
|
|
|
|
*
|
2014-01-07 22:05:30 +01:00
|
|
|
* Portions Copyright (c) 1996-2014, 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
|
|
|
*
|
2010-09-20 22:08:53 +02:00
|
|
|
* src/include/utils/elog.h
|
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
|
|
|
|
|
2004-07-31 02:45:57 +02:00
|
|
|
#include <setjmp.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 */
|
2005-10-15 04:49:52 +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. */
|
2009-06-11 16:49:15 +02:00
|
|
|
#define INFO 17 /* Messages specifically requested by user (eg
|
|
|
|
* VACUUM VERBOSE output); always sent to
|
2009-01-06 17:39:52 +01:00
|
|
|
* client regardless of client_min_messages,
|
|
|
|
* but by default not sent to server log. */
|
2002-09-04 22:31:48 +02:00
|
|
|
#define NOTICE 18 /* Helpful messages to users about query
|
2009-06-11 16:49:15 +02:00
|
|
|
* operation; sent to client and server log by
|
|
|
|
* default. */
|
2005-10-15 04:49:52 +02:00
|
|
|
#define WARNING 19 /* Warnings. NOTICE is for expected messages
|
|
|
|
* like implicit sequence creation by SERIAL.
|
|
|
|
* WARNING is for unexpected messages. */
|
|
|
|
#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
|
|
|
|
2003-08-04 02:43:34 +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)
|
2003-08-04 02:43:34 +02:00
|
|
|
#define PGUNSIXBIT(val) (((val) & 0x3F) + '0')
|
2003-04-24 23:16:45 +02:00
|
|
|
|
|
|
|
#define MAKE_SQLSTATE(ch1,ch2,ch3,ch4,ch5) \
|
|
|
|
(PGSIXBIT(ch1) + (PGSIXBIT(ch2) << 6) + (PGSIXBIT(ch3) << 12) + \
|
|
|
|
(PGSIXBIT(ch4) << 18) + (PGSIXBIT(ch5) << 24))
|
|
|
|
|
2004-08-01 01:04:58 +02:00
|
|
|
/* These macros depend on the fact that '0' becomes a zero in SIXBIT */
|
|
|
|
#define ERRCODE_TO_CATEGORY(ec) ((ec) & ((1 << 12) - 1))
|
|
|
|
#define ERRCODE_IS_CATEGORY(ec) (((ec) & ~((1 << 12) - 1)) == 0)
|
|
|
|
|
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
|
2003-08-04 02:43:34 +02:00
|
|
|
* 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.
|
2008-10-09 19:24:05 +02:00
|
|
|
*
|
|
|
|
* ereport_domain() allows a message domain to be specified, for modules that
|
|
|
|
* wish to use a different message catalog from the backend's. To avoid having
|
|
|
|
* one copy of the default text domain per .o file, we define it as NULL here
|
|
|
|
* and have errstart insert the default text domain. Modules can either use
|
2008-10-10 00:22:31 +02:00
|
|
|
* ereport_domain() directly, or preferably they can override the TEXTDOMAIN
|
2008-10-09 19:24:05 +02:00
|
|
|
* macro.
|
2012-08-21 06:03:32 +02:00
|
|
|
*
|
Improve handling of ereport(ERROR) and elog(ERROR).
In commit 71450d7fd6c7cf7b3e38ac56e363bff6a681973c, we added code to inform
suitably-intelligent compilers that ereport() doesn't return if the elevel
is ERROR or higher. This patch extends that to elog(), and also fixes a
double-evaluation hazard that the previous commit created in ereport(),
as well as reducing the emitted code size.
The elog() improvement requires the compiler to support __VA_ARGS__, which
should be available in just about anything nowadays since it's required by
C99. But our minimum language baseline is still C89, so add a configure
test for that.
The previous commit assumed that ereport's elevel could be evaluated twice,
which isn't terribly safe --- there are already counterexamples in xlog.c.
On compilers that have __builtin_constant_p, we can use that to protect the
second test, since there's no possible optimization gain if the compiler
doesn't know the value of elevel. Otherwise, use a local variable inside
the macros to prevent double evaluation. The local-variable solution is
inferior because (a) it leads to useless code being emitted when elevel
isn't constant, and (b) it increases the optimization level needed for the
compiler to recognize that subsequent code is unreachable. But it seems
better than not teaching non-gcc compilers about unreachability at all.
Lastly, if the compiler has __builtin_unreachable(), we can use that
instead of abort(), resulting in a noticeable code savings since no
function call is actually emitted. However, it seems wise to do this only
in non-assert builds. In an assert build, continue to use abort(), so that
the behavior will be predictable and debuggable if the "impossible"
happens.
These changes involve making the ereport and elog macros emit do-while
statement blocks not just expressions, which forces small changes in
a few call sites.
Andres Freund, Tom Lane, Heikki Linnakangas
2013-01-14 00:39:20 +01:00
|
|
|
* If elevel >= ERROR, the call will not return; we try to inform the compiler
|
|
|
|
* of that via pg_unreachable(). However, no useful optimization effect is
|
|
|
|
* obtained unless the compiler sees elevel as a compile-time constant, else
|
|
|
|
* we're just adding code bloat. So, if __builtin_constant_p is available,
|
|
|
|
* use that to cause the second if() to vanish completely for non-constant
|
|
|
|
* cases. We avoid using a local variable because it's not necessary and
|
|
|
|
* prevents gcc from making the unreachability deduction at optlevel -O0.
|
2003-04-24 23:16:45 +02:00
|
|
|
*----------
|
|
|
|
*/
|
Improve handling of ereport(ERROR) and elog(ERROR).
In commit 71450d7fd6c7cf7b3e38ac56e363bff6a681973c, we added code to inform
suitably-intelligent compilers that ereport() doesn't return if the elevel
is ERROR or higher. This patch extends that to elog(), and also fixes a
double-evaluation hazard that the previous commit created in ereport(),
as well as reducing the emitted code size.
The elog() improvement requires the compiler to support __VA_ARGS__, which
should be available in just about anything nowadays since it's required by
C99. But our minimum language baseline is still C89, so add a configure
test for that.
The previous commit assumed that ereport's elevel could be evaluated twice,
which isn't terribly safe --- there are already counterexamples in xlog.c.
On compilers that have __builtin_constant_p, we can use that to protect the
second test, since there's no possible optimization gain if the compiler
doesn't know the value of elevel. Otherwise, use a local variable inside
the macros to prevent double evaluation. The local-variable solution is
inferior because (a) it leads to useless code being emitted when elevel
isn't constant, and (b) it increases the optimization level needed for the
compiler to recognize that subsequent code is unreachable. But it seems
better than not teaching non-gcc compilers about unreachability at all.
Lastly, if the compiler has __builtin_unreachable(), we can use that
instead of abort(), resulting in a noticeable code savings since no
function call is actually emitted. However, it seems wise to do this only
in non-assert builds. In an assert build, continue to use abort(), so that
the behavior will be predictable and debuggable if the "impossible"
happens.
These changes involve making the ereport and elog macros emit do-while
statement blocks not just expressions, which forces small changes in
a few call sites.
Andres Freund, Tom Lane, Heikki Linnakangas
2013-01-14 00:39:20 +01:00
|
|
|
#ifdef HAVE__BUILTIN_CONSTANT_P
|
2008-10-09 19:24:05 +02:00
|
|
|
#define ereport_domain(elevel, domain, rest) \
|
Improve handling of ereport(ERROR) and elog(ERROR).
In commit 71450d7fd6c7cf7b3e38ac56e363bff6a681973c, we added code to inform
suitably-intelligent compilers that ereport() doesn't return if the elevel
is ERROR or higher. This patch extends that to elog(), and also fixes a
double-evaluation hazard that the previous commit created in ereport(),
as well as reducing the emitted code size.
The elog() improvement requires the compiler to support __VA_ARGS__, which
should be available in just about anything nowadays since it's required by
C99. But our minimum language baseline is still C89, so add a configure
test for that.
The previous commit assumed that ereport's elevel could be evaluated twice,
which isn't terribly safe --- there are already counterexamples in xlog.c.
On compilers that have __builtin_constant_p, we can use that to protect the
second test, since there's no possible optimization gain if the compiler
doesn't know the value of elevel. Otherwise, use a local variable inside
the macros to prevent double evaluation. The local-variable solution is
inferior because (a) it leads to useless code being emitted when elevel
isn't constant, and (b) it increases the optimization level needed for the
compiler to recognize that subsequent code is unreachable. But it seems
better than not teaching non-gcc compilers about unreachability at all.
Lastly, if the compiler has __builtin_unreachable(), we can use that
instead of abort(), resulting in a noticeable code savings since no
function call is actually emitted. However, it seems wise to do this only
in non-assert builds. In an assert build, continue to use abort(), so that
the behavior will be predictable and debuggable if the "impossible"
happens.
These changes involve making the ereport and elog macros emit do-while
statement blocks not just expressions, which forces small changes in
a few call sites.
Andres Freund, Tom Lane, Heikki Linnakangas
2013-01-14 00:39:20 +01:00
|
|
|
do { \
|
|
|
|
if (errstart(elevel, __FILE__, __LINE__, PG_FUNCNAME_MACRO, domain)) \
|
|
|
|
errfinish rest; \
|
|
|
|
if (__builtin_constant_p(elevel) && (elevel) >= ERROR) \
|
|
|
|
pg_unreachable(); \
|
|
|
|
} while(0)
|
2013-05-29 22:58:43 +02:00
|
|
|
#else /* !HAVE__BUILTIN_CONSTANT_P */
|
Improve handling of ereport(ERROR) and elog(ERROR).
In commit 71450d7fd6c7cf7b3e38ac56e363bff6a681973c, we added code to inform
suitably-intelligent compilers that ereport() doesn't return if the elevel
is ERROR or higher. This patch extends that to elog(), and also fixes a
double-evaluation hazard that the previous commit created in ereport(),
as well as reducing the emitted code size.
The elog() improvement requires the compiler to support __VA_ARGS__, which
should be available in just about anything nowadays since it's required by
C99. But our minimum language baseline is still C89, so add a configure
test for that.
The previous commit assumed that ereport's elevel could be evaluated twice,
which isn't terribly safe --- there are already counterexamples in xlog.c.
On compilers that have __builtin_constant_p, we can use that to protect the
second test, since there's no possible optimization gain if the compiler
doesn't know the value of elevel. Otherwise, use a local variable inside
the macros to prevent double evaluation. The local-variable solution is
inferior because (a) it leads to useless code being emitted when elevel
isn't constant, and (b) it increases the optimization level needed for the
compiler to recognize that subsequent code is unreachable. But it seems
better than not teaching non-gcc compilers about unreachability at all.
Lastly, if the compiler has __builtin_unreachable(), we can use that
instead of abort(), resulting in a noticeable code savings since no
function call is actually emitted. However, it seems wise to do this only
in non-assert builds. In an assert build, continue to use abort(), so that
the behavior will be predictable and debuggable if the "impossible"
happens.
These changes involve making the ereport and elog macros emit do-while
statement blocks not just expressions, which forces small changes in
a few call sites.
Andres Freund, Tom Lane, Heikki Linnakangas
2013-01-14 00:39:20 +01:00
|
|
|
#define ereport_domain(elevel, domain, rest) \
|
|
|
|
do { \
|
|
|
|
const int elevel_ = (elevel); \
|
|
|
|
if (errstart(elevel_, __FILE__, __LINE__, PG_FUNCNAME_MACRO, domain)) \
|
|
|
|
errfinish rest; \
|
|
|
|
if (elevel_ >= ERROR) \
|
|
|
|
pg_unreachable(); \
|
|
|
|
} while(0)
|
2013-05-29 22:58:43 +02:00
|
|
|
#endif /* HAVE__BUILTIN_CONSTANT_P */
|
2003-04-24 23:16:45 +02:00
|
|
|
|
2009-06-04 20:33:08 +02:00
|
|
|
#define ereport(elevel, rest) \
|
|
|
|
ereport_domain(elevel, TEXTDOMAIN, rest)
|
2008-10-09 19:24:05 +02:00
|
|
|
|
|
|
|
#define TEXTDOMAIN NULL
|
|
|
|
|
2003-04-24 23:16:45 +02:00
|
|
|
extern bool errstart(int elevel, const char *filename, int lineno,
|
2008-10-09 19:24:05 +02:00
|
|
|
const char *funcname, const char *domain);
|
2003-08-04 02:43:34 +02:00
|
|
|
extern void errfinish(int dummy,...);
|
2003-04-24 23:16:45 +02:00
|
|
|
|
2003-08-04 02:43:34 +02:00
|
|
|
extern int errcode(int sqlerrcode);
|
2003-04-24 23:16:45 +02:00
|
|
|
|
2003-08-04 02:43:34 +02:00
|
|
|
extern int errcode_for_file_access(void);
|
|
|
|
extern int errcode_for_socket_access(void);
|
2003-07-19 01:20:33 +02:00
|
|
|
|
2003-08-04 02:43:34 +02:00
|
|
|
extern int
|
|
|
|
errmsg(const char *fmt,...)
|
2003-04-24 23:16:45 +02:00
|
|
|
/* This extension allows gcc to check the format string for consistency with
|
|
|
|
the supplied arguments. */
|
2011-04-28 16:56:14 +02:00
|
|
|
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
|
2003-04-24 23:16:45 +02:00
|
|
|
|
2003-08-04 02:43:34 +02:00
|
|
|
extern int
|
|
|
|
errmsg_internal(const char *fmt,...)
|
2003-04-24 23:16:45 +02:00
|
|
|
/* This extension allows gcc to check the format string for consistency with
|
|
|
|
the supplied arguments. */
|
2011-04-28 16:56:14 +02:00
|
|
|
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
|
2003-04-24 23:16:45 +02:00
|
|
|
|
2009-06-04 20:33:08 +02:00
|
|
|
extern int
|
|
|
|
errmsg_plural(const char *fmt_singular, const char *fmt_plural,
|
2009-06-11 16:49:15 +02:00
|
|
|
unsigned long n,...)
|
2009-06-04 20:33:08 +02:00
|
|
|
/* This extension allows gcc to check the format string for consistency with
|
|
|
|
the supplied arguments. */
|
2011-04-28 16:56:14 +02:00
|
|
|
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 4)))
|
|
|
|
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 4)));
|
2009-06-04 20:33:08 +02:00
|
|
|
|
2003-08-04 02:43:34 +02:00
|
|
|
extern int
|
|
|
|
errdetail(const char *fmt,...)
|
2003-04-24 23:16:45 +02:00
|
|
|
/* This extension allows gcc to check the format string for consistency with
|
|
|
|
the supplied arguments. */
|
2011-04-28 16:56:14 +02:00
|
|
|
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
|
2003-04-24 23:16:45 +02:00
|
|
|
|
2011-07-16 19:41:48 +02:00
|
|
|
extern int
|
|
|
|
errdetail_internal(const char *fmt,...)
|
|
|
|
/* This extension allows gcc to check the format string for consistency with
|
|
|
|
the supplied arguments. */
|
|
|
|
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
|
|
|
|
|
2008-03-24 19:08:47 +01:00
|
|
|
extern int
|
|
|
|
errdetail_log(const char *fmt,...)
|
|
|
|
/* This extension allows gcc to check the format string for consistency with
|
|
|
|
the supplied arguments. */
|
2011-04-28 16:56:14 +02:00
|
|
|
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
|
2008-03-24 19:08:47 +01:00
|
|
|
|
2009-06-04 20:33:08 +02:00
|
|
|
extern int
|
|
|
|
errdetail_plural(const char *fmt_singular, const char *fmt_plural,
|
2009-06-11 16:49:15 +02:00
|
|
|
unsigned long n,...)
|
2009-06-04 20:33:08 +02:00
|
|
|
/* This extension allows gcc to check the format string for consistency with
|
|
|
|
the supplied arguments. */
|
2011-04-28 16:56:14 +02:00
|
|
|
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 4)))
|
|
|
|
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 4)));
|
2009-06-04 20:33:08 +02:00
|
|
|
|
2003-08-04 02:43:34 +02:00
|
|
|
extern int
|
|
|
|
errhint(const char *fmt,...)
|
2003-04-24 23:16:45 +02:00
|
|
|
/* This extension allows gcc to check the format string for consistency with
|
|
|
|
the supplied arguments. */
|
2011-04-28 16:56:14 +02:00
|
|
|
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
|
2003-04-24 23:16:45 +02:00
|
|
|
|
2012-11-12 14:10:24 +01:00
|
|
|
/*
|
|
|
|
* errcontext() is typically called in error context callback functions, not
|
|
|
|
* within an ereport() invocation. The callback function can be in a different
|
|
|
|
* module than the ereport() call, so the message domain passed in errstart()
|
|
|
|
* is not usually the correct domain for translating the context message.
|
|
|
|
* set_errcontext_domain() first sets the domain to be used, and
|
|
|
|
* errcontext_msg() passes the actual message.
|
|
|
|
*/
|
2013-05-29 22:58:43 +02:00
|
|
|
#define errcontext set_errcontext_domain(TEXTDOMAIN), errcontext_msg
|
2012-11-12 14:10:24 +01:00
|
|
|
|
|
|
|
extern int set_errcontext_domain(const char *domain);
|
2003-08-04 02:43:34 +02:00
|
|
|
extern int
|
2012-11-12 14:10:24 +01:00
|
|
|
errcontext_msg(const char *fmt,...)
|
2003-04-24 23:16:45 +02:00
|
|
|
/* This extension allows gcc to check the format string for consistency with
|
|
|
|
the supplied arguments. */
|
2011-04-28 16:56:14 +02:00
|
|
|
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
|
2003-04-24 23:16:45 +02:00
|
|
|
|
2007-03-03 00:37:23 +01:00
|
|
|
extern int errhidestmt(bool hide_stmt);
|
|
|
|
|
2003-08-04 02:43:34 +02:00
|
|
|
extern int errfunction(const char *funcname);
|
|
|
|
extern int errposition(int cursorpos);
|
2003-04-24 23:16:45 +02:00
|
|
|
|
2004-03-21 23:29:11 +01:00
|
|
|
extern int internalerrposition(int cursorpos);
|
|
|
|
extern int internalerrquery(const char *query);
|
|
|
|
|
Provide database object names as separate fields in error messages.
This patch addresses the problem that applications currently have to
extract object names from possibly-localized textual error messages,
if they want to know for example which index caused a UNIQUE_VIOLATION
failure. It adds new error message fields to the wire protocol, which
can carry the name of a table, table column, data type, or constraint
associated with the error. (Since the protocol spec has always instructed
clients to ignore unrecognized field types, this should not create any
compatibility problem.)
Support for providing these new fields has been added to just a limited set
of error reports (mainly, those in the "integrity constraint violation"
SQLSTATE class), but we will doubtless add them to more calls in future.
Pavel Stehule, reviewed and extensively revised by Peter Geoghegan, with
additional hacking by Tom Lane.
2013-01-29 23:06:26 +01:00
|
|
|
extern int err_generic_string(int field, const char *str);
|
|
|
|
|
2008-09-01 22:42:46 +02:00
|
|
|
extern int geterrcode(void);
|
2004-03-21 23:29:11 +01:00
|
|
|
extern int geterrposition(void);
|
|
|
|
extern int getinternalerrposition(void);
|
|
|
|
|
2003-04-24 23:16:45 +02:00
|
|
|
|
|
|
|
/*----------
|
|
|
|
* Old-style error reporting API: to be used in this way:
|
|
|
|
* elog(ERROR, "portal \"%s\" not found", stmt->portalname);
|
|
|
|
*----------
|
|
|
|
*/
|
Improve handling of ereport(ERROR) and elog(ERROR).
In commit 71450d7fd6c7cf7b3e38ac56e363bff6a681973c, we added code to inform
suitably-intelligent compilers that ereport() doesn't return if the elevel
is ERROR or higher. This patch extends that to elog(), and also fixes a
double-evaluation hazard that the previous commit created in ereport(),
as well as reducing the emitted code size.
The elog() improvement requires the compiler to support __VA_ARGS__, which
should be available in just about anything nowadays since it's required by
C99. But our minimum language baseline is still C89, so add a configure
test for that.
The previous commit assumed that ereport's elevel could be evaluated twice,
which isn't terribly safe --- there are already counterexamples in xlog.c.
On compilers that have __builtin_constant_p, we can use that to protect the
second test, since there's no possible optimization gain if the compiler
doesn't know the value of elevel. Otherwise, use a local variable inside
the macros to prevent double evaluation. The local-variable solution is
inferior because (a) it leads to useless code being emitted when elevel
isn't constant, and (b) it increases the optimization level needed for the
compiler to recognize that subsequent code is unreachable. But it seems
better than not teaching non-gcc compilers about unreachability at all.
Lastly, if the compiler has __builtin_unreachable(), we can use that
instead of abort(), resulting in a noticeable code savings since no
function call is actually emitted. However, it seems wise to do this only
in non-assert builds. In an assert build, continue to use abort(), so that
the behavior will be predictable and debuggable if the "impossible"
happens.
These changes involve making the ereport and elog macros emit do-while
statement blocks not just expressions, which forces small changes in
a few call sites.
Andres Freund, Tom Lane, Heikki Linnakangas
2013-01-14 00:39:20 +01:00
|
|
|
#ifdef HAVE__VA_ARGS
|
|
|
|
/*
|
|
|
|
* If we have variadic macros, we can give the compiler a hint about the
|
|
|
|
* call not returning when elevel >= ERROR. See comments for ereport().
|
|
|
|
* Note that historically elog() has called elog_start (which saves errno)
|
|
|
|
* before evaluating "elevel", so we preserve that behavior here.
|
|
|
|
*/
|
|
|
|
#ifdef HAVE__BUILTIN_CONSTANT_P
|
|
|
|
#define elog(elevel, ...) \
|
|
|
|
do { \
|
|
|
|
elog_start(__FILE__, __LINE__, PG_FUNCNAME_MACRO); \
|
|
|
|
elog_finish(elevel, __VA_ARGS__); \
|
|
|
|
if (__builtin_constant_p(elevel) && (elevel) >= ERROR) \
|
|
|
|
pg_unreachable(); \
|
|
|
|
} while(0)
|
2013-05-29 22:58:43 +02:00
|
|
|
#else /* !HAVE__BUILTIN_CONSTANT_P */
|
Improve handling of ereport(ERROR) and elog(ERROR).
In commit 71450d7fd6c7cf7b3e38ac56e363bff6a681973c, we added code to inform
suitably-intelligent compilers that ereport() doesn't return if the elevel
is ERROR or higher. This patch extends that to elog(), and also fixes a
double-evaluation hazard that the previous commit created in ereport(),
as well as reducing the emitted code size.
The elog() improvement requires the compiler to support __VA_ARGS__, which
should be available in just about anything nowadays since it's required by
C99. But our minimum language baseline is still C89, so add a configure
test for that.
The previous commit assumed that ereport's elevel could be evaluated twice,
which isn't terribly safe --- there are already counterexamples in xlog.c.
On compilers that have __builtin_constant_p, we can use that to protect the
second test, since there's no possible optimization gain if the compiler
doesn't know the value of elevel. Otherwise, use a local variable inside
the macros to prevent double evaluation. The local-variable solution is
inferior because (a) it leads to useless code being emitted when elevel
isn't constant, and (b) it increases the optimization level needed for the
compiler to recognize that subsequent code is unreachable. But it seems
better than not teaching non-gcc compilers about unreachability at all.
Lastly, if the compiler has __builtin_unreachable(), we can use that
instead of abort(), resulting in a noticeable code savings since no
function call is actually emitted. However, it seems wise to do this only
in non-assert builds. In an assert build, continue to use abort(), so that
the behavior will be predictable and debuggable if the "impossible"
happens.
These changes involve making the ereport and elog macros emit do-while
statement blocks not just expressions, which forces small changes in
a few call sites.
Andres Freund, Tom Lane, Heikki Linnakangas
2013-01-14 00:39:20 +01:00
|
|
|
#define elog(elevel, ...) \
|
|
|
|
do { \
|
|
|
|
int elevel_; \
|
|
|
|
elog_start(__FILE__, __LINE__, PG_FUNCNAME_MACRO); \
|
|
|
|
elevel_ = (elevel); \
|
|
|
|
elog_finish(elevel_, __VA_ARGS__); \
|
|
|
|
if (elevel_ >= ERROR) \
|
|
|
|
pg_unreachable(); \
|
|
|
|
} while(0)
|
2013-05-29 22:58:43 +02:00
|
|
|
#endif /* HAVE__BUILTIN_CONSTANT_P */
|
|
|
|
#else /* !HAVE__VA_ARGS */
|
Improve handling of ereport(ERROR) and elog(ERROR).
In commit 71450d7fd6c7cf7b3e38ac56e363bff6a681973c, we added code to inform
suitably-intelligent compilers that ereport() doesn't return if the elevel
is ERROR or higher. This patch extends that to elog(), and also fixes a
double-evaluation hazard that the previous commit created in ereport(),
as well as reducing the emitted code size.
The elog() improvement requires the compiler to support __VA_ARGS__, which
should be available in just about anything nowadays since it's required by
C99. But our minimum language baseline is still C89, so add a configure
test for that.
The previous commit assumed that ereport's elevel could be evaluated twice,
which isn't terribly safe --- there are already counterexamples in xlog.c.
On compilers that have __builtin_constant_p, we can use that to protect the
second test, since there's no possible optimization gain if the compiler
doesn't know the value of elevel. Otherwise, use a local variable inside
the macros to prevent double evaluation. The local-variable solution is
inferior because (a) it leads to useless code being emitted when elevel
isn't constant, and (b) it increases the optimization level needed for the
compiler to recognize that subsequent code is unreachable. But it seems
better than not teaching non-gcc compilers about unreachability at all.
Lastly, if the compiler has __builtin_unreachable(), we can use that
instead of abort(), resulting in a noticeable code savings since no
function call is actually emitted. However, it seems wise to do this only
in non-assert builds. In an assert build, continue to use abort(), so that
the behavior will be predictable and debuggable if the "impossible"
happens.
These changes involve making the ereport and elog macros emit do-while
statement blocks not just expressions, which forces small changes in
a few call sites.
Andres Freund, Tom Lane, Heikki Linnakangas
2013-01-14 00:39:20 +01:00
|
|
|
#define elog \
|
|
|
|
elog_start(__FILE__, __LINE__, PG_FUNCNAME_MACRO), \
|
|
|
|
elog_finish
|
2013-05-29 22:58:43 +02:00
|
|
|
#endif /* HAVE__VA_ARGS */
|
2000-06-04 17:06:34 +02:00
|
|
|
|
2004-09-05 05:42:13 +02:00
|
|
|
extern void elog_start(const char *filename, int lineno, const char *funcname);
|
2001-10-25 07:50:21 +02:00
|
|
|
extern void
|
2003-08-04 02:43:34 +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. */
|
2011-04-28 16:56:14 +02:00
|
|
|
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3)));
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2003-04-24 23:16:45 +02:00
|
|
|
|
2011-04-07 06:11:01 +02:00
|
|
|
/* Support for constructing error strings separately from ereport() calls */
|
|
|
|
|
|
|
|
extern void pre_format_elog_string(int errnumber, const char *domain);
|
2011-04-10 17:42:00 +02:00
|
|
|
extern char *
|
|
|
|
format_elog_string(const char *fmt,...)
|
2011-04-07 06:11:01 +02:00
|
|
|
/* This extension allows gcc to check the format string for consistency with
|
|
|
|
the supplied arguments. */
|
2011-04-28 16:56:14 +02:00
|
|
|
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
|
2011-04-07 06:11:01 +02:00
|
|
|
|
|
|
|
|
2003-04-24 23:16:45 +02:00
|
|
|
/* Support for attaching context information to error reports */
|
|
|
|
|
|
|
|
typedef struct ErrorContextCallback
|
|
|
|
{
|
|
|
|
struct ErrorContextCallback *previous;
|
2003-08-04 02:43:34 +02:00
|
|
|
void (*callback) (void *arg);
|
|
|
|
void *arg;
|
2003-08-08 23:42:59 +02:00
|
|
|
} ErrorContextCallback;
|
2003-04-24 23:16:45 +02:00
|
|
|
|
2007-07-25 14:22:54 +02:00
|
|
|
extern PGDLLIMPORT ErrorContextCallback *error_context_stack;
|
2003-04-24 23:16:45 +02:00
|
|
|
|
|
|
|
|
2004-07-31 02:45:57 +02:00
|
|
|
/*----------
|
|
|
|
* API for catching ereport(ERROR) exits. Use these macros like so:
|
|
|
|
*
|
|
|
|
* PG_TRY();
|
|
|
|
* {
|
|
|
|
* ... code that might throw ereport(ERROR) ...
|
|
|
|
* }
|
|
|
|
* PG_CATCH();
|
|
|
|
* {
|
|
|
|
* ... error recovery code ...
|
|
|
|
* }
|
|
|
|
* PG_END_TRY();
|
|
|
|
*
|
|
|
|
* (The braces are not actually necessary, but are recommended so that
|
|
|
|
* pg_indent will indent the construct nicely.) The error recovery code
|
|
|
|
* can optionally do PG_RE_THROW() to propagate the same error outwards.
|
|
|
|
*
|
|
|
|
* Note: while the system will correctly propagate any new ereport(ERROR)
|
|
|
|
* occurring in the recovery section, there is a small limit on the number
|
|
|
|
* of levels this will work for. It's best to keep the error recovery
|
|
|
|
* section simple enough that it can't generate any new errors, at least
|
|
|
|
* not before popping the error stack.
|
2008-04-17 01:59:40 +02:00
|
|
|
*
|
|
|
|
* Note: an ereport(FATAL) will not be caught by this construct; control will
|
|
|
|
* exit straight through proc_exit(). Therefore, do NOT put any cleanup
|
|
|
|
* of non-process-local resources into the error recovery section, at least
|
|
|
|
* not without taking thought for what will happen during ereport(FATAL).
|
|
|
|
* The PG_ENSURE_ERROR_CLEANUP macros provided by storage/ipc.h may be
|
|
|
|
* helpful in such cases.
|
2004-07-31 02:45:57 +02:00
|
|
|
*----------
|
|
|
|
*/
|
|
|
|
#define PG_TRY() \
|
|
|
|
do { \
|
|
|
|
sigjmp_buf *save_exception_stack = PG_exception_stack; \
|
|
|
|
ErrorContextCallback *save_context_stack = error_context_stack; \
|
|
|
|
sigjmp_buf local_sigjmp_buf; \
|
2004-09-16 23:59:17 +02:00
|
|
|
if (sigsetjmp(local_sigjmp_buf, 0) == 0) \
|
2004-07-31 02:45:57 +02:00
|
|
|
{ \
|
|
|
|
PG_exception_stack = &local_sigjmp_buf
|
|
|
|
|
2004-08-29 07:07:03 +02:00
|
|
|
#define PG_CATCH() \
|
2004-07-31 02:45:57 +02:00
|
|
|
} \
|
|
|
|
else \
|
|
|
|
{ \
|
|
|
|
PG_exception_stack = save_exception_stack; \
|
|
|
|
error_context_stack = save_context_stack
|
|
|
|
|
|
|
|
#define PG_END_TRY() \
|
|
|
|
} \
|
|
|
|
PG_exception_stack = save_exception_stack; \
|
|
|
|
error_context_stack = save_context_stack; \
|
|
|
|
} while (0)
|
|
|
|
|
2007-05-04 04:01:02 +02:00
|
|
|
/*
|
|
|
|
* gcc understands __attribute__((noreturn)); for other compilers, insert
|
Improve handling of ereport(ERROR) and elog(ERROR).
In commit 71450d7fd6c7cf7b3e38ac56e363bff6a681973c, we added code to inform
suitably-intelligent compilers that ereport() doesn't return if the elevel
is ERROR or higher. This patch extends that to elog(), and also fixes a
double-evaluation hazard that the previous commit created in ereport(),
as well as reducing the emitted code size.
The elog() improvement requires the compiler to support __VA_ARGS__, which
should be available in just about anything nowadays since it's required by
C99. But our minimum language baseline is still C89, so add a configure
test for that.
The previous commit assumed that ereport's elevel could be evaluated twice,
which isn't terribly safe --- there are already counterexamples in xlog.c.
On compilers that have __builtin_constant_p, we can use that to protect the
second test, since there's no possible optimization gain if the compiler
doesn't know the value of elevel. Otherwise, use a local variable inside
the macros to prevent double evaluation. The local-variable solution is
inferior because (a) it leads to useless code being emitted when elevel
isn't constant, and (b) it increases the optimization level needed for the
compiler to recognize that subsequent code is unreachable. But it seems
better than not teaching non-gcc compilers about unreachability at all.
Lastly, if the compiler has __builtin_unreachable(), we can use that
instead of abort(), resulting in a noticeable code savings since no
function call is actually emitted. However, it seems wise to do this only
in non-assert builds. In an assert build, continue to use abort(), so that
the behavior will be predictable and debuggable if the "impossible"
happens.
These changes involve making the ereport and elog macros emit do-while
statement blocks not just expressions, which forces small changes in
a few call sites.
Andres Freund, Tom Lane, Heikki Linnakangas
2013-01-14 00:39:20 +01:00
|
|
|
* pg_unreachable() so that the compiler gets the point.
|
2007-05-04 04:01:02 +02:00
|
|
|
*/
|
|
|
|
#ifdef __GNUC__
|
2004-07-31 02:45:57 +02:00
|
|
|
#define PG_RE_THROW() \
|
2007-05-02 17:32:42 +02:00
|
|
|
pg_re_throw()
|
2007-05-04 04:01:02 +02:00
|
|
|
#else
|
|
|
|
#define PG_RE_THROW() \
|
Improve handling of ereport(ERROR) and elog(ERROR).
In commit 71450d7fd6c7cf7b3e38ac56e363bff6a681973c, we added code to inform
suitably-intelligent compilers that ereport() doesn't return if the elevel
is ERROR or higher. This patch extends that to elog(), and also fixes a
double-evaluation hazard that the previous commit created in ereport(),
as well as reducing the emitted code size.
The elog() improvement requires the compiler to support __VA_ARGS__, which
should be available in just about anything nowadays since it's required by
C99. But our minimum language baseline is still C89, so add a configure
test for that.
The previous commit assumed that ereport's elevel could be evaluated twice,
which isn't terribly safe --- there are already counterexamples in xlog.c.
On compilers that have __builtin_constant_p, we can use that to protect the
second test, since there's no possible optimization gain if the compiler
doesn't know the value of elevel. Otherwise, use a local variable inside
the macros to prevent double evaluation. The local-variable solution is
inferior because (a) it leads to useless code being emitted when elevel
isn't constant, and (b) it increases the optimization level needed for the
compiler to recognize that subsequent code is unreachable. But it seems
better than not teaching non-gcc compilers about unreachability at all.
Lastly, if the compiler has __builtin_unreachable(), we can use that
instead of abort(), resulting in a noticeable code savings since no
function call is actually emitted. However, it seems wise to do this only
in non-assert builds. In an assert build, continue to use abort(), so that
the behavior will be predictable and debuggable if the "impossible"
happens.
These changes involve making the ereport and elog macros emit do-while
statement blocks not just expressions, which forces small changes in
a few call sites.
Andres Freund, Tom Lane, Heikki Linnakangas
2013-01-14 00:39:20 +01:00
|
|
|
(pg_re_throw(), pg_unreachable())
|
2007-05-04 04:01:02 +02:00
|
|
|
#endif
|
2004-07-31 02:45:57 +02:00
|
|
|
|
2007-07-25 14:22:54 +02:00
|
|
|
extern PGDLLIMPORT sigjmp_buf *PG_exception_stack;
|
2004-07-31 02:45:57 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* Stuff that error handlers might want to use */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ErrorData holds the data accumulated during any one ereport() cycle.
|
|
|
|
* Any non-NULL pointers must point to palloc'd data.
|
|
|
|
* (The const pointers are an exception; we assume they point at non-freeable
|
|
|
|
* constant strings.)
|
|
|
|
*/
|
|
|
|
typedef struct ErrorData
|
|
|
|
{
|
|
|
|
int elevel; /* error level */
|
|
|
|
bool output_to_server; /* will report to server log? */
|
|
|
|
bool output_to_client; /* will report to client? */
|
|
|
|
bool show_funcname; /* true to force funcname inclusion */
|
2007-03-03 00:37:23 +01:00
|
|
|
bool hide_stmt; /* true to prevent STATEMENT: inclusion */
|
2004-07-31 02:45:57 +02:00
|
|
|
const char *filename; /* __FILE__ of ereport() call */
|
|
|
|
int lineno; /* __LINE__ of ereport() call */
|
|
|
|
const char *funcname; /* __func__ of ereport() call */
|
2008-10-10 00:22:31 +02:00
|
|
|
const char *domain; /* message domain */
|
2013-05-29 22:58:43 +02:00
|
|
|
const char *context_domain; /* message domain for context message */
|
2004-07-31 02:45:57 +02:00
|
|
|
int sqlerrcode; /* encoded ERRSTATE */
|
|
|
|
char *message; /* primary error message */
|
|
|
|
char *detail; /* detail error message */
|
2008-03-24 19:08:47 +01:00
|
|
|
char *detail_log; /* detail error message for server log only */
|
2004-07-31 02:45:57 +02:00
|
|
|
char *hint; /* hint message */
|
|
|
|
char *context; /* context message */
|
Provide database object names as separate fields in error messages.
This patch addresses the problem that applications currently have to
extract object names from possibly-localized textual error messages,
if they want to know for example which index caused a UNIQUE_VIOLATION
failure. It adds new error message fields to the wire protocol, which
can carry the name of a table, table column, data type, or constraint
associated with the error. (Since the protocol spec has always instructed
clients to ignore unrecognized field types, this should not create any
compatibility problem.)
Support for providing these new fields has been added to just a limited set
of error reports (mainly, those in the "integrity constraint violation"
SQLSTATE class), but we will doubtless add them to more calls in future.
Pavel Stehule, reviewed and extensively revised by Peter Geoghegan, with
additional hacking by Tom Lane.
2013-01-29 23:06:26 +01:00
|
|
|
char *schema_name; /* name of schema */
|
|
|
|
char *table_name; /* name of table */
|
|
|
|
char *column_name; /* name of column */
|
|
|
|
char *datatype_name; /* name of datatype */
|
|
|
|
char *constraint_name; /* name of constraint */
|
2004-07-31 02:45:57 +02:00
|
|
|
int cursorpos; /* cursor index into query string */
|
|
|
|
int internalpos; /* cursor index into internalquery */
|
|
|
|
char *internalquery; /* text of internally-generated query */
|
|
|
|
int saved_errno; /* errno at entry */
|
2013-08-01 07:07:20 +02:00
|
|
|
|
|
|
|
/* context containing associated non-constant strings */
|
|
|
|
struct MemoryContextData *assoc_context;
|
2004-07-31 02:45:57 +02:00
|
|
|
} ErrorData;
|
|
|
|
|
|
|
|
extern void EmitErrorReport(void);
|
|
|
|
extern ErrorData *CopyErrorData(void);
|
|
|
|
extern void FreeErrorData(ErrorData *edata);
|
|
|
|
extern void FlushErrorState(void);
|
2012-04-30 19:22:28 +02:00
|
|
|
extern void ReThrowError(ErrorData *edata) __attribute__((noreturn));
|
2007-05-04 04:01:02 +02:00
|
|
|
extern void pg_re_throw(void) __attribute__((noreturn));
|
2004-07-31 02:45:57 +02:00
|
|
|
|
2013-07-25 00:53:27 +02:00
|
|
|
extern char *GetErrorContextStack(void);
|
|
|
|
|
2012-03-06 21:35:41 +01:00
|
|
|
/* Hook for intercepting messages before they are sent to the server log */
|
|
|
|
typedef void (*emit_log_hook_type) (ErrorData *edata);
|
|
|
|
extern PGDLLIMPORT emit_log_hook_type emit_log_hook;
|
|
|
|
|
2004-07-31 02:45:57 +02:00
|
|
|
|
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 */
|
2011-04-10 17:42:00 +02:00
|
|
|
} PGErrorVerbosity;
|
2003-06-30 18:47:02 +02:00
|
|
|
|
2008-03-10 13:55:13 +01:00
|
|
|
extern int Log_error_verbosity;
|
2004-03-09 05:43:07 +01:00
|
|
|
extern char *Log_line_prefix;
|
2004-08-29 07:07:03 +02:00
|
|
|
extern int Log_destination;
|
2013-08-13 21:24:52 +02:00
|
|
|
extern char *Log_destination_string;
|
2003-08-04 02:43:34 +02:00
|
|
|
|
2004-04-05 05:02:11 +02:00
|
|
|
/* Log destination bitmap */
|
2004-08-29 07:07:03 +02:00
|
|
|
#define LOG_DESTINATION_STDERR 1
|
|
|
|
#define LOG_DESTINATION_SYSLOG 2
|
2004-04-05 05:02:11 +02:00
|
|
|
#define LOG_DESTINATION_EVENTLOG 4
|
2007-11-15 22:14:46 +01:00
|
|
|
#define LOG_DESTINATION_CSVLOG 8
|
2003-04-24 23:16:45 +02:00
|
|
|
|
|
|
|
/* Other exported functions */
|
|
|
|
extern void DebugFileOpen(void);
|
2005-06-10 18:23:11 +02:00
|
|
|
extern char *unpack_sql_state(int sql_state);
|
2008-10-27 20:37:22 +01:00
|
|
|
extern bool in_error_recursion_trouble(void);
|
2005-10-15 04:49:52 +02:00
|
|
|
|
2005-10-14 22:53:56 +02:00
|
|
|
#ifdef HAVE_SYSLOG
|
|
|
|
extern void set_syslog_parameters(const char *ident, int facility);
|
|
|
|
#endif
|
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
|
|
|
|
2004-06-24 23:03:42 +02:00
|
|
|
/*
|
|
|
|
* Write errors to stderr (or by equal means when stderr is
|
|
|
|
* not available). Used before ereport/elog can be used
|
|
|
|
* safely (memory context, GUC load etc)
|
|
|
|
*/
|
2004-08-29 07:07:03 +02:00
|
|
|
extern void
|
|
|
|
write_stderr(const char *fmt,...)
|
2004-06-24 23:03:42 +02:00
|
|
|
/* This extension allows gcc to check the format string for consistency with
|
|
|
|
the supplied arguments. */
|
2011-04-28 16:56:14 +02:00
|
|
|
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
|
2004-06-24 23:03:42 +02:00
|
|
|
|
2001-11-05 18:46:40 +01:00
|
|
|
#endif /* ELOG_H */
|