28 #define LOG_SERVER_ONLY 16 30 #define COMMERROR LOG_SERVER_ONLY 43 #define WARNING_CLIENT_ONLY 20 59 #define PGSIXBIT(ch) (((ch) - '0') & 0x3F) 60 #define PGUNSIXBIT(val) (((val) & 0x3F) + '0') 62 #define MAKE_SQLSTATE(ch1,ch2,ch3,ch4,ch5) \ 63 (PGSIXBIT(ch1) + (PGSIXBIT(ch2) << 6) + (PGSIXBIT(ch3) << 12) + \ 64 (PGSIXBIT(ch4) << 18) + (PGSIXBIT(ch5) << 24)) 67 #define ERRCODE_TO_CATEGORY(ec) ((ec) & ((1 << 12) - 1)) 68 #define ERRCODE_IS_CATEGORY(ec) (((ec) & ~((1 << 12) - 1)) == 0) 71 #include "utils/errcodes.h" 82 #if defined(errno) && defined(__linux__) 83 #define pg_prevent_errno_in_scope() int __errno_location pg_attribute_unused() 84 #elif defined(errno) && (defined(__darwin__) || defined(__freebsd__)) 85 #define pg_prevent_errno_in_scope() int __error pg_attribute_unused() 87 #define pg_prevent_errno_in_scope() 132 #ifdef HAVE__BUILTIN_CONSTANT_P 133 #define ereport_domain(elevel, domain, ...) \ 135 pg_prevent_errno_in_scope(); \ 136 if (__builtin_constant_p(elevel) && (elevel) >= ERROR ? \ 137 errstart_cold(elevel, domain) : \ 138 errstart(elevel, domain)) \ 139 __VA_ARGS__, errfinish(__FILE__, __LINE__, PG_FUNCNAME_MACRO); \ 140 if (__builtin_constant_p(elevel) && (elevel) >= ERROR) \ 144 #define ereport_domain(elevel, domain, ...) \ 146 const int elevel_ = (elevel); \ 147 pg_prevent_errno_in_scope(); \ 148 if (errstart(elevel_, domain)) \ 149 __VA_ARGS__, errfinish(__FILE__, __LINE__, PG_FUNCNAME_MACRO); \ 150 if (elevel_ >= ERROR) \ 155 #define ereport(elevel, ...) \ 156 ereport_domain(elevel, TEXTDOMAIN, __VA_ARGS__) 158 #define TEXTDOMAIN NULL 166 extern int errcode(
int sqlerrcode);
174 extern
int errmsg_plural(const
char *fmt_singular, const
char *fmt_plural,
175 unsigned long n,...) pg_attribute_printf(1, 4) pg_attribute_printf(2, 4);
177 extern
int errdetail(const
char *fmt,...) pg_attribute_printf(1, 2);
180 extern
int errdetail_log(const
char *fmt,...) pg_attribute_printf(1, 2);
183 const
char *fmt_plural,
184 unsigned long n,...) pg_attribute_printf(1, 4) pg_attribute_printf(2, 4);
186 extern
int errdetail_plural(const
char *fmt_singular, const
char *fmt_plural,
187 unsigned long n,...) pg_attribute_printf(1, 4) pg_attribute_printf(2, 4);
189 extern
int errhint(const
char *fmt,...) pg_attribute_printf(1, 2);
199 #define errcontext set_errcontext_domain(TEXTDOMAIN), errcontext_msg 203 extern int errcontext_msg(
const char *fmt,...) pg_attribute_printf(1, 2);
228 #define elog(elevel, ...) \ 229 ereport(elevel, errmsg_internal(__VA_ARGS__)) 311 sigjmp_buf *_save_exception_stack = PG_exception_stack; \ 312 ErrorContextCallback *_save_context_stack = error_context_stack; \ 313 sigjmp_buf _local_sigjmp_buf; \ 314 bool _do_rethrow = false; \ 315 if (sigsetjmp(_local_sigjmp_buf, 0) == 0) \ 317 PG_exception_stack = &_local_sigjmp_buf 323 PG_exception_stack = _save_exception_stack; \ 324 error_context_stack = _save_context_stack 326 #define PG_FINALLY() \ 329 _do_rethrow = true; \ 331 PG_exception_stack = _save_exception_stack; \ 332 error_context_stack = _save_context_stack 334 #define PG_END_TRY() \ 338 PG_exception_stack = _save_exception_stack; \ 339 error_context_stack = _save_context_stack; \ 346 #ifdef HAVE_PG_ATTRIBUTE_NORETURN 347 #define PG_RE_THROW() \ 350 #define PG_RE_THROW() \ 351 (pg_re_throw(), pg_unreachable()) 432 #define LOG_DESTINATION_STDERR 1 433 #define LOG_DESTINATION_SYSLOG 2 434 #define LOG_DESTINATION_EVENTLOG 4 435 #define LOG_DESTINATION_CSVLOG 8 443 extern void set_syslog_parameters(
const char *
ident,
int facility);
451 extern void write_stderr(
const char *fmt,...) pg_attribute_printf(1, 2);
#define pg_attribute_noreturn()
#define pg_attribute_cold
void pre_format_elog_string(int errnumber, const char *domain)
int errcode_for_file_access(void)
int errposition(int cursorpos)
char * format_elog_string(const char *fmt,...) pg_attribute_printf(1
void ReThrowError(ErrorData *edata) pg_attribute_noreturn()
ErrorData * CopyErrorData(void)
int int int pg_attribute_printf(2, 4)
PGDLLIMPORT sigjmp_buf * PG_exception_stack
int int errmsg_internal(const char *fmt,...) pg_attribute_printf(1
int int errhidestmt(bool hide_stmt)
void FreeErrorData(ErrorData *edata)
char struct ErrorContextCallback ErrorContextCallback
void errfinish(const char *filename, int lineno, const char *funcname)
struct ErrorContextCallback * previous
int int int errmsg_plural(const char *fmt_singular, const char *fmt_plural, unsigned long n,...) pg_attribute_printf(1
const char * context_domain
int errhidecontext(bool hide_ctx)
bool syslog_sequence_numbers
char * GetErrorContextStack(void)
int errdetail_plural(const char *fmt_singular, const char *fmt_plural, unsigned long n,...) pg_attribute_printf(1
int errcode_for_socket_access(void)
int set_errcontext_domain(const char *domain)
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)
int internalerrquery(const char *query)
pg_attribute_cold bool errstart_cold(int elevel, const char *domain)
void ThrowErrorData(ErrorData *edata)
int internalerrposition(int cursorpos)
void EmitErrorReport(void)
int int errdetail_internal(const char *fmt,...) pg_attribute_printf(1
PGDLLIMPORT emit_log_hook_type emit_log_hook
int errmsg(const char *fmt,...) pg_attribute_printf(1
void(* emit_log_hook_type)(ErrorData *edata)
bool message_level_is_interesting(int elevel)
int err_generic_string(int field, const char *str)
int getinternalerrposition(void)
bool errstart(int elevel, const char *domain)
int errcontext_msg(const char *fmt,...) pg_attribute_printf(1
struct MemoryContextData * assoc_context
int errhint(const char *fmt,...) pg_attribute_printf(1
int int int errdetail_log(const char *fmt,...) pg_attribute_printf(1
bool in_error_recursion_trouble(void)
void pg_re_throw(void) pg_attribute_noreturn()
void write_stderr(const char *fmt,...) pg_attribute_printf(1
bool syslog_split_messages
int errfunction(const char *funcname)
void FlushErrorState(void)
int errdetail(const char *fmt,...) pg_attribute_printf(1
char * Log_destination_string
char * unpack_sql_state(int sql_state)
int int int int errdetail_log_plural(const char *fmt_singular, const char *fmt_plural, unsigned long n,...) pg_attribute_printf(1
PGDLLIMPORT ErrorContextCallback * error_context_stack
struct ErrorData ErrorData
int errcode(int sqlerrcode)