PostgreSQL Source Code  git master
elog.h File Reference
#include <setjmp.h>
#include "utils/errcodes.h"
Include dependency graph for elog.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ErrorContextCallback
 
struct  ErrorData
 

Macros

#define DEBUG5
 
#define DEBUG4   11
 
#define DEBUG3   12
 
#define DEBUG2   13
 
#define DEBUG1   14 /* used by GUC debug_* variables */
 
#define LOG
 
#define LOG_SERVER_ONLY
 
#define COMMERROR
 
#define INFO
 
#define NOTICE
 
#define WARNING
 
#define PGWARNING   19 /* Must equal WARNING; see NOTE below. */
 
#define WARNING_CLIENT_ONLY
 
#define ERROR
 
#define PGERROR   21 /* Must equal ERROR; see NOTE below. */
 
#define FATAL   22 /* fatal error - abort process */
 
#define PANIC   23 /* take down the other backends with me */
 
#define PGSIXBIT(ch)   (((ch) - '0') & 0x3F)
 
#define PGUNSIXBIT(val)   (((val) & 0x3F) + '0')
 
#define MAKE_SQLSTATE(ch1, ch2, ch3, ch4, ch5)
 
#define ERRCODE_TO_CATEGORY(ec)   ((ec) & ((1 << 12) - 1))
 
#define ERRCODE_IS_CATEGORY(ec)   (((ec) & ~((1 << 12) - 1)) == 0)
 
#define pg_prevent_errno_in_scope()
 
#define ereport_domain(elevel, domain, ...)
 
#define ereport(elevel, ...)    ereport_domain(elevel, TEXTDOMAIN, __VA_ARGS__)
 
#define TEXTDOMAIN   NULL
 
#define errcontext   set_errcontext_domain(TEXTDOMAIN), errcontext_msg
 
#define elog(elevel, ...)    ereport(elevel, errmsg_internal(__VA_ARGS__))
 
#define PG_TRY()
 
#define PG_CATCH()
 
#define PG_FINALLY()
 
#define PG_END_TRY()
 
#define PG_RE_THROW()    (pg_re_throw(), pg_unreachable())
 
#define LOG_DESTINATION_STDERR   1
 
#define LOG_DESTINATION_SYSLOG   2
 
#define LOG_DESTINATION_EVENTLOG   4
 
#define LOG_DESTINATION_CSVLOG   8
 
#define LOG_DESTINATION_JSONLOG   16
 

Typedefs

typedef char struct ErrorContextCallback ErrorContextCallback
 
typedef struct ErrorData ErrorData
 
typedef void(* emit_log_hook_type) (ErrorData *edata)
 

Enumerations

enum  PGErrorVerbosity { PGERROR_TERSE , PGERROR_DEFAULT , PGERROR_VERBOSE }
 

Functions

bool message_level_is_interesting (int elevel)
 
bool errstart (int elevel, const char *domain)
 
pg_attribute_cold bool errstart_cold (int elevel, const char *domain)
 
void errfinish (const char *filename, int lineno, const char *funcname)
 
int errcode (int sqlerrcode)
 
int errcode_for_file_access (void)
 
int errcode_for_socket_access (void)
 
int errmsg (const char *fmt,...) pg_attribute_printf(1
 
int int errmsg_internal (const char *fmt,...) pg_attribute_printf(1
 
int int int errmsg_plural (const char *fmt_singular, const char *fmt_plural, unsigned long n,...) pg_attribute_printf(1
 
int int int pg_attribute_printf (2, 4)
 
int errdetail (const char *fmt,...) pg_attribute_printf(1
 
int int errdetail_internal (const char *fmt,...) pg_attribute_printf(1
 
int int int errdetail_log (const char *fmt,...) pg_attribute_printf(1
 
int int int int errdetail_log_plural (const char *fmt_singular, const char *fmt_plural, unsigned long n,...) pg_attribute_printf(1
 
int errdetail_plural (const char *fmt_singular, const char *fmt_plural, unsigned long n,...) pg_attribute_printf(1
 
int errhint (const char *fmt,...) pg_attribute_printf(1
 
int int errhint_plural (const char *fmt_singular, const char *fmt_plural, unsigned long n,...) pg_attribute_printf(1
 
int set_errcontext_domain (const char *domain)
 
int errcontext_msg (const char *fmt,...) pg_attribute_printf(1
 
int int errhidestmt (bool hide_stmt)
 
int errhidecontext (bool hide_ctx)
 
int errbacktrace (void)
 
int errposition (int cursorpos)
 
int internalerrposition (int cursorpos)
 
int internalerrquery (const char *query)
 
int err_generic_string (int field, const char *str)
 
int geterrcode (void)
 
int geterrposition (void)
 
int getinternalerrposition (void)
 
void pre_format_elog_string (int errnumber, const char *domain)
 
char * format_elog_string (const char *fmt,...) pg_attribute_printf(1
 
void EmitErrorReport (void)
 
ErrorDataCopyErrorData (void)
 
void FreeErrorData (ErrorData *edata)
 
void FlushErrorState (void)
 
void ReThrowError (ErrorData *edata) pg_attribute_noreturn()
 
void ThrowErrorData (ErrorData *edata)
 
void pg_re_throw (void) pg_attribute_noreturn()
 
char * GetErrorContextStack (void)
 
void DebugFileOpen (void)
 
char * unpack_sql_state (int sql_state)
 
bool in_error_recursion_trouble (void)
 
void reset_formatted_start_time (void)
 
char * get_formatted_start_time (void)
 
char * get_formatted_log_time (void)
 
const char * get_backend_type_for_log (void)
 
bool check_log_of_query (ErrorData *edata)
 
const char * error_severity (int elevel)
 
void write_pipe_chunks (char *data, int len, int dest)
 
void write_csvlog (ErrorData *edata)
 
void write_jsonlog (ErrorData *edata)
 
void write_stderr (const char *fmt,...) pg_attribute_printf(1
 

Variables

PGDLLIMPORT ErrorContextCallbackerror_context_stack
 
PGDLLIMPORT sigjmp_buf * PG_exception_stack
 
PGDLLIMPORT emit_log_hook_type emit_log_hook
 
PGDLLIMPORT int Log_error_verbosity
 
PGDLLIMPORT char * Log_line_prefix
 
PGDLLIMPORT int Log_destination
 
PGDLLIMPORT char * Log_destination_string
 
PGDLLIMPORT bool syslog_sequence_numbers
 
PGDLLIMPORT bool syslog_split_messages
 

Macro Definition Documentation

◆ COMMERROR

#define COMMERROR
Value:
LOG_SERVER_ONLY /* Client communication problems; same as
* LOG for server reporting, but never
* sent to client. */
#define LOG_SERVER_ONLY
Definition: elog.h:26

Definition at line 27 of file elog.h.

◆ DEBUG1

#define DEBUG1   14 /* used by GUC debug_* variables */

Definition at line 24 of file elog.h.

◆ DEBUG2

#define DEBUG2   13

Definition at line 23 of file elog.h.

◆ DEBUG3

#define DEBUG3   12

Definition at line 22 of file elog.h.

◆ DEBUG4

#define DEBUG4   11

Definition at line 21 of file elog.h.

◆ DEBUG5

#define DEBUG5
Value:
10 /* Debugging messages, in categories of
* decreasing detail. */

Definition at line 20 of file elog.h.

◆ elog

#define elog (   elevel,
  ... 
)     ereport(elevel, errmsg_internal(__VA_ARGS__))

Definition at line 218 of file elog.h.

◆ ereport

#define ereport (   elevel,
  ... 
)     ereport_domain(elevel, TEXTDOMAIN, __VA_ARGS__)

Definition at line 143 of file elog.h.

◆ ereport_domain

#define ereport_domain (   elevel,
  domain,
  ... 
)
Value:
do { \
const int elevel_ = (elevel); \
pg_prevent_errno_in_scope(); \
if (errstart(elevel_, domain)) \
__VA_ARGS__, errfinish(__FILE__, __LINE__, PG_FUNCNAME_MACRO); \
if (elevel_ >= ERROR) \
pg_unreachable(); \
} while(0)
#define PG_FUNCNAME_MACRO
Definition: c.h:370
bool errstart(int elevel, const char *domain)
Definition: elog.c:335
#define ERROR
Definition: elog.h:33
void errfinish(const char *filename, int lineno, const char *funcname)
Definition: elog.c:508

Definition at line 132 of file elog.h.

◆ ERRCODE_IS_CATEGORY

#define ERRCODE_IS_CATEGORY (   ec)    (((ec) & ~((1 << 12) - 1)) == 0)

Definition at line 56 of file elog.h.

◆ ERRCODE_TO_CATEGORY

#define ERRCODE_TO_CATEGORY (   ec)    ((ec) & ((1 << 12) - 1))

Definition at line 55 of file elog.h.

◆ errcontext

#define errcontext   set_errcontext_domain(TEXTDOMAIN), errcontext_msg

Definition at line 190 of file elog.h.

◆ ERROR

#define ERROR
Value:
21 /* user error - abort transaction; return to
* known state */

Definition at line 33 of file elog.h.

◆ FATAL

#define FATAL   22 /* fatal error - abort process */

Definition at line 35 of file elog.h.

◆ INFO

#define INFO
Value:
17 /* Messages specifically requested by user (eg
* VACUUM VERBOSE output); always sent to
* client regardless of client_min_messages,
* but by default not sent to server log. */

Definition at line 28 of file elog.h.

◆ LOG

#define LOG
Value:
15 /* Server operational messages; sent only to
* server log by default. */

Definition at line 25 of file elog.h.

◆ LOG_DESTINATION_CSVLOG

#define LOG_DESTINATION_CSVLOG   8

Definition at line 424 of file elog.h.

◆ LOG_DESTINATION_EVENTLOG

#define LOG_DESTINATION_EVENTLOG   4

Definition at line 423 of file elog.h.

◆ LOG_DESTINATION_JSONLOG

#define LOG_DESTINATION_JSONLOG   16

Definition at line 425 of file elog.h.

◆ LOG_DESTINATION_STDERR

#define LOG_DESTINATION_STDERR   1

Definition at line 421 of file elog.h.

◆ LOG_DESTINATION_SYSLOG

#define LOG_DESTINATION_SYSLOG   2

Definition at line 422 of file elog.h.

◆ LOG_SERVER_ONLY

#define LOG_SERVER_ONLY
Value:
16 /* Same as LOG for server reporting, but never
* sent to client. */

Definition at line 26 of file elog.h.

◆ MAKE_SQLSTATE

#define MAKE_SQLSTATE (   ch1,
  ch2,
  ch3,
  ch4,
  ch5 
)
Value:
(PGSIXBIT(ch1) + (PGSIXBIT(ch2) << 6) + (PGSIXBIT(ch3) << 12) + \
(PGSIXBIT(ch4) << 18) + (PGSIXBIT(ch5) << 24))
#define PGSIXBIT(ch)
Definition: elog.h:47

Definition at line 50 of file elog.h.

◆ NOTICE

#define NOTICE
Value:
18 /* Helpful messages to users about query
* operation; sent to client and not to server
* log by default. */

Definition at line 29 of file elog.h.

◆ PANIC

#define PANIC   23 /* take down the other backends with me */

Definition at line 36 of file elog.h.

◆ PG_CATCH

#define PG_CATCH ( )
Value:
} \
else \
{ \
PG_exception_stack = _save_exception_stack; \
error_context_stack = _save_context_stack

Definition at line 309 of file elog.h.

◆ PG_END_TRY

#define PG_END_TRY ( )
Value:
} \
if (_do_rethrow) \
PG_RE_THROW(); \
PG_exception_stack = _save_exception_stack; \
error_context_stack = _save_context_stack; \
} while (0)

Definition at line 324 of file elog.h.

◆ PG_FINALLY

#define PG_FINALLY ( )
Value:
} \
else \
_do_rethrow = true; \
{ \
PG_exception_stack = _save_exception_stack; \
error_context_stack = _save_context_stack

Definition at line 316 of file elog.h.

◆ pg_prevent_errno_in_scope

#define pg_prevent_errno_in_scope ( )

Definition at line 75 of file elog.h.

◆ PG_RE_THROW

#define PG_RE_THROW ( )     (pg_re_throw(), pg_unreachable())

Definition at line 340 of file elog.h.

◆ PG_TRY

#define PG_TRY ( )
Value:
do { \
sigjmp_buf *_save_exception_stack = PG_exception_stack; \
ErrorContextCallback *_save_context_stack = error_context_stack; \
sigjmp_buf _local_sigjmp_buf; \
bool _do_rethrow = false; \
if (sigsetjmp(_local_sigjmp_buf, 0) == 0) \
{ \
PG_exception_stack = &_local_sigjmp_buf
PGDLLIMPORT sigjmp_buf * PG_exception_stack
Definition: elog.c:95
PGDLLIMPORT ErrorContextCallback * error_context_stack
Definition: elog.c:93

Definition at line 299 of file elog.h.

◆ PGERROR

#define PGERROR   21 /* Must equal ERROR; see NOTE below. */

Definition at line 34 of file elog.h.

◆ PGSIXBIT

#define PGSIXBIT (   ch)    (((ch) - '0') & 0x3F)

Definition at line 47 of file elog.h.

◆ PGUNSIXBIT

#define PGUNSIXBIT (   val)    (((val) & 0x3F) + '0')

Definition at line 48 of file elog.h.

◆ PGWARNING

#define PGWARNING   19 /* Must equal WARNING; see NOTE below. */

Definition at line 31 of file elog.h.

◆ TEXTDOMAIN

#define TEXTDOMAIN   NULL

Definition at line 146 of file elog.h.

◆ WARNING

#define WARNING
Value:
19 /* Warnings. NOTICE is for expected messages
* like implicit sequence creation by SERIAL.
* WARNING is for unexpected messages. */

Definition at line 30 of file elog.h.

◆ WARNING_CLIENT_ONLY

#define WARNING_CLIENT_ONLY
Value:
20 /* Warnings to be sent to client as usual, but
* never to the server log. */

Definition at line 32 of file elog.h.

Typedef Documentation

◆ emit_log_hook_type

typedef void(* emit_log_hook_type) (ErrorData *edata)

Definition at line 400 of file elog.h.

◆ ErrorContextCallback

◆ ErrorData

typedef struct ErrorData ErrorData

Enumeration Type Documentation

◆ PGErrorVerbosity

Enumerator
PGERROR_TERSE 
PGERROR_DEFAULT 
PGERROR_VERBOSE 

Definition at line 406 of file elog.h.

421 {

Function Documentation

◆ check_log_of_query()

bool check_log_of_query ( ErrorData edata)

Definition at line 2368 of file elog.c.

2369 {
2370  /* log required? */
2372  return false;
2373 
2374  /* query log wanted? */
2375  if (edata->hide_stmt)
2376  return false;
2377 
2378  /* query string available? */
2379  if (debug_query_string == NULL)
2380  return false;
2381 
2382  return true;
2383 }
static bool is_log_level_output(int elevel, int log_min_level)
Definition: elog.c:194
int log_min_error_statement
Definition: guc.c:635
const char * debug_query_string
Definition: postgres.c:89
int elevel
Definition: elog.h:357
bool hide_stmt
Definition: elog.h:360

References debug_query_string, ErrorData::elevel, ErrorData::hide_stmt, is_log_level_output(), and log_min_error_statement.

Referenced by send_message_to_server_log(), write_csvlog(), and write_jsonlog().

◆ CopyErrorData()

ErrorData* CopyErrorData ( void  )

Definition at line 1555 of file elog.c.

1556 {
1558  ErrorData *newedata;
1559 
1560  /*
1561  * we don't increment recursion_depth because out-of-memory here does not
1562  * indicate a problem within the error subsystem.
1563  */
1565 
1567 
1568  /* Copy the struct itself */
1569  newedata = (ErrorData *) palloc(sizeof(ErrorData));
1570  memcpy(newedata, edata, sizeof(ErrorData));
1571 
1572  /* Make copies of separately-allocated fields */
1573  if (newedata->message)
1574  newedata->message = pstrdup(newedata->message);
1575  if (newedata->detail)
1576  newedata->detail = pstrdup(newedata->detail);
1577  if (newedata->detail_log)
1578  newedata->detail_log = pstrdup(newedata->detail_log);
1579  if (newedata->hint)
1580  newedata->hint = pstrdup(newedata->hint);
1581  if (newedata->context)
1582  newedata->context = pstrdup(newedata->context);
1583  if (newedata->backtrace)
1584  newedata->backtrace = pstrdup(newedata->backtrace);
1585  if (newedata->schema_name)
1586  newedata->schema_name = pstrdup(newedata->schema_name);
1587  if (newedata->table_name)
1588  newedata->table_name = pstrdup(newedata->table_name);
1589  if (newedata->column_name)
1590  newedata->column_name = pstrdup(newedata->column_name);
1591  if (newedata->datatype_name)
1592  newedata->datatype_name = pstrdup(newedata->datatype_name);
1593  if (newedata->constraint_name)
1594  newedata->constraint_name = pstrdup(newedata->constraint_name);
1595  if (newedata->internalquery)
1596  newedata->internalquery = pstrdup(newedata->internalquery);
1597 
1598  /* Use the calling context for string allocation */
1599  newedata->assoc_context = CurrentMemoryContext;
1600 
1601  return newedata;
1602 }
static int errordata_stack_depth
Definition: elog.c:147
#define CHECK_STACK_DEPTH()
Definition: elog.c:164
static ErrorData errordata[ERRORDATA_STACK_SIZE]
Definition: elog.c:145
Assert(fmt[strlen(fmt) - 1] !='\n')
char * pstrdup(const char *in)
Definition: mcxt.c:1305
MemoryContext CurrentMemoryContext
Definition: mcxt.c:42
MemoryContext ErrorContext
Definition: mcxt.c:49
void * palloc(Size size)
Definition: mcxt.c:1068
char * schema_name
Definition: elog.h:375
char * context
Definition: elog.h:372
char * internalquery
Definition: elog.h:382
struct MemoryContextData * assoc_context
Definition: elog.h:386
char * datatype_name
Definition: elog.h:378
char * detail
Definition: elog.h:369
char * table_name
Definition: elog.h:376
char * backtrace
Definition: elog.h:373
char * message
Definition: elog.h:368
char * detail_log
Definition: elog.h:370
char * hint
Definition: elog.h:371
char * constraint_name
Definition: elog.h:379
char * column_name
Definition: elog.h:377

References Assert(), ErrorData::assoc_context, ErrorData::backtrace, CHECK_STACK_DEPTH, ErrorData::column_name, ErrorData::constraint_name, ErrorData::context, CurrentMemoryContext, ErrorData::datatype_name, ErrorData::detail, ErrorData::detail_log, ErrorContext, errordata, errordata_stack_depth, ErrorData::hint, ErrorData::internalquery, ErrorData::message, palloc(), pstrdup(), ErrorData::schema_name, and ErrorData::table_name.

Referenced by _SPI_commit(), _SPI_rollback(), exec_stmt_block(), ExecEvalJsonExprSubtrans(), GetConnection(), initTrie(), plperl_return_next(), plperl_spi_commit(), plperl_spi_exec(), plperl_spi_exec_prepared(), plperl_spi_fetchrow(), plperl_spi_prepare(), plperl_spi_query(), plperl_spi_query_prepared(), plperl_spi_rollback(), plperl_util_elog(), pltcl_commit(), pltcl_elog(), pltcl_rollback(), pltcl_subtrans_abort(), PLy_commit(), PLy_output(), PLy_rollback(), PLy_spi_subtransaction_abort(), ReorderBufferProcessTXN(), and xml_is_document().

◆ DebugFileOpen()

void DebugFileOpen ( void  )

Definition at line 1917 of file elog.c.

1918 {
1919  int fd,
1920  istty;
1921 
1922  if (OutputFileName[0])
1923  {
1924  /*
1925  * A debug-output file name was given.
1926  *
1927  * Make sure we can write the file, and find out if it's a tty.
1928  */
1929  if ((fd = open(OutputFileName, O_CREAT | O_APPEND | O_WRONLY,
1930  0666)) < 0)
1931  ereport(FATAL,
1933  errmsg("could not open file \"%s\": %m", OutputFileName)));
1934  istty = isatty(fd);
1935  close(fd);
1936 
1937  /*
1938  * Redirect our stderr to the debug output file.
1939  */
1940  if (!freopen(OutputFileName, "a", stderr))
1941  ereport(FATAL,
1943  errmsg("could not reopen file \"%s\" as stderr: %m",
1944  OutputFileName)));
1945 
1946  /*
1947  * If the file is a tty and we're running under the postmaster, try to
1948  * send stdout there as well (if it isn't a tty then stderr will block
1949  * out stdout, so we may as well let stdout go wherever it was going
1950  * before).
1951  */
1952  if (istty && IsUnderPostmaster)
1953  if (!freopen(OutputFileName, "a", stdout))
1954  ereport(FATAL,
1956  errmsg("could not reopen file \"%s\" as stdout: %m",
1957  OutputFileName)));
1958  }
1959 }
int errcode_for_file_access(void)
Definition: elog.c:716
int errmsg(const char *fmt,...)
Definition: elog.c:904
#define FATAL
Definition: elog.h:35
#define ereport(elevel,...)
Definition: elog.h:143
bool IsUnderPostmaster
Definition: globals.c:113
char OutputFileName[MAXPGPATH]
Definition: globals.c:74
#define close(a)
Definition: win32.h:12
static int fd(const char *x, int i)
Definition: preproc-init.c:105

References close, ereport, errcode_for_file_access(), errmsg(), FATAL, fd(), IsUnderPostmaster, OutputFileName, and generate_unaccent_rules::stdout.

Referenced by BaseInit().

◆ EmitErrorReport()

void EmitErrorReport ( void  )

Definition at line 1504 of file elog.c.

1505 {
1507  MemoryContext oldcontext;
1508 
1509  recursion_depth++;
1511  oldcontext = MemoryContextSwitchTo(edata->assoc_context);
1512 
1513  /*
1514  * Call hook before sending message to log. The hook function is allowed
1515  * to turn off edata->output_to_server, so we must recheck that afterward.
1516  * Making any other change in the content of edata is not considered
1517  * supported.
1518  *
1519  * Note: the reason why the hook can only turn off output_to_server, and
1520  * not turn it on, is that it'd be unreliable: we will never get here at
1521  * all if errstart() deems the message uninteresting. A hook that could
1522  * make decisions in that direction would have to hook into errstart(),
1523  * where it would have much less information available. emit_log_hook is
1524  * intended for custom log filtering and custom log message transmission
1525  * mechanisms.
1526  *
1527  * The log hook has access to both the translated and original English
1528  * error message text, which is passed through to allow it to be used as a
1529  * message identifier. Note that the original text is not available for
1530  * detail, detail_log, hint and context text elements.
1531  */
1532  if (edata->output_to_server && emit_log_hook)
1533  (*emit_log_hook) (edata);
1534 
1535  /* Send to server log, if enabled */
1536  if (edata->output_to_server)
1538 
1539  /* Send to client, if enabled */
1540  if (edata->output_to_client)
1541  send_message_to_frontend(edata);
1542 
1543  MemoryContextSwitchTo(oldcontext);
1544  recursion_depth--;
1545 }
static void send_message_to_frontend(ErrorData *edata)
Definition: elog.c:3123
static int recursion_depth
Definition: elog.c:149
emit_log_hook_type emit_log_hook
Definition: elog.c:106
static void send_message_to_server_log(ErrorData *edata)
Definition: elog.c:2817
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:109
bool output_to_server
Definition: elog.h:358
bool output_to_client
Definition: elog.h:359

References ErrorData::assoc_context, CHECK_STACK_DEPTH, emit_log_hook, errordata, errordata_stack_depth, MemoryContextSwitchTo(), ErrorData::output_to_client, ErrorData::output_to_server, recursion_depth, send_message_to_frontend(), and send_message_to_server_log().

Referenced by AutoVacLauncherMain(), AutoVacWorkerMain(), BackgroundWriterMain(), basic_archive_file(), CheckpointerMain(), DisableSubscriptionAndExit(), do_autovacuum(), errfinish(), perform_work_item(), PostgresMain(), StartBackgroundWorker(), and WalWriterMain().

◆ err_generic_string()

int err_generic_string ( int  field,
const char *  str 
)

Definition at line 1346 of file elog.c.

1347 {
1349 
1350  /* we don't bother incrementing recursion_depth */
1352 
1353  switch (field)
1354  {
1355  case PG_DIAG_SCHEMA_NAME:
1356  set_errdata_field(edata->assoc_context, &edata->schema_name, str);
1357  break;
1358  case PG_DIAG_TABLE_NAME:
1359  set_errdata_field(edata->assoc_context, &edata->table_name, str);
1360  break;
1361  case PG_DIAG_COLUMN_NAME:
1362  set_errdata_field(edata->assoc_context, &edata->column_name, str);
1363  break;
1364  case PG_DIAG_DATATYPE_NAME:
1366  break;
1369  break;
1370  default:
1371  elog(ERROR, "unsupported ErrorData field id: %d", field);
1372  break;
1373  }
1374 
1375  return 0; /* return value does not matter */
1376 }
static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str)
Definition: elog.c:1382
#define PG_DIAG_SCHEMA_NAME
Definition: postgres_ext.h:65
#define PG_DIAG_CONSTRAINT_NAME
Definition: postgres_ext.h:69
#define PG_DIAG_DATATYPE_NAME
Definition: postgres_ext.h:68
#define PG_DIAG_TABLE_NAME
Definition: postgres_ext.h:66
#define PG_DIAG_COLUMN_NAME
Definition: postgres_ext.h:67

References ErrorData::assoc_context, CHECK_STACK_DEPTH, ErrorData::column_name, ErrorData::constraint_name, ErrorData::datatype_name, elog(), ERROR, errordata, errordata_stack_depth, PG_DIAG_COLUMN_NAME, PG_DIAG_CONSTRAINT_NAME, PG_DIAG_DATATYPE_NAME, PG_DIAG_SCHEMA_NAME, PG_DIAG_TABLE_NAME, ErrorData::schema_name, set_errdata_field(), generate_unaccent_rules::str, and ErrorData::table_name.

Referenced by errdatatype(), errdomainconstraint(), errtable(), errtablecolname(), errtableconstraint(), exec_stmt_raise(), PLy_elog_impl(), and PLy_output().

◆ errbacktrace()

int errbacktrace ( void  )

Definition at line 926 of file elog.c.

927 {
929  MemoryContext oldcontext;
930 
931  recursion_depth++;
933  oldcontext = MemoryContextSwitchTo(edata->assoc_context);
934 
935  set_backtrace(edata, 1);
936 
937  MemoryContextSwitchTo(oldcontext);
938  recursion_depth--;
939 
940  return 0;
941 }
static pg_noinline void set_backtrace(ErrorData *edata, int num_skip)
Definition: elog.c:950

References ErrorData::assoc_context, CHECK_STACK_DEPTH, errordata, errordata_stack_depth, MemoryContextSwitchTo(), recursion_depth, and set_backtrace().

◆ errcode()

int errcode ( int  sqlerrcode)

Definition at line 693 of file elog.c.

694 {
696 
697  /* we don't bother incrementing recursion_depth */
699 
700  edata->sqlerrcode = sqlerrcode;
701 
702  return 0; /* return value does not matter */
703 }
int sqlerrcode
Definition: elog.h:367

References CHECK_STACK_DEPTH, errordata, errordata_stack_depth, and ErrorData::sqlerrcode.

Referenced by _arrq_cons(), _bt_binsrch_insert(), _bt_check_third_page(), _bt_check_unique(), _bt_checkpage(), _bt_get_endpoint(), _bt_getmeta(), _bt_gettrueroot(), _bt_insert_parent(), _bt_insertonpg(), _bt_lock_subtree_parent(), _bt_mark_page_halfdead(), _bt_pagedel(), _bt_split(), _bt_unlink_halfdead_page(), _crypt_blowfish_rn(), _hash_addovflpage(), _hash_checkpage(), _hash_doinsert(), _hash_first(), _hash_init(), _hash_ovflblkno_to_bitno(), _intbig_in(), _intbig_out(), _lca(), _lt_q_regex(), _ltree_compress(), _PG_init(), _SPI_commit(), _SPI_execute_plan(), _SPI_rollback(), AbortBufferIO(), accumArrayResultArr(), aclcheck_error(), aclcheck_error_col(), aclinsert(), aclitemin(), aclparse(), aclremove(), add_json(), add_jsonb(), add_parameter_name(), add_reloption_kind(), add_size(), addCompoundAffixFlagValue(), AddEnumLabel(), addFamilyMember(), addFkRecurseReferenced(), addFkRecurseReferencing(), AddQual(), addRangeTableEntryForCTE(), addRangeTableEntryForFunction(), addRangeTableEntryForJoin(), addRangeTableEntryForSubquery(), addRangeTableEntryForTableFunc(), addRangeTableEntryForValues(), AddRelationNewConstraints(), AddRoleMems(), addTargetToSortList(), AdjustIntervalForTypmod(), AdjustTimestampForTypmodError(), advance_windowaggregate(), afterTriggerMarkEvents(), AfterTriggerSetState(), AggregateCreate(), alen_object_start(), alen_scalar(), AllocateDir(), AllocateFile(), AllocateVfd(), AllocSetContextCreateInternal(), AlterDatabase(), AlterDatabaseOwner(), AlterDatabaseRefreshColl(), AlterDomainAddConstraint(), AlterDomainDropConstraint(), AlterDomainNotNull(), AlterDomainValidateConstraint(), AlterEventTrigger(), AlterEventTriggerOwner(), AlterEventTriggerOwner_internal(), AlterEventTriggerOwner_oid(), AlterExtensionNamespace(), AlterForeignDataWrapper(), AlterForeignDataWrapperOwner(), AlterForeignDataWrapperOwner_internal(), AlterForeignDataWrapperOwner_oid(), AlterForeignServer(), AlterForeignServerOwner(), AlterForeignServerOwner_oid(), AlterFunction(), AlterObjectNamespace_internal(), AlterObjectRename_internal(), AlterOperator(), AlterOpFamily(), AlterOpFamilyAdd(), AlterOpFamilyDrop(), AlterPolicy(), AlterPublication(), AlterPublicationOptions(), AlterPublicationOwner(), AlterPublicationOwner_internal(), AlterPublicationOwner_oid(), AlterRelationNamespaceInternal(), AlterRole(), AlterRoleSet(), AlterSchemaOwner(), AlterStatistics(), AlterSubscription(), AlterSubscription_refresh(), AlterSubscriptionOwner(), AlterSubscriptionOwner_internal(), AlterSubscriptionOwner_oid(), AlterSystemSetConfigFile(), AlterTableMoveAll(), AlterTableNamespace(), AlterTableSpaceOptions(), AlterTSConfiguration(), AlterType(), AlterTypeNamespace(), AlterTypeNamespace_oid(), AlterTypeNamespaceInternal(), AlterTypeOwner(), AlterUserMapping(), analyzeCTE(), analyzeCTETargetList(), anybit_typmodin(), anychar_typmodin(), anymultirange_in(), anytime_typmod_check(), anytime_typmodin(), anytimestamp_typmod_check(), anytimestamp_typmodin(), appendElement(), appendJsonTableColumns(), appendKey(), apply_dispatch(), apply_handle_begin_prepare(), apply_handle_commit(), apply_handle_origin(), apply_handle_prepare(), apply_handle_stream_abort(), apply_handle_stream_commit(), apply_handle_stream_prepare(), apply_handle_stream_start(), apply_handle_stream_stop(), apply_typmod(), apply_typmod_special(), ApplyWorkerMain(), apw_start_database_worker(), apw_start_leader_worker(), array_agg_array_transfn(), array_agg_transfn(), array_append(), array_cat(), array_cmp(), array_contain_compare(), array_eq(), array_exec_setup(), array_fill(), array_fill_internal(), array_fill_with_lower_bounds(), array_get_slice(), array_in(), array_iterator(), array_map(), array_position_common(), array_positions(), array_prepend(), array_recv(), array_replace_internal(), array_send(), array_set_element(), array_set_element_expanded(), array_set_slice(), array_subscript_check_subscripts(), array_subscript_transform(), array_to_datum_internal(), array_to_tsvector(), ArrayCheckBounds(), ArrayCount(), ArrayGetIntegerTypmods(), ArrayGetNItems(), arrq_cons(), ascii(), ASN1_STRING_to_text(), assign_backendlist_entry(), assign_client_encoding(), assign_collations_walker(), assign_hypothetical_collations(), assign_record_type_identifier(), assignOperTypes(), assignProcTypes(), AssignTypeArrayOid(), AssignTypeMultirangeArrayOid(), AssignTypeMultirangeOid(), Async_Notify(), ATAddCheckConstraint(), ATAddForeignKeyConstraint(), AtEOSubXact_SPI(), AtEOXact_SPI(), ATExecAddColumn(), ATExecAddConstraint(), ATExecAddIdentity(), ATExecAddIndexConstraint(), ATExecAddInherit(), ATExecAddOf(), ATExecAlterColumnGenericOptions(), ATExecAlterColumnType(), ATExecAlterConstraint(), ATExecAttachPartition(), ATExecAttachPartitionIdx(), ATExecChangeOwner(), ATExecCheckNotNull(), ATExecClusterOn(), ATExecColumnDefault(), ATExecDetachPartition(), ATExecDropColumn(), ATExecDropConstraint(), ATExecDropExpression(), ATExecDropIdentity(), ATExecDropInherit(), ATExecDropNotNull(), ATExecDropOf(), ATExecGenericOptions(), ATExecReplicaIdentity(), ATExecSetCompression(), ATExecSetIdentity(), ATExecSetNotNull(), ATExecSetOptions(), ATExecSetRelOptions(), ATExecSetStatistics(), ATExecSetStorage(), ATExecValidateConstraint(), ATPrepAddColumn(), ATPrepAddInherit(), ATPrepAlterColumnType(), AtPrepare_Locks(), AtPrepare_Notify(), AtPrepare_RelationMap(), ATPrepChangePersistence(), ATPrepCmd(), ATPrepDropColumn(), ATPrepDropExpression(), ATPrepDropNotNull(), ATPrepSetNotNull(), ATPrepSetTableSpace(), ATRewriteTable(), ATRewriteTables(), ATSimplePermissions(), AtSubCommit_childXids(), attach_internal(), AttachPartitionEnsureIndexes(), auth_failed(), auth_peer(), autoinc(), autoprewarm_database_main(), autoprewarm_start_worker(), BackendStartup(), BackgroundWorkerInitializeConnection(), BackgroundWorkerInitializeConnectionByOid(), BackgroundWorkerStateChange(), BaseBackupGetTargetHandle(), BasicOpenFilePerm(), bbsink_gzip_new(), bbsink_lz4_new(), bbsink_server_archive_contents(), bbsink_server_manifest_contents(), bbsink_server_new(), bbsink_zstd_new(), be_lo_close(), be_lo_get_fragment(), be_lo_lseek(), be_lo_lseek64(), be_lo_put(), be_lo_tell(), be_lo_tell64(), be_lo_unlink(), be_tls_init(), be_tls_open_server(), be_tls_read(), be_tls_write(), before_shmem_exit(), begin_prepare_cb_wrapper(), BeginCopyFrom(), BeginCopyTo(), BeginInternalSubTransaction(), BeginTransactionBlock(), bernoulli_beginsamplescan(), bgworker_die(), binary_decode(), binary_encode(), bit(), bit_and(), bit_catenate(), bit_in(), bit_or(), bit_overlay(), bit_recv(), bitgetbit(), bitsetbit(), bitsubstring(), bittoint4(), bittoint8(), bitxor(), blvalidate(), boolin(), BootstrapModeMain(), bpchar(), bpchar_input(), bqarr_in(), bqarr_out(), brin_bloom_summary_in(), brin_bloom_summary_recv(), brin_desummarize_range(), brin_doinsert(), brin_doupdate(), brin_getinsertbuffer(), brin_metapage_info(), brin_minmax_multi_distance_interval(), brin_minmax_multi_summary_in(), brin_minmax_multi_summary_recv(), brin_page_items(), brin_page_type(), brin_revmap_data(), brin_summarize_range(), brinGetTupleForHeapBlock(), brininsert(), brinRevmapDesummarizeRange(), brinvalidate(), bt_check_every_level(), bt_check_level_from_leftmost(), bt_child_check(), bt_child_highkey_check(), bt_downlink_missing_check(), bt_index_check_internal(), bt_metap(), bt_normalize_tuple(), bt_page_items_bytea(), bt_page_items_internal(), bt_page_stats_internal(), bt_recheck_sibling_links(), bt_right_page_check_scankey(), bt_target_page_check(), bt_tuple_present_callback(), btree_index_checkable(), btree_index_mainfork_expected(), BTreeTupleGetHeapTIDCareful(), btvacuumpage(), btvalidate(), build_attrmap_by_name(), build_attrmap_by_position(), build_column_default(), build_datatype(), build_server_first_message(), build_tuplestore_recursively(), BuildDescForRelation(), buildRelationAliases(), BuildRelationExtStatistics(), bytea_overlay(), bytea_substring(), byteaGetBit(), byteaGetByte(), byteain(), byteaout(), byteaSetBit(), byteaSetByte(), calc_rank_cd(), call_bool_check_hook(), call_enum_check_hook(), call_int_check_hook(), call_pltcl_start_proc(), call_real_check_hook(), call_string_check_hook(), cannotCastJsonbValue(), cash_dist(), cash_div_cash(), cash_div_flt4(), cash_div_flt8(), cash_div_int2(), cash_div_int4(), cash_div_int8(), cash_in(), CastCreate(), changeDependenciesOn(), char2wchar(), check_acl(), check_agg_arguments(), check_agg_arguments_walker(), check_agglevels_and_constraints(), check_circularity(), check_collation_set(), check_conn_params(), check_default_partition_contents(), check_default_table_access_method(), check_default_tablespace(), check_duplicates_in_publist(), check_enable_rls(), check_encoding_locale_matches(), check_exclusion_or_unique_constraint(), check_for_column_name_collision(), check_foreign_key(), check_icu_locale(), check_ident_usermap(), check_index_is_clusterable(), check_is_member_of_role(), check_lateral_ref_ok(), check_nested_generated_walker(), check_new_partition_bound(), check_object_ownership(), check_of_type(), check_parameter_resolution_walker(), check_password(), check_primary_key(), check_publication_add_relation(), check_publication_add_schema(), check_publications(), check_relation_privileges(), check_relation_relkind(), check_relation_updatable(), check_restricted_library_name(), check_role(), check_rolespec_name(), check_safe_enum_use(), check_session_authorization(), check_simple_rowfilter_expr_walker(), check_sql_fn_retval(), check_sql_fn_statements(), check_srf_call_placement(), check_ssl_key_file_permissions(), check_stack_depth(), check_strxfrm_bug(), check_temp_tablespaces(), check_transform_function(), check_TSCurrentConfig(), check_ungrouped_columns_walker(), check_unicode_value(), check_valid_extension_name(), check_valid_version_name(), CheckAlterPublication(), CheckAttributeNamesTypes(), CheckAttributeType(), CheckCmdReplicaIdentity(), checkDataDir(), checkDomainOwner(), checkEnumOwner(), checkExprIsVarFree(), CheckForSerializableConflictIn(), CheckForSerializableConflictOut(), CheckForSerializableConflictOutNeeded(), CheckForSessionAndXactLocks(), CheckFunctionValidatorAccess(), CheckIndexCompatible(), checkInsertTargets(), checkJsonOutputFormat(), CheckLogicalDecodingRequirements(), CheckMD5Auth(), CheckMyDatabase(), checkNameSpaceConflicts(), CheckObjSchemaNotAlreadyInPublication(), CheckPredicate(), CheckPubRelationColumnList(), CheckRecoveryConflictDeadlock(), CheckRelationTableSpaceMove(), CheckRestrictedOperation(), checkRuleResultList(), CheckSASLAuth(), CheckSelectLocking(), CheckSetNamespace(), checkSharedDependencies(), CheckSlotPermissions(), CheckSlotRequirements(), checkStringLen(), CheckSubscriptionRelkind(), CheckTableNotInUse(), checkTargetlistEntrySQL92(), checkTimezoneIsUsedForCast(), CheckTransactionBlock(), CheckValidResultRel(), CheckValidRowMarkRel(), CheckVarSlotCompatibility(), checkViewTupleDesc(), checkWellFormedRecursion(), checkWellFormedRecursionWalker(), choose_hashed_setop(), chr(), cidr_abbrev(), cidr_set_masklen(), circle_in(), circle_poly(), circle_recv(), ClientAuthentication(), CloneFkReferencing(), ClosePipeFromProgram(), ClosePipeToProgram(), cluster(), cluster_rel(), coerce_record_to_complex(), coerce_to_boolean(), coerce_to_common_type(), coerce_to_specific_type_typmod(), coerceDefaultJsonExpr(), coerceJsonFuncExpr(), CollationCreate(), collectMatchBitmap(), colNameToVar(), CommandCounterIncrement(), CommentObject(), commit_prepared_cb_wrapper(), comparetup_index_btree(), compatConnectbyTupleDescs(), compatCrosstabTupleDescs(), compatible_oper(), compile_plperl_function(), compile_pltcl_function(), compileTheLexeme(), compileTheSubstitute(), complex_in(), compute_common_attribute(), compute_function_attributes(), compute_return_type(), ComputeIndexAttrs(), ComputePartitionAttrs(), ConnCreate(), connect_pg_server(), connectby_text(), connectby_text_serial(), construct_md_array(), ConversionCreate(), convert_and_check_filename(), convert_any_priv_string(), convert_column_name(), convert_function_name(), convert_type_name(), convertJsonbArray(), convertJsonbObject(), cookConstraint(), cookDefault(), copy_replication_slot(), copy_table(), CopyFrom(), CopyGetAttnums(), CopyGetData(), CopyReadAttributesCSV(), CopyReadAttributesText(), CopyReadBinaryAttribute(), CopyReadLineText(), create_ctas_nodata(), create_distinct_paths(), create_ordinary_grouping_paths(), create_tablespace_directories(), CreateAccessMethod(), CreateCast(), CreateConversionCommand(), createdb(), CreateDecodingContext(), CreateEventTrigger(), CreateExtension(), CreateExtensionInternal(), CreateForeignDataWrapper(), CreateForeignServer(), CreateFunction(), CreateInheritance(), CreateInitDecodingContext(), CreateLockFile(), createNewConnection(), CreateOpFamily(), CreatePolicy(), CreatePortal(), CreatePredicateLock(), CreateProceduralLanguage(), CreatePublication(), CreateRole(), CreateSchemaCommand(), CreateStatistics(), CreateSubscription(), CreateTableAsRelExists(), CreateTableSpace(), CreateTransform(), CreateTriggerFiringOn(), CreateUserMapping(), crosstab(), crosstab_hash(), cube_a_f8(), cube_a_f8_f8(), cube_c_f8(), cube_c_f8_f8(), cube_coord(), cube_coord_llur(), cube_recv(), cube_subset(), currval_oid(), cursor_to_xml(), cursor_to_xmlschema(), dacos(), dacosd(), dacosh(), dasin(), dasind(), datanh(), date2timestamp_opt_overflow(), date2timestamptz_opt_overflow(), date_in(), date_mi(), date_mii(), date_pli(), date_recv(), datetime_timestamp(), DateTimeParseError(), datetimetz_timestamptz(), datum_to_json(), datum_to_jsonb(), datumGetSize(), db_encoding_convert(), dblink_build_sql_delete(), dblink_build_sql_insert(), dblink_build_sql_update(), dblink_connect(), dblink_connstr_check(), dblink_exec(), dblink_fdw_validator(), dblink_fetch(), dblink_get_conn(), dblink_res_error(), dblink_security_check(), DCH_datetime_type(), DCH_from_char(), DCH_to_char(), dcos(), dcosd(), dcot(), dcotd(), DeadLockReport(), DecodeDateTime(), DecodeTimeOnly(), deconstruct_array(), DeconstructQualifiedName(), defGetBoolean(), defGetCopyHeaderChoice(), defGetInt32(), defGetInt64(), defGetNumeric(), defGetQualifiedName(), defGetString(), defGetStringList(), defGetTypeLength(), defGetTypeName(), define_custom_variable(), DefineAggregate(), DefineCollation(), DefineCompositeType(), DefineDomain(), DefineEnum(), DefineIndex(), DefineOpClass(), DefineOperator(), DefineOpFamily(), DefineQueryRewrite(), DefineRange(), DefineRelation(), DefineSavepoint(), DefineSequence(), DefineTSConfiguration(), DefineTSDictionary(), DefineTSParser(), DefineTSTemplate(), DefineType(), DefineView(), DefineVirtualRelation(), deleteConnection(), DeleteInheritsTuple(), DelRoleMems(), deserialize_deflist(), destroy_tablespace_directories(), DetermineTimeZoneAbbrevOffsetTS(), dintdict_init(), dispell_init(), div_var(), div_var_fast(), div_var_int(), dlog1(), dlog10(), do_analyze_rel(), do_compile(), do_pg_backup_start(), do_pg_backup_stop(), do_setval(), do_to_timestamp(), DoCopy(), domain_check_input(), domain_state_setup(), domainAddConstraint(), DoPortalRewind(), dpow(), DropConfigurationMapping(), DropDatabase(), dropdb(), DropErrorMsgNonExistent(), DropErrorMsgWrongType(), dropOperators(), DropOwnedObjects(), dropProcedures(), DropRole(), DropSubscription(), DropTableSpace(), dsa_allocate_extended(), dsa_attach(), dshash_create(), dsimple_init(), dsin(), dsind(), dsm_backend_startup(), dsm_create(), dsnowball_init(), dsqrt(), dsynonym_init(), dtan(), dtand(), dtoi2(), dtoi4(), dtoi8(), dummy_object_relabel(), dumptuples(), dxsyn_init(), EA_get_flat_size(), each_array_start(), each_scalar(), each_worker_jsonb(), ean2isn(), ean2string(), elements_object_start(), elements_scalar(), elements_worker_jsonb(), emit_audit_message(), EnableDisableRule(), EnableDisableTrigger(), EnableLockPagesPrivilege(), EndPrepare(), EndTransactionBlock(), enforce_generic_type_consistency(), enlargeStringInfo(), entry_reset(), enum_cmp_internal(), enum_first(), enum_in(), enum_last(), enum_out(), enum_range_all(), enum_range_bounds(), enum_recv(), enum_send(), EnumValuesCreate(), errcode_for_dynamic_shared_memory(), error_commit_ts_disabled(), error_duplicate_filter_variable(), errorConflictingDefElem(), errorMissingColumn(), errorMissingRTE(), esc_dec_len(), esc_decode(), EvalPlanQualFetchRowMark(), EvaluateParams(), exec_assign_value(), exec_bind_message(), exec_check_assignable(), exec_describe_portal_message(), exec_describe_statement_message(), exec_dynquery_with_params(), exec_eval_datum(), exec_eval_expr(), exec_execute_message(), exec_init_tuple_store(), exec_move_row_from_fields(), exec_object_restorecon(), exec_parse_message(), exec_replication_command(), exec_run_select(), exec_simple_query(), exec_stmt_assert(), exec_stmt_case(), exec_stmt_close(), exec_stmt_dynexecute(), exec_stmt_execsql(), exec_stmt_fetch(), exec_stmt_forc(), exec_stmt_foreach_a(), exec_stmt_fori(), exec_stmt_getdiag(), exec_stmt_open(), exec_stmt_raise(), exec_stmt_return(), exec_stmt_return_next(), exec_stmt_return_query(), ExecAlterDefaultPrivilegesStmt(), ExecAlterExtensionContentsStmt(), ExecAlterExtensionStmt(), ExecBRInsertTriggers(), ExecBSDeleteTriggers(), ExecBSInsertTriggers(), ExecBSTruncateTriggers(), ExecBSUpdateTriggers(), ExecBuildUpdateProjection(), ExecCallTriggerFunc(), ExecCheckIndexConstraints(), ExecCheckPlanOutput(), ExecCheckTupleVisible(), ExecConstraints(), ExecCrossPartitionUpdate(), ExecCrossPartitionUpdateForeignKey(), execCurrentOf(), ExecCustomMarkPos(), ExecCustomRestrPos(), ExecDelete(), ExecEvalArrayExpr(), ExecEvalConstraintCheck(), ExecEvalConstraintNotNull(), ExecEvalCurrentOfExpr(), ExecEvalFieldSelect(), ExecEvalJsonExpr(), ExecEvalParamExtern(), ExecEvalWholeRowVar(), ExecFindPartition(), ExecGrant_Language(), ExecGrant_Relation(), ExecGrant_Type(), ExecInitAgg(), ExecInitExprRec(), ExecInitFunc(), ExecInitMergeJoin(), ExecInitSubscriptingRef(), ExecLockRows(), ExecMakeFunctionResultSet(), ExecMakeTableFunctionResult(), ExecMergeMatched(), ExecOnConflictUpdate(), ExecOpenScanRelation(), ExecPartitionCheckEmitError(), ExecPrepareTuplestoreResult(), ExecRefreshMatView(), ExecReindex(), ExecScanSubPlan(), ExecSecLabelStmt(), ExecSetParamPlan(), ExecSetVariableStmt(), ExecUpdate(), execute_extension_script(), execute_sql_string(), executeBinaryArithmExpr(), ExecuteCallStmt(), executeDateTimeMethod(), ExecuteDoStmt(), ExecuteGrantStmt(), executeItemOptUnwrapTarget(), executeKeyValueMethod(), executeNumericItemMethod(), ExecuteQuery(), ExecuteTruncate(), executeUnaryArithmExpr(), ExecVacuum(), ExecWindowAgg(), ExecWithCheckOptions(), ExitPostmaster(), exp_var(), expand_col_privileges(), expand_vacuum_rel(), ExpandAllTables(), ExpandColumnRefStar(), expandTableLikeClause(), ExplainQuery(), ExportSnapshot(), exprType(), extract_date(), extract_variadic_args(), ExtractExtensionList(), extractModify(), FastPathGetRelationLockEntry(), fatal_llvm_error_handler(), fatal_system_new_handler(), fetch_array_arg_replace_nulls(), fetch_cursor_param_value(), fetch_finfo_record(), fetch_fp_info(), fetch_remote_table_info(), fetch_table_list(), FetchDynamicTimeZone(), FetchPreparedStatement(), file_fdw_validator(), FileWrite(), finalize_grouping_exprs_walker(), find_composite_type_dependencies(), find_expr_references_walker(), find_in_dynamic_libpath(), find_my_exec(), find_option(), find_provider(), find_typed_table_dependencies(), findDependentObjects(), findRangeCanonicalFunction(), findRangeSubOpclass(), findRangeSubtypeDiffFunction(), findTargetlistEntrySQL92(), findTypeAnalyzeFunction(), findTypeInputFunction(), findTypeOutputFunction(), findTypeReceiveFunction(), findTypeSendFunction(), findTypeSubscriptingFunction(), findTypeTypmodinFunction(), findTypeTypmodoutFunction(), finish_nodeitem(), fireRIRrules(), fixed_paramref_hook(), flatten_set_variable_args(), flattenJsonPathParseItem(), float4in(), float8_timestamptz(), float8in_internal_opt_error(), float_overflow_error(), float_underflow_error(), float_zero_divide_error(), FloatExceptionHandler(), fmgr_info_cxt_security(), fmgr_internal_validator(), fmgr_sql(), fmgr_sql_validator(), forbidden_in_wal_sender(), forkname_to_number(), free_parsestate(), FreezeMultiXactId(), from_char_parse_int_len(), from_char_seq_search(), from_char_set_int(), from_char_set_mode(), fsm_page_contents(), ftoi2(), ftoi4(), ftoi8(), func_select_candidate(), g_cube_distance(), gai_strerror(), gbtreekey_in(), gbtreekey_out(), gen_random_uuid(), generate_recursion_path(), generate_series_step_int4(), generate_series_step_int8(), generate_series_step_numeric(), generate_series_timestamp(), generate_series_timestamptz(), generateClonedIndexStmt(), GenerationContextCreate(), Generic_Text_IC_like(), GenericMatchText(), get_am_type_oid(), get_cached_rowtype(), get_cast_oid(), get_collation_oid(), get_connect_string(), get_controlfile(), get_conversion_oid(), get_crosstab_tuplestore(), get_database_oid(), get_domain_constraint_oid(), get_event_trigger_oid(), get_expr_result_tupdesc(), get_extension_oid(), get_fn_opclass_options(), get_foreign_data_wrapper_oid(), get_foreign_server_oid(), get_func_expr(), get_hex(), get_language_oid(), get_multirange_io_data(), get_namespace_oid(), get_object_address(), get_object_address_attrdef(), get_object_address_attribute(), get_object_address_defacl(), get_object_address_opf_member(), get_object_address_publication_rel(), get_object_address_publication_schema(), get_object_address_relobject(), get_object_address_type(), get_object_address_usermapping(), get_other_operator(), get_page_from_raw(), get_publication_oid(), get_range_io_data(), get_raw_page_1_9(), get_raw_page_fork_1_9(), get_raw_page_internal(), get_record_type_from_argument(), get_record_type_from_query(), get_relation_by_qualified_name(), get_relation_constraint_attnos(), get_relation_constraint_oid(), get_relation_info(), get_relation_policy_oid(), get_required_extension(), get_rewrite_oid(), get_role_oid(), get_rolespec_oid(), get_rolespec_tuple(), get_rte_attribute_is_dropped(), get_sort_group_operators(), get_sql_insert(), get_sql_update(), get_statistics_object_oid(), get_subscription_oid(), get_tablespace_oid(), get_th(), get_transform_oid(), get_trigger_oid(), get_ts_config_oid(), get_ts_dict_oid(), get_ts_parser_func(), get_ts_parser_oid(), get_ts_template_func(), get_ts_template_oid(), get_tsearch_config_filename(), get_tuple_of_interest(), get_windowfunc_expr_helper(), getAffixFlagSet(), getArrayIndex(), GetAttributeCompression(), GetColumnDefCollation(), GetConfigOption(), GetConfigOptionByName(), GetConfigOptionResetString(), GetConflictingVirtualXIDs(), GetCurrentTimeUsec(), getdatafield(), GetDefaultOpClass(), GetDefaultTablespace(), GetExtensibleNodeEntry(), GetFdwRoutineByServerId(), getid(), GetIndexAmRoutineByAmId(), getJsonPathVariable(), getJsonPathVariableFromJsonb(), GetMultiXactIdMembers(), GetNewMultiXactId(), GetNewTransactionId(), getNextFlagFromString(), GetRunningTransactionData(), GetSafeSnapshot(), GetSerializableTransactionSnapshot(), GetSerializableTransactionSnapshotInt(), GetSnapshotData(), gettoken_query(), gettoken_query_standard(), gettoken_tsvector(), getTokenTypes(), GetTupleForTrigger(), getTypeBinaryInputInfo(), getTypeBinaryOutputInfo(), getTypeInputInfo(), getTypeOutputInfo(), GetUserMapping(), GetUserNameFromId(), getWeights(), gin_clean_pending_list(), gin_leafpage_items(), gin_metapage_info(), gin_page_opaque_info(), ginadjustmembers(), ginCombineData(), GinFormTuple(), ginvalidate(), gist_page_items(), gist_page_items_bytea(), gist_page_opaque_info(), gistadjustmembers(), gistcheckpage(), gistSplit(), gistUserPicksplit(), gistvalidate(), GrantRole(), grouping_planner(), gtsvectorin(), guc_malloc(), guc_realloc(), guc_strdup(), handle_streamed_transaction(), HandleConcurrentAbort(), HandleFunctionRequest(), HandleParallelMessages(), has_sequence_privilege_id(), has_sequence_privilege_id_id(), has_sequence_privilege_id_name(), has_sequence_privilege_name(), has_sequence_privilege_name_id(), has_sequence_privilege_name_name(), hash_array(), hash_array_extended(), hash_array_start(), hash_bitmap_info(), hash_create(), hash_metapage_info(), hash_multirange(), hash_multirange_extended(), hash_page_items(), hash_page_stats(), hash_page_type(), hash_range(), hash_range_extended(), hash_record(), hash_record_extended(), hash_scalar(), hash_search_with_hash_value(), hashbpchar(), hashbpcharextended(), hashtext(), hashtextextended(), hashvalidate(), heap_acquire_tuplock(), heap_create(), heap_create_with_catalog(), heap_delete(), heap_fetch_toast_slice(), heap_force_common(), heap_form_minimal_tuple(), heap_form_tuple(), heap_getnext(), heap_inplace_update(), heap_lock_tuple(), heap_page_items(), heap_prepare_freeze_tuple(), heap_prepare_insert(), heap_truncate_check_FKs(), heap_tuple_infomask_flags(), heap_update(), heapam_index_build_range_scan(), heapam_index_validate_scan(), heapam_tuple_lock(), hex2_to_uchar(), hex_decode(), hlparsetext(), HoldPinnedPortals(), hstore_from_array(), hstore_from_arrays(), hstore_populate_record(), hstore_recv(), hstore_subscript_assign(), hstore_subscript_transform(), hstore_to_plpython(), hstoreArrayToPairs(), hstoreCheckKeyLen(), hstoreCheckValLen(), i4tochar(), i4toi2(), i8tooid(), identify_update_path(), ImportForeignSchema(), ImportSnapshot(), in_range_float4_float8(), in_range_float8_float8(), in_range_int2_int4(), in_range_int4_int4(), in_range_int4_int8(), in_range_int8_int8(), in_range_interval_interval(), in_range_numeric_numeric(), in_range_time_interval(), in_range_timestamp_interval(), in_range_timestamptz_interval(), in_range_timetz_interval(), index_check_primary_key(), index_concurrently_create_copy(), index_constraint_create(), index_create(), index_delete_check_htid(), index_drop(), index_form_tuple(), index_opclass_options(), index_open(), IndexOnlyNext(), inet_abbrev(), inet_merge(), inet_set_masklen(), inetand(), inetmi(), inetor(), infer_arbiter_indexes(), init_execution_state(), init_MultiFuncCall(), init_params(), init_sequence(), init_sexpr(), initArrayResultArr(), InitControlFile(), InitFileAccess(), initGinState(), initialize_dh(), initialize_ecdh(), initialize_peragg(), InitializeClientEncoding(), InitializeSessionUserId(), InitLocalBuffers(), InitPgFdwOptions(), InitPostgres(), InitProcess(), InitTempTableNamespace(), initTrie(), InitWalRecovery(), InitXLogReaderState(), inner_subltree(), insert_username(), InsertRule(), instantiate_empty_record_variable(), int24div(), int24mi(), int24mul(), int24pl(), int28div(), int28mi(), int28mul(), int28pl(), int2_dist(), int2abs(), int2div(), int2mi(), int2mod(), int2mul(), int2pl(), int2um(), int2vectorin(), int2vectorrecv(), int42div(), int42mi(), int42mul(), int42pl(), int48div(), int48mi(), int48mul(), int48pl(), int4_dist(), int4abs(), int4div(), int4gcd_internal(), int4inc(), int4lcm(), int4mi(), int4mod(), int4mul(), int4pl(), int4um(), int82(), int82div(), int82mi(), int82mul(), int82pl(), int84(), int84div(), int84mi(), int84mul(), int84pl(), int8_dist(), int8abs(), int8dec(), int8div(), int8gcd_internal(), int8inc(), int8lcm(), int8mi(), int8mod(), int8mul(), int8pl(), int8um(), internal_get_result_type(), internal_inetpl(), internal_load_library(), interpret_AS_clause(), interpret_func_parallel(), interpret_func_support(), interpret_function_parameter_list(), interval_div(), interval_in(), interval_justify_days(), interval_justify_hours(), interval_justify_interval(), interval_mi(), interval_mul(), interval_part_common(), interval_pl(), interval_trunc(), interval_um(), intervaltypmodin(), intorel_startup(), inv_open(), inv_read(), inv_seek(), inv_truncate(), inv_write(), iso8859_to_utf8(), IsThereCollationInNamespace(), IsThereFunctionInNamespace(), IsThereOpClassInNamespace(), IsThereOpFamilyInNamespace(), json_agg_transfn_worker(), json_build_object_worker(), json_ereport_error(), json_object(), json_object_agg_transfn_worker(), json_object_two_arg(), json_validate(), jsonb_agg_transfn_worker(), jsonb_array_length(), jsonb_build_object_worker(), jsonb_delete(), jsonb_delete_array(), jsonb_delete_idx(), jsonb_delete_path(), jsonb_insert(), jsonb_object(), jsonb_object_agg_transfn_worker(), jsonb_object_keys(), jsonb_object_two_arg(), jsonb_path_match_internal(), jsonb_set(), jsonb_set_lax(), jsonb_subscript_check_subscripts(), jsonb_subscript_transform(), JsonEncodeDateTime(), JsonItemFromDatum(), jsonPathFromCstring(), JsonPathQuery(), JsonPathValue(), JsValueToJsObject(), LargeObjectDrop(), lastval(), length_in_encoding(), libpqrcv_check_conninfo(), libpqrcv_create_slot(), libpqrcv_endstreaming(), libpqrcv_exec(), libpqrcv_get_conninfo(), libpqrcv_identify_system(), libpqrcv_processTuples(), libpqrcv_readtimelinehistoryfile(), libpqrcv_receive(), libpqrcv_send(), libpqrcv_startstreaming(), like_fixed_prefix(), line_construct_pp(), line_in(), line_recv(), ln_var(), lo_get_fragment_internal(), lo_read(), lo_truncate_internal(), lo_write(), load_categories_hash(), load_dh_file(), load_enum_cache_data(), load_external_function(), load_hba(), load_libraries(), LocalBufferAlloc(), LocalToUtf(), locate_stem_module(), lock_twophase_recover(), LockAcquireExtended(), LockGXact(), LockSchemaList(), LockTableRecurse(), LockViewRecurse_walker(), logicalrep_rel_mark_updatable(), logicalrep_rel_open(), logicalrep_report_missing_attrs(), logicalrep_worker_attach(), logicalrep_worker_launch(), LogicalRepApplyLoop(), LogicalRepSyncTableStart(), lookup_agg_function(), lookup_am_handler_func(), lookup_fdw_handler_func(), lookup_rowtype_tupdesc_domain(), lookup_rowtype_tupdesc_internal(), lookup_type_cache(), LookupFuncName(), LookupFuncWithArgs(), LookupOperName(), LookupTypeNameExtended(), LookupTypeNameOid(), lowerstr_with_len(), lpad(), lt_q_regex(), ltree_concat(), ltree_gist_in(), ltree_gist_out(), ltree_to_plpython(), ltxtq_out(), ltxtq_send(), lz4_decompress_datum(), lz4_decompress_datum_slice(), macaddr8_in(), macaddr8tomacaddr(), macaddr_in(), make_absolute_path(), make_callstmt_target(), make_date(), make_distinct_op(), make_expanded_record_from_tupdesc(), make_expanded_record_from_typeid(), make_icu_collator(), make_interval(), make_op(), make_outerjoininfo(), make_pathkeys_for_window(), make_result_opt_error(), make_row_comparison_op(), make_row_distinct_op(), make_ruledef(), make_scalar_array_op(), make_time(), make_timestamp_internal(), make_timestamptz_at_timezone(), make_tsvector(), makeArrayTypeName(), makeJsonEncoding(), makeMultirangeTypeName(), makepol(), makeRangeVarFromNameList(), makeWholeRowVar(), map_sql_value_to_xml_value(), mark_index_clustered(), MarkAsPreparing(), MarkGUCPrefixReserved(), MarkInheritDetached(), MarkPortalActive(), MatchText(), materializeResult(), md5_bytea(), md5_text(), mdextend(), mdread(), mdwrite(), MemoryContextAlloc(), MemoryContextAllocExtended(), MemoryContextAllocHuge(), MemoryContextAllocZero(), MemoryContextAllocZeroAligned(), merge_acl_with_grant(), merge_collation_state(), merge_publications(), MergeAttributes(), MergeAttributesIntoExisting(), MergeCheckConstraint(), MergeConstraintsIntoExisting(), MergeWithExistingConstraint(), metaphone(), moddatetime(), movedb(), mul_size(), multirange_constructor2(), multirange_in(), namerecv(), NamespaceCreate(), network_host(), network_in(), network_out(), network_recv(), network_show(), next_token(), NextCopyFrom(), NextCopyFromRawFields(), nextval_internal(), NIAddAffix(), NIImportAffixes(), NIImportDictionary(), NIImportOOAffixes(), NISortDictionary(), NonFiniteTimestampTzPart(), normal_rand(), NUM_processor(), NUMDesc_prepare(), numeric_div_opt_error(), numeric_div_trunc(), numeric_fac(), numeric_in(), numeric_int2(), numeric_int4_opt_error(), numeric_int8(), numeric_ln(), numeric_log(), numeric_mod_opt_error(), numeric_pg_lsn(), numeric_power(), numeric_recv(), numeric_sqrt(), numerictypmodin(), numericvar_to_double_no_overflow(), objectNamesToOids(), ObjectsInPublicationToOids(), oidin_subr(), oidvectorin(), oidvectorrecv(), okeys_array_start(), okeys_scalar(), on_proc_exit(), on_shmem_exit(), OnConflict_CheckForSerializationFailure(), op_error(), OpClassCacheLookup(), OpenPipeStream(), OpenTableList(), OpenTransientFilePerm(), OperatorCreate(), OperatorShellMake(), OpFamilyCacheLookup(), page_checksum_internal(), page_header(), PageAddItemExtended(), PageGetItemIdCareful(), PageIndexMultiDelete(), PageIndexTupleDelete(), PageIndexTupleDeleteNoCompact(), PageIndexTupleOverwrite(), PageIsVerifiedExtended(), PageRepairFragmentation(), pair_decode(), palloc(), palloc0(), palloc_btree_page(), palloc_extended(), ParallelWorkerMain(), ParameterAclCreate(), ParameterAclLookup(), parse_affentry(), parse_and_validate_value(), parse_basebackup_options(), parse_datetime(), parse_extension_control_file(), parse_fcall_arguments(), parse_format(), parse_hba_auth_opt(), parse_hba_line(), parse_ident(), parse_ident_line(), parse_jsonb_index_flags(), parse_key_value_arrays(), parse_lquery(), parse_ltree(), parse_one_reloption(), parse_output_parameters(), parse_phrase_operator(), parse_publication_options(), parse_re_flags(), parse_sane_timezone(), parse_snapshot(), parse_subscription_options(), parse_test_flags(), parse_tsquery(), parseCheckAggregates(), parseCreateReplSlotOptions(), ParseFuncOrColumn(), parseIntFromText(), parseNameAndArgTypes(), parseRelOptionsInternal(), parserOpenTable(), parsetext(), parseTypeString(), parseVxidFromText(), parseXidFromText(), path_add(), path_decode(), path_in(), path_poly(), path_recv(), PathNameOpenFilePerm(), pclose_check(), percentile_cont_final_common(), percentile_disc_final(), perform_base_backup(), perform_default_encoding_conversion(), PerformCursorOpen(), PerformPortalClose(), PerformPortalFetch(), pg_analyze_and_rewrite_varparams(), pg_any_to_server(), pg_attribute_aclmask_ext(), pg_attribute_noreturn(), pg_backup_start(), pg_backup_stop(), pg_base64_decode(), pg_be_scram_build_secret(), pg_cancel_backend(), pg_class_aclmask_ext(), pg_class_ownercheck(), pg_collation_actual_version(), pg_collation_for(), pg_collation_ownercheck(), pg_conversion_ownercheck(), pg_convert(), pg_create_restore_point(), pg_crypt(), pg_cryptohash_create(), pg_current_logfile(), pg_current_wal_flush_lsn(), pg_current_wal_insert_lsn(), pg_current_wal_lsn(), pg_database_aclmask(), pg_database_collation_actual_version(), pg_database_ownercheck(), pg_decode_startup(), pg_decrypt(), pg_decrypt_iv(), pg_dependencies_in(), pg_dependencies_recv(), pg_do_encoding_conversion(), pg_encrypt(), pg_encrypt_iv(), pg_event_trigger_ddl_commands(), pg_event_trigger_dropped_objects(), pg_event_trigger_ownercheck(), pg_event_trigger_table_rewrite_oid(), pg_event_trigger_table_rewrite_reason(), pg_extension_config_dump(), pg_extension_ownercheck(), pg_file_rename_internal(), pg_file_write_internal(), pg_foreign_data_wrapper_aclmask(), pg_foreign_data_wrapper_ownercheck(), pg_foreign_server_aclmask(), pg_foreign_server_ownercheck(), pg_freespace(), pg_gen_salt(), pg_gen_salt_rounds(), pg_get_expr_worker(), pg_get_functiondef(), pg_get_multixact_members(), pg_get_object_address(), pg_get_serial_sequence(), pg_get_wal_record_info(), pg_get_wal_replay_pause_state(), pg_hmac_create(), pg_import_system_collations(), pg_is_wal_replay_paused(), pg_language_aclmask(), pg_language_ownercheck(), pg_largeobject_aclmask_snapshot(), pg_largeobject_ownercheck(), pg_logdir_ls(), pg_logdir_ls_internal(), pg_logical_slot_get_changes_guts(), pg_ls_replslotdir(), pg_ls_tmpdir(), pg_lsn_in(), pg_lsn_mii(), pg_lsn_pli(), pg_mcv_list_in(), pg_mcv_list_recv(), pg_namespace_aclmask(), pg_namespace_ownercheck(), pg_ndistinct_in(), pg_ndistinct_recv(), pg_newlocale_from_collation(), pg_nextoid(), pg_opclass_ownercheck(), pg_oper_ownercheck(), pg_opfamily_ownercheck(), pg_parameter_acl_aclmask(), pg_prewarm(), pg_proc_aclmask(), pg_proc_ownercheck(), pg_promote(), pg_publication_ownercheck(), pg_random_bytes(), pg_read_binary_file(), pg_read_file(), pg_read_file_v2(), pg_regerror(), pg_relpages(), pg_relpages_impl(), pg_relpagesbyid(), pg_replication_origin_create(), pg_replication_origin_session_progress(), pg_replication_origin_xact_setup(), pg_replication_slot_advance(), pg_rotate_logfile(), pg_sequence_last_value(), pg_sequence_parameters(), pg_set_regex_collation(), pg_size_bytes(), pg_snapshot_recv(), pg_stat_get_progress_info(), pg_stat_reset_shared(), pg_stat_reset_subscription_stats(), pg_stat_statements_info(), pg_stat_statements_internal(), pg_statistics_object_ownercheck(), pg_stats_ext_mcvlist_items(), pg_stop_making_pinned_objects(), pg_strtoint16(), pg_strtoint32(), pg_strtoint64(), pg_subscription_ownercheck(), pg_switch_wal(), pg_tablespace_aclmask(), pg_tablespace_location(), pg_tablespace_ownercheck(), pg_terminate_backend(), pg_to_ascii(), pg_ts_config_ownercheck(), pg_ts_dict_ownercheck(), pg_type_aclmask(), pg_type_ownercheck(), pg_unicode_to_server(), pg_visibility(), pg_visibility_map(), pg_wait_until_termination(), pg_wal_replay_pause(), pg_wal_replay_resume(), pg_walfile_name(), pg_walfile_name_offset(), pgfdw_cancel_query(), pgfdw_reject_incomplete_xact_state_change(), pgfdw_report_error(), pgfdw_xact_callback(), PGLC_localeconv(), pglz_decompress_datum(), pglz_decompress_datum_slice(), pgoutput_column_list_init(), pgoutput_startup(), pgrowlocks(), PGSharedMemoryCreate(), pgss_shmem_startup(), pgstat_get_kind_from_str(), pgstat_heap(), pgstat_init_function_usage(), pgstat_relation(), pgstat_reset_replslot(), pgstatginindex(), pgstatginindex_internal(), pgstathashindex(), pgstatindex(), pgstatindex_impl(), pgstatindexbyid(), pgstattuple(), pgstattuple_approx(), pgstattuple_approx_internal(), pgstattuplebyid(), placeChar(), plperl_array_to_datum(), plperl_build_tuple_result(), plperl_call_perl_event_trigger_func(), plperl_call_perl_func(), plperl_call_perl_trigger_func(), plperl_create_sub(), plperl_func_handler(), plperl_init_interp(), plperl_modify_tuple(), plperl_return_next_internal(), plperl_spi_execute_fetch_result(), plperl_sv_to_datum(), plperl_sv_to_literal(), plperl_to_hstore(), plperl_trigger_handler(), plperl_trusted_init(), plperl_untrusted_init(), plperl_validator(), plpgsql_build_variable(), plpgsql_exec_event_trigger(), plpgsql_exec_function(), plpgsql_exec_get_datum_type(), plpgsql_exec_get_datum_type_info(), plpgsql_exec_trigger(), plpgsql_param_eval_generic(), plpgsql_param_eval_generic_ro(), plpgsql_param_eval_recfield(), plpgsql_parse_cwordrowtype(), plpgsql_parse_err_condition(), plpgsql_parse_wordrowtype(), plpgsql_post_column_ref(), plpgsql_recognize_err_condition(), plpgsql_resolve_polymorphic_argtypes(), plpgsql_validator(), plpgsql_yyerror(), plpython_to_hstore(), pltcl_build_tuple_result(), pltcl_elog(), pltcl_func_handler(), pltcl_trigger_handler(), PLy_cursor_fetch(), PLy_elog_impl(), PLy_exec_function(), PLy_exec_trigger(), PLy_function_build_args(), PLy_modify_tuple(), PLy_output(), PLy_procedure_create(), PLy_spi_execute_fetch_result(), PLyGenericObject_ToComposite(), PLyMapping_ToComposite(), PLyNumber_ToJsonbValue(), PLyObject_AsString(), PLyObject_ToJsonbValue(), PLySequence_ToArray(), PLySequence_ToArray_recurse(), PLySequence_ToComposite(), PLyUnicode_ToComposite(), policy_role_list_to_array(), poly_in(), poly_recv(), populate_array_check_dimension(), populate_array_report_expected_array(), populate_joinrel_with_paths(), populate_recordset_array_element_start(), populate_recordset_object_start(), populate_recordset_scalar(), populate_recordset_worker(), PortalDrop(), PortalRunSelect(), PortalSetResultFormat(), postgres_fdw_validator(), postgresBeginForeignInsert(), postgresExecForeignTruncate(), postgresImportForeignSchema(), PostgresMain(), postgresql_fdw_validator(), PostgresSingleUserMain(), PostmasterMain(), PostPrepare_Locks(), power_var(), power_var_int(), pq_copymsgbytes(), pq_getmessage(), pq_getmsgbyte(), pq_getmsgbytes(), pq_getmsgend(), pq_getmsgrawstring(), pq_getmsgstring(), pq_getmsgtext(), pq_startmsgread(), PreCommit_CheckForSerializationFailure(), PreCommit_Notify(), PreCommit_Portals(), predicatelock_twophase_recover(), PrefetchBuffer(), prepare_cb_wrapper(), prepare_sql_fn_parse_info(), PrepareQuery(), PrepareRedoAdd(), PrepareTransaction(), preprocess_grouping_sets(), prepTuplestoreResult(), PreventCommandDuringRecovery(), PreventCommandIfParallelMode(), PreventCommandIfReadOnly(), PreventInTransactionBlock(), printtup_prepare_info(), ProcArrayAdd(), ProcedureCreate(), process_matched_tle(), process_owned_by(), process_postgres_switches(), ProcessCopyOptions(), ProcessGUCArray(), ProcessInterrupts(), ProcessRepliesIfAny(), ProcessStandbyMessage(), ProcessStartupPacket(), ProcessTwoPhaseBuffer(), processTypesSpec(), ProcessUtilitySlow(), ProcessWalRcvInterrupts(), protect_out_of_mem(), prsd_headline(), prssyntaxerror(), publication_add_relation(), publication_add_schema(), publication_translate_columns(), PublicationDropSchemas(), PublicationDropTables(), pushquery(), PushTransaction(), pushval_asis(), pushValue(), pushValue_internal(), pvsnprintf(), px_crypt_des(), px_THROW_ERROR(), qtext_load_file(), QTN2QT(), QualifiedNameGetCreationNamespace(), query_to_xml_internal(), queryin(), quickdie(), range_constructor3(), range_minus_internal(), range_parse(), range_parse_bound(), range_parse_flags(), range_serialize(), range_union_internal(), RangeVarAdjustRelationPersistence(), RangeVarCallbackForAlterRelation(), RangeVarCallbackForAttachIndex(), RangeVarCallbackForDropRelation(), RangeVarCallbackForLockTable(), RangeVarCallbackForPolicy(), RangeVarCallbackForReindexIndex(), RangeVarCallbackForRenameRule(), RangeVarCallbackForRenameTrigger(), RangeVarCallbackOwnsRelation(), RangeVarCallbackOwnsTable(), RangeVarGetAndCheckCreationNamespace(), RangeVarGetCreationNamespace(), RangeVarGetRelidExtended(), raw_heap_insert(), RE_compile(), RE_compile_and_cache(), RE_wchar_execute(), read_any_attr(), read_attr_value(), read_backup_label(), read_binary_file(), read_client_final_message(), read_client_first_message(), read_dictionary(), read_objtype_from_string(), read_relmap_file(), read_tablespace_map(), read_whole_file(), ReadArrayBinary(), ReadArrayStr(), ReadBuffer_common(), ReadBufferExtended(), ReadControlFile(), readRecoverySignalFile(), ReadReplicationSlot(), readstoplist(), ReadTwoPhaseFile(), ReassignOwnedObjects(), ReceiveCopyBinaryHeader(), recompute_limits(), record_cmp(), record_eq(), record_image_cmp(), record_image_eq(), record_in(), record_recv(), recordDependencyOnCurrentExtension(), RecoveryRequiresIntParameter(), recursive_revoke(), recv_password_packet(), refresh_by_match_merge(), refuseDupeIndexAttach(), regex_fixed_prefix(), regexp_count(), regexp_fixed_prefix(), regexp_instr(), regexp_like(), regexp_match(), regexp_split_to_array(), regexp_split_to_table(), regexp_substr(), RegisterBackgroundWorker(), RegisterExtensibleNodeEntry(), registerJsonTableColumn(), RegisterTimeout(), regnamespacein(), regoperatorin(), regoperin(), regprocedurein(), regprocin(), REGRESS_exec_check_perms(), REGRESS_object_access_hook(), REGRESS_object_access_hook_str(), REGRESS_utility_command(), regrolein(), reindex_index(), reindex_relation(), ReindexMultipleTables(), ReindexRelationConcurrently(), reject_target_detail(), RelationBuildPartitionKey(), RelationCopyStorage(), RelationFindReplTupleByIndex(), RelationFindReplTupleSeq(), RelationGetBufferForTuple(), ReleaseCurrentSubTransaction(), ReleaseOneSerializableXact(), ReleaseSavepoint(), remove_tablespace_symlink(), RemoveExtensionById(), RemoveInheritance(), RemoveObjects(), RemovePolicyById(), RemoveRelations(), RemoveRewriteRuleById(), RemoveSubscriptionRel(), RemoveTriggerById(), RemoveUserMapping(), rename_constraint_internal(), rename_policy(), renameatt_check(), renameatt_internal(), RenameConstraintById(), RenameDatabase(), RenameEnumLabel(), RenameRelationInternal(), RenameRewriteRule(), RenameRole(), RenameSchema(), RenameTableSpace(), renametrig(), renametrig_internal(), RenameType(), RenameTypeInternal(), repalloc(), repalloc_huge(), repeat(), replace_rte_variables_mutator(), replace_text_regexp(), ReplaceVarsFromTargetList_callback(), ReplicationSlotAcquire(), ReplicationSlotCreate(), ReplicationSlotDropAtPubNode(), ReplicationSlotsDropDBSlots(), ReplicationSlotValidateName(), replorigin_advance(), replorigin_by_name(), replorigin_by_oid(), replorigin_check_prerequisites(), replorigin_create(), replorigin_drop_guts(), replorigin_session_reset(), replorigin_session_setup(), report_invalid_encoding(), report_name_conflict(), report_namespace_conflict(), report_untranslatable_char(), reportDependentObjects(), ReportSlotConnectionError(), requireSuperuser(), reserveAllocatedDesc(), resolve_anyarray_from_others(), resolve_anyelement_from_others(), resolve_anymultirange_from_others(), resolve_anyrange_from_others(), resolve_column_ref(), resolve_unique_index_expr(), ResolveOpClass(), RestoreGUCState(), RestoreSlotFromDisk(), restrict_and_check_grant(), revalidate_rectypeid(), RevalidateCachedQuery(), revmap_physical_extend(), RewriteQuery(), rewriteRuleAction(), rewriteSearchAndCycle(), rewriteTargetListIU(), rewriteTargetView(), ri_CheckTrigger(), ri_FetchConstraintInfo(), RI_FKey_check(), RI_Initial_Check(), ri_PerformCheck(), ri_ReportViolation(), rollback_prepared_cb_wrapper(), RollbackToSavepoint(), rpad(), sanity_check_tid_array(), SanityCheckBackgroundWorker(), satisfies_hash_partition(), scanNameSpaceForRefname(), scanNameSpaceForRelid(), scanNSItemForColumn(), scanRTEForColumn(), scram_exchange(), scram_init(), secure_open_gssapi(), secure_read(), secure_write(), select_common_collation(), select_common_type(), select_common_type_from_oids(), select_perl_context(), sendDir(), SendFunctionResult(), SendTimeLineHistory(), sepgsql_attribute_relabel(), sepgsql_avc_check_perms_label(), sepgsql_avc_init(), sepgsql_avc_unlabeled(), sepgsql_check_perms(), sepgsql_client_auth(), sepgsql_compute_avd(), sepgsql_compute_create(), sepgsql_get_label(), sepgsql_init_client_label(), sepgsql_mcstrans_in(), sepgsql_mcstrans_out(), sepgsql_object_relabel(), sepgsql_relation_relabel(), sepgsql_restorecon(), sepgsql_set_client_label(), sepgsql_utility_command(), serialize_expr_stats(), server_check_detail(), set_config_by_name(), set_config_option(), set_max_safe_fds(), set_var_from_str(), setCompoundAffixFlagValue(), SetDefaultACL(), setPath(), setPathArray(), setPathObject(), SetPossibleUnsafeConflict(), SetRWConflict(), setSchemaName(), setseed(), SetSerializableTransactionSnapshot(), SetSessionAuthorization(), SetSingleFuncCall(), setTargetTable(), SetTransactionSnapshot(), setup_background_workers(), setup_dynamic_shared_memory(), setup_pct_info(), setup_regexp_matches(), setup_test_matches(), SetUserIdAndContext(), SharedFileSetAttach(), SharedInvalBackendInit(), shdepDropOwned(), shdepLockAndCheckObject(), shdepReassignOwned(), shell_check_detail(), shell_construct_command(), shell_finish_command(), shell_get_sink(), shell_in(), shell_out(), shm_mq_receive(), shm_mq_sendv(), shm_toc_allocate(), shm_toc_insert(), ShmemAlloc(), ShmemAllocUnlocked(), ShmemInitStruct(), similar_escape_internal(), SlabContextCreate(), slot_modify_data(), slot_store_data(), SnapBuildInitialSnapshot(), SnapBuildRestore(), socket_set_nonblocking(), SocketBackend(), sort(), spgadjustmembers(), spgdoinsert(), spgFormInnerTuple(), spgFormNodeTuple(), spgGetCache(), spgvalidate(), SPI_cursor_open_internal(), split_part(), sqrt_var(), ssl_extension_info(), standard_ProcessUtility(), StartAutovacuumWorker(), StartLogicalReplication(), StartReplication(), StartupDecodingContext(), StartupReplicationOrigin(), storeOperators(), StorePreparedStatement(), storeProcedures(), StoreRelCheck(), storeRow(), str_initcap(), str_tolower(), str_toupper(), str_udeescape(), stream_abort_cb_wrapper(), stream_change_cb_wrapper(), stream_commit_cb_wrapper(), stream_prepare_cb_wrapper(), stream_start_cb_wrapper(), stream_stop_cb_wrapper(), string2ean(), string_to_privilege(), string_to_uuid(), stringToQualifiedNameList(), substitute_libpath_macro(), suppress_redundant_updates_trigger(), SV_to_JsonbValue(), SyncRepWaitForLSN(), system_beginsamplescan(), system_rows_beginsamplescan(), system_time_beginsamplescan(), table_open(), table_openrv(), table_openrv_extended(), table_tuple_get_latest_tid(), tablesample_init(), TablespaceCreateDbspace(), TargetPrivilegesCheck(), tblspc_redo(), TerminateOtherDBBackends(), test_enc_conversion(), test_re_compile(), test_re_execute(), test_shm_mq(), test_shm_mq_main(), test_shm_mq_pipelined(), TestForOldSnapshot_impl(), text_format(), text_format_append_string(), text_format_parse_digits(), text_format_parse_format(), text_format_string_conversion(), text_overlay(), text_position_setup(), text_starts_with(), text_substring(), text_to_bits(), textarray_to_strvaluelist(), textregexreplace(), textregexreplace_extended(), textToQualifiedNameList(), tfuncInitialize(), tfuncLoadRows(), thesaurus_init(), thesaurusRead(), throw_tcl_error(), tidin(), time_part_common(), time_recv(), timestamp2timestamptz_opt_overflow(), timestamp_age(), timestamp_bin(), timestamp_date(), timestamp_in(), timestamp_izone(), timestamp_mi(), timestamp_out(), timestamp_part_common(), timestamp_pl_interval(), timestamp_recv(), timestamp_time(), timestamp_to_char(), timestamp_trunc(), timestamp_zone(), timestamptz2timestamp(), timestamptz_age(), timestamptz_bin(), timestamptz_date(), timestamptz_in(), timestamptz_izone(), timestamptz_out(), timestamptz_part_common(), timestamptz_pl_interval(), timestamptz_recv(), timestamptz_time(), timestamptz_timetz(), timestamptz_to_char(), timestamptz_trunc_internal(), timestamptz_trunc_zone(), timestamptz_zone(), timetz_izone(), timetz_part_common(), timetz_recv(), timetz_zone(), to_ascii_enc(), to_ascii_encname(), to_date(), to_json(), to_jsonb(), to_regnamespace(), to_regoperator(), to_regrole(), to_timestamp(), TopologicalSort(), tqueueReceiveSlot(), TransactionIdGetCommitTsData(), TransactionIdInRecentPast(), TransactionIdIsInProgress(), transformAExprNullIf(), transformAggregateCall(), transformAlterTableStmt(), transformArrayExpr(), transformAssignedExpr(), transformAssignmentIndirection(), transformAssignmentSubscripts(), transformCaseExpr(), transformCoalesceExpr(), transformCollateClause(), transformColumnDefinition(), transformColumnNameList(), transformColumnRef(), transformColumnType(), transformConstraintAttrs(), transformContainerSubscripts(), transformCreateStmt(), transformCreateTableAsStmt(), transformDeclareCursorStmt(), transformDistinctClause(), transformDistinctOnClause(), transformExprRecurse(), transformFkeyCheckAttrs(), transformFkeyGetPrimaryKey(), transformFrameOffset(), transformFromClauseItem(), transformGenericOptions(), transformGroupingFunc(), transformGroupingSet(), transformIndexConstraint(), transformIndexStmt(), transformIndirection(), transformInsertRow(), transformJsonAggConstructor(), transformJsonArrayQueryConstructor(), transformJsonConstructorRet(), transformJsonExprCommon(), transformJsonFuncExpr(), transformJsonIsPredicate(), transformJsonOutput(), transformJsonParseArg(), transformJsonParseExpr(), transformJsonTable(), transformJsonTableChildPlan(), transformJsonTableColumns(), transformJsonValueExprExt(), transformLimitClause(), transformLockingClause(), transformMergeStmt(), transformMultiAssignRef(), transformOnConflictArbiter(), transformParamRef(), transformPartitionBound(), transformPartitionBoundValue(), transformPartitionCmd(), transformPartitionRangeBounds(), transformPartitionSpec(), transformPLAssignStmt(), TransformPubWhereClauses(), transformRangeFunction(), transformRangeTableFunc(), transformRangeTableSample(), transformRelOptions(), transformReturningList(), transformRuleStmt(), transformSelectStmt(), transformSetOperationStmt(), transformSetOperationTree(), transformStatsStmt(), transformSubLink(), transformTableConstraint(), transformTableLikeClause(), transformTypeCast(), transformUpdateTargetList(), transformValuesClause(), transformWindowDefinitions(), transformWindowFuncCall(), transformWithClause(), transformXmlExpr(), transformXmlSerialize(), translate(), triggered_change_notification(), trim_array(), truncate_check_activity(), truncate_check_rel(), truncate_identifier(), try_table_open(), ts_headline_byid_opt(), ts_headline_json_byid_opt(), ts_headline_jsonb_byid_opt(), ts_stat_sql(), tsquery_phrase_distance(), tsquery_rewrite_query(), tsvector_concat(), tsvector_filter(), tsvector_update_trigger(), tsvectorin(), ttdummy(), tts_buffer_heap_getsysattr(), tts_heap_getsysattr(), tts_minimal_getsysattr(), tts_virtual_getsysattr(), tuple_data_split(), tuple_data_split_internal(), tupledesc_match(), tuples_equal(), TwoPhaseTransactionGid(), TypeCreate(), TypeGetTupleDesc(), typenameType(), typenameTypeMod(), TypeShellMake(), typeStringToTypeName(), unaccent_dict(), unaccent_init(), unicode_norm_form_from_string(), unique_key_recheck(), uniqueifyJsonbObject(), unistr(), unknown_attribute(), UserAbortTransactionBlock(), utf8_to_iso8859(), utf8_to_win(), UtfToLocal(), uuid_generate_internal(), vac_update_relstats(), vacuum(), vacuum_open_relation(), validate_ddl_tags(), validate_option_array_item(), validate_pkattnums(), validate_table_rewrite_tags(), validateConnectbyTupleDesc(), validateDomainConstraint(), validateFkOnDeleteSetColumns(), validateInfiniteBounds(), ValidateInputLSNs(), ValidateJoinEstimator(), validateJsonTableChildPlan(), ValidatePgVersion(), validateRecoveryParameters(), ValidateRestrictionEstimator(), varbit(), varbit_in(), varbit_recv(), varchar(), varchar_input(), variable_coerce_param_hook(), variable_paramref_hook(), varstr_levenshtein(), verify_brin_page(), verify_dictoptions(), verify_hash_page(), verify_heapam(), VirtualXactLock(), wait_for_workers_to_become_ready(), WaitForParallelWorkersToAttach(), WaitForParallelWorkersToExit(), WaitForParallelWorkersToFinish(), WalRcvFetchTimeLineHistoryFiles(), WALReadRaiseError(), WalReceiverMain(), widget_in(), width_bucket_array(), width_bucket_float8(), width_bucket_numeric(), win_to_utf8(), window_nth_value(), window_ntile(), worker_spi_launch(), write_auto_conf_file(), X509_NAME_field_to_text(), X509_NAME_to_cstring(), XLogFileCopy(), XLogPageRead(), XlogReadTwoPhaseData(), XLogWalRcvProcessMsg(), xmlcomment(), xmlpi(), XmlTableGetValue(), XmlTableSetColumnFilter(), XmlTableSetNamespace(), XmlTableSetRowFilter(), xmltotext_with_xmloption(), xmlvalidate(), xpath_table(), and xslt_process().

◆ errcode_for_file_access()

int errcode_for_file_access ( void  )

Definition at line 716 of file elog.c.

717 {
719 
720  /* we don't bother incrementing recursion_depth */
722 
723  switch (edata->saved_errno)
724  {
725  /* Permission-denied failures */
726  case EPERM: /* Not super-user */
727  case EACCES: /* Permission denied */
728 #ifdef EROFS
729  case EROFS: /* Read only file system */
730 #endif
731  edata->sqlerrcode = ERRCODE_INSUFFICIENT_PRIVILEGE;
732  break;
733 
734  /* File not found */
735  case ENOENT: /* No such file or directory */
736  edata->sqlerrcode = ERRCODE_UNDEFINED_FILE;
737  break;
738 
739  /* Duplicate file */
740  case EEXIST: /* File exists */
741  edata->sqlerrcode = ERRCODE_DUPLICATE_FILE;
742  break;
743 
744  /* Wrong object type or state */
745  case ENOTDIR: /* Not a directory */
746  case EISDIR: /* Is a directory */
747 #if defined(ENOTEMPTY) && (ENOTEMPTY != EEXIST) /* same code on AIX */
748  case ENOTEMPTY: /* Directory not empty */
749 #endif
750  edata->sqlerrcode = ERRCODE_WRONG_OBJECT_TYPE;
751  break;
752 
753  /* Insufficient resources */
754  case ENOSPC: /* No space left on device */
755  edata->sqlerrcode = ERRCODE_DISK_FULL;
756  break;
757 
758  case ENFILE: /* File table overflow */
759  case EMFILE: /* Too many open files */
760  edata->sqlerrcode = ERRCODE_INSUFFICIENT_RESOURCES;
761  break;
762 
763  /* Hardware failure */
764  case EIO: /* I/O error */
765  edata->sqlerrcode = ERRCODE_IO_ERROR;
766  break;
767 
768  /* All else is classified as internal errors */
769  default:
770  edata->sqlerrcode = ERRCODE_INTERNAL_ERROR;
771  break;
772  }
773 
774  return 0; /* return value does not matter */
775 }
int saved_errno
Definition: elog.h:383

References CHECK_STACK_DEPTH, errordata, errordata_stack_depth, ErrorData::saved_errno, and ErrorData::sqlerrcode.

Referenced by _mdfd_getseg(), _mdnblocks(), AddToDataDirLockFile(), AlterSystemSetConfigFile(), apply_spooled_messages(), ApplyLogicalMappingFile(), apw_dump_now(), apw_load_buffers(), assign_xlog_sync_method(), basebackup_read_file(), basic_archive_file_internal(), bbsink_server_archive_contents(), bbsink_server_begin_archive(), bbsink_server_begin_manifest(), bbsink_server_end_archive(), bbsink_server_manifest_contents(), bbsink_server_new(), be_lo_export(), BeginCopyFrom(), BeginCopyTo(), BootStrapXLOG(), BufFileDumpBuffer(), BufFileLoadBuffer(), BufFileOpenFileSet(), BufFileSeek(), BufFileSize(), BufFileTruncateFileSet(), calculate_relation_size(), calculate_tablespace_size(), ChangeToDataDir(), check_ssl_key_file_permissions(), checkDataDir(), CheckForStandbyTrigger(), CheckPointLogicalRewriteHeap(), CheckPointReplicationOrigin(), CheckPointSnapBuild(), CheckXLogRemoved(), ClosePipeFromProgram(), ClosePipeToProgram(), ClosePostmasterPorts(), compare_files(), copy_file(), copydir(), CopyGetData(), CopySendEndOfRow(), create_tablespace_directories(), CreateDirAndVersionFile(), CreateLockFile(), CreateOptsFile(), CreateSlotOnDisk(), db_dir_size(), DebugFileOpen(), DeleteAllExportedSnapshotFiles(), destroy_tablespace_directories(), do_pg_backup_stop(), do_truncate(), dsm_cleanup_for_mmap(), dsm_impl_mmap(), durable_rename(), durable_rename_excl(), durable_unlink(), EndCopy(), EndCopyFrom(), entry_reset(), errcode_for_dynamic_shared_memory(), ExecHashJoinGetSavedTuple(), ExecHashJoinNewBatch(), existsTimeLineHistory(), ExportSnapshot(), file_exists(), fileAnalyzeForeignTable(), FileClose(), fill_hba_view(), fill_ident_view(), find_my_exec(), fsync_fname_ext(), gc_qtexts(), get_controlfile(), get_dirent_type(), getInstallationPaths(), getlen(), hashagg_batch_read(), heap_xlog_logical_rewrite(), InitPostgres(), InitPostmasterDeathWatchHandle(), InitWalRecovery(), internal_load_library(), issue_xlog_fsync(), KeepFileRestoredFromArchive(), lo_import_internal(), load_dh_file(), load_hba(), load_ident(), logfile_open(), logical_end_heap_rewrite(), logical_heap_rewrite_flush_mappings(), logical_rewrite_log_mapping(), ltsReadBlock(), ltsWriteBlock(), mdcreate(), mdextend(), mdimmedsync(), mdopenfork(), mdread(), mdtruncate(), mdunlinkfork(), mdwrite(), parse_extension_control_file(), PathNameCreateTemporaryDir(), PathNameCreateTemporaryFile(), PathNameDeleteTemporaryFile(), PathNameOpenTemporaryFile(), perform_base_backup(), pg_current_logfile(), pg_file_rename_internal(), pg_file_sync(), pg_file_unlink(), pg_file_unlink_v1_1(), pg_file_write_internal(), pg_flush_data(), pg_import_system_collations(), pg_ls_dir_files(), pg_promote(), pg_stat_file(), pg_tablespace_databases(), pg_tablespace_location(), pg_tzenumerate_next(), pg_tzenumerate_start(), pgarch_readyXlog(), PGReserveSemaphores(), PGSharedMemoryCreate(), pgss_shmem_shutdown(), pgss_shmem_startup(), pgstat_discard_stats(), pgstat_read_statsfile(), pgstat_write_statsfile(), PostmasterMain(), ProcessSyncRequests(), qtext_load_file(), qtext_store(), read_backup_label(), read_binary_file(), read_relmap_file(), read_tablespace_map(), read_whole_file(), ReadControlFile(), ReadDirExtended(), ReadNextXLogRecord(), readRecoverySignalFile(), readTimeLineHistory(), readtup_heap(), ReadTwoPhaseFile(), RecheckDataDirLockFile(), RecreateTwoPhaseFile(), register_dirty_segment(), remove_tablespace_symlink(), RemovePgTempFilesInDir(), RemovePgTempRelationFilesInDbspace(), RemoveTwoPhaseFile(), RemoveXlogFile(), ReorderBufferCleanupSerializedTXNs(), ReorderBufferRestoreChanges(), ReorderBufferRestoreCleanup(), ReorderBufferSerializeChange(), ReorderBufferSerializeTXN(), ReplicationSlotDropPtr(), ResetUnloggedRelationsInDbspaceDir(), ResetUnloggedRelationsInTablespaceDir(), resolve_symlinks(), RestoreArchivedFile(), RestoreSlotFromDisk(), run_ssl_passphrase_command(), SaveSlotToPath(), SendBackupManifest(), sendDir(), sendFile(), sendTablespace(), SendTimeLineHistory(), shell_finish_command(), shell_send_data(), SlruReportIOError(), SnapBuildRestore(), SnapBuildSerialize(), StartupReplicationOrigin(), sts_parallel_scan_next(), sts_read_tuple(), subxact_info_read(), SyncDataDirectory(), SyncPostCheckpoint(), SysLogger_Start(), TablespaceCreateDbspace(), tokenize_auth_file(), tokenize_inc_file(), tuplestore_copy_read_pointer(), tuplestore_gettuple(), tuplestore_puttuple_common(), tuplestore_rescan(), tuplestore_select_read_pointer(), unlink_if_exists_fname(), unlink_initfile(), update_controlfile(), update_metainfo_datafile(), ValidatePgVersion(), wal_segment_open(), WALReadRaiseError(), WalReceiverMain(), WalSndSegmentOpen(), write_auto_conf_file(), write_relcache_init_file(), write_relmap_file(), WriteControlFile(), writeTimeLineHistory(), writeTimeLineHistoryFile(), XLogArchiveForceDone(), XLogArchiveNotify(), XLogFileClose(), XLogFileCopy(), XLogFileInit(), XLogFileInitInternal(), XLogFileOpen(), XLogFileRead(), XLogFileReadAnyTLI(), XLogInitNewTimeline(), XLogPageRead(), XlogReadTwoPhaseData(), XLogWalRcvClose(), XLogWalRcvWrite(), and XLogWrite().

◆ errcode_for_socket_access()

int errcode_for_socket_access ( void  )

Definition at line 787 of file elog.c.

788 {
790 
791  /* we don't bother incrementing recursion_depth */
793 
794  switch (edata->saved_errno)
795  {
796  /* Loss of connection */
798  edata->sqlerrcode = ERRCODE_CONNECTION_FAILURE;
799  break;
800 
801  /* All else is classified as internal errors */
802  default:
803  edata->sqlerrcode = ERRCODE_INTERNAL_ERROR;
804  break;
805  }
806 
807  return 0; /* return value does not matter */
808 }
#define ALL_CONNECTION_FAILURE_ERRNOS
Definition: port.h:117

References ALL_CONNECTION_FAILURE_ERRNOS, CHECK_STACK_DEPTH, errordata, errordata_stack_depth, ErrorData::saved_errno, and ErrorData::sqlerrcode.

Referenced by auth_peer(), be_tls_open_server(), ident_inet(), InitPostmasterDeathWatchHandle(), internal_flush(), pq_getbyte_if_available(), pq_recvbuf(), ProcessStartupPacket(), ServerLoop(), StreamConnection(), StreamServerPort(), SysLogger_Start(), and SysLoggerMain().

◆ errcontext_msg()

int errcontext_msg ( const char *  fmt,
  ... 
)

◆ errdetail()

int errdetail ( const char *  fmt,
  ... 
)

◆ errdetail_internal()

int int errdetail_internal ( const char *  fmt,
  ... 
)

◆ errdetail_log()

int int int errdetail_log ( const char *  fmt,
  ... 
)

◆ errdetail_log_plural()

int int int int errdetail_log_plural ( const char *  fmt_singular,
const char *  fmt_plural,
unsigned long  n,
  ... 
)

◆ errdetail_plural()

int errdetail_plural ( const char *  fmt_singular,
const char *  fmt_plural,
unsigned long  n,
  ... 
)

◆ errfinish()

void errfinish ( const char *  filename,
int  lineno,
const char *  funcname 
)

Definition at line 508 of file elog.c.

509 {
511  int elevel;
512  MemoryContext oldcontext;
513  ErrorContextCallback *econtext;
514 
515  recursion_depth++;
517 
518  /* Save the last few bits of error state into the stack entry */
519  if (filename)
520  {
521  const char *slash;
522 
523  /* keep only base name, useful especially for vpath builds */
524  slash = strrchr(filename, '/');
525  if (slash)
526  filename = slash + 1;
527  /* Some Windows compilers use backslashes in __FILE__ strings */
528  slash = strrchr(filename, '\\');
529  if (slash)
530  filename = slash + 1;
531  }
532 
533  edata->filename = filename;
534  edata->lineno = lineno;
535  edata->funcname = funcname;
536 
537  elevel = edata->elevel;
538 
539  /*
540  * Do processing in ErrorContext, which we hope has enough reserved space
541  * to report an error.
542  */
543  oldcontext = MemoryContextSwitchTo(ErrorContext);
544 
545  if (!edata->backtrace &&
546  edata->funcname &&
549  set_backtrace(edata, 2);
550 
551  /*
552  * Call any context callback functions. Errors occurring in callback
553  * functions will be treated as recursive errors --- this ensures we will
554  * avoid infinite recursion (see errstart).
555  */
556  for (econtext = error_context_stack;
557  econtext != NULL;
558  econtext = econtext->previous)
559  econtext->callback(econtext->arg);
560 
561  /*
562  * If ERROR (not more nor less) we pass it off to the current handler.
563  * Printing it and popping the stack is the responsibility of the handler.
564  */
565  if (elevel == ERROR)
566  {
567  /*
568  * We do some minimal cleanup before longjmp'ing so that handlers can
569  * execute in a reasonably sane state.
570  *
571  * Reset InterruptHoldoffCount in case we ereport'd from inside an
572  * interrupt holdoff section. (We assume here that no handler will
573  * itself be inside a holdoff section. If necessary, such a handler
574  * could save and restore InterruptHoldoffCount for itself, but this
575  * should make life easier for most.)
576  */
579 
580  CritSectionCount = 0; /* should be unnecessary, but... */
581 
582  /*
583  * Note that we leave CurrentMemoryContext set to ErrorContext. The
584  * handler should reset it to something else soon.
585  */
586 
587  recursion_depth--;
588  PG_RE_THROW();
589  }
590 
591  /* Emit the message to the right places */
592  EmitErrorReport();
593 
594  /* Now free up subsidiary data attached to stack entry, and release it */
595  if (edata->message)
596  pfree(edata->message);
597  if (edata->detail)
598  pfree(edata->detail);
599  if (edata->detail_log)
600  pfree(edata->detail_log);
601  if (edata->hint)
602  pfree(edata->hint);
603  if (edata->context)
604  pfree(edata->context);
605  if (edata->backtrace)
606  pfree(edata->backtrace);
607  if (edata->schema_name)
608  pfree(edata->schema_name);
609  if (edata->table_name)
610  pfree(edata->table_name);
611  if (edata->column_name)
612  pfree(edata->column_name);
613  if (edata->datatype_name)
614  pfree(edata->datatype_name);
615  if (edata->constraint_name)
616  pfree(edata->constraint_name);
617  if (edata->internalquery)
618  pfree(edata->internalquery);
619 
621 
622  /* Exit error-handling context */
623  MemoryContextSwitchTo(oldcontext);
624  recursion_depth--;
625 
626  /*
627  * Perform error recovery action as specified by elevel.
628  */
629  if (elevel == FATAL)
630  {
631  /*
632  * For a FATAL error, we let proc_exit clean up and exit.
633  *
634  * If we just reported a startup failure, the client will disconnect
635  * on receiving it, so don't send any more to the client.
636  */
639 
640  /*
641  * fflush here is just to improve the odds that we get to see the
642  * error message, in case things are so hosed that proc_exit crashes.
643  * Any other code you might be tempted to add here should probably be
644  * in an on_proc_exit or on_shmem_exit callback instead.
645  */
646  fflush(stdout);
647  fflush(stderr);
648 
649  /*
650  * Let the cumulative stats system know. Only mark the session as
651  * terminated by fatal error if there is no other known cause.
652  */
655 
656  /*
657  * Do normal process-exit cleanup, then return exit code 1 to indicate
658  * FATAL termination. The postmaster may or may not consider this
659  * worthy of panic, depending on which subprocess returns it.
660  */
661  proc_exit(1);
662  }
663 
664  if (elevel >= PANIC)
665  {
666  /*
667  * Serious crash time. Postmaster will observe SIGABRT process exit
668  * status and kill the other backends too.
669  *
670  * XXX: what if we are *in* the postmaster? abort() won't kill our
671  * children...
672  */
673  fflush(stdout);
674  fflush(stderr);
675  abort();
676  }
677 
678  /*
679  * Check for cancel/die interrupt first --- this is so that the user can
680  * stop a query emitting tons of notice or warning messages, even if it's
681  * in a loop that otherwise fails to check for interrupts.
682  */
684 }
@ DestRemote
Definition: dest.h:91
@ DestNone
Definition: dest.h:89
void EmitErrorReport(void)
Definition: elog.c:1504
ErrorContextCallback * error_context_stack
Definition: elog.c:93
static bool matches_backtrace_functions(const char *funcname)
Definition: elog.c:478
sigjmp_buf * PG_exception_stack
Definition: elog.c:95
#define PG_RE_THROW()
Definition: elog.h:340
#define PANIC
Definition: elog.h:36
volatile uint32 QueryCancelHoldoffCount
Definition: globals.c:41
volatile uint32 InterruptHoldoffCount
Definition: globals.c:40
volatile uint32 CritSectionCount
Definition: globals.c:42
char * backtrace_functions
Definition: guc.c:646
void proc_exit(int code)
Definition: ipc.c:104
static void const char fflush(stdout)
void pfree(void *pointer)
Definition: mcxt.c:1175
#define CHECK_FOR_INTERRUPTS()
Definition: miscadmin.h:121
static char * filename
Definition: pg_dumpall.c:94
@ DISCONNECT_FATAL
Definition: pgstat.h:80
@ DISCONNECT_NORMAL
Definition: pgstat.h:78
SessionEndType pgStatSessionEndCause
CommandDest whereToSendOutput
Definition: postgres.c:92
struct ErrorContextCallback * previous
Definition: elog.h:232
void(* callback)(void *arg)
Definition: elog.h:233
const char * filename
Definition: elog.h:362
const char * funcname
Definition: elog.h:364
int lineno
Definition: elog.h:363

References ErrorContextCallback::arg, ErrorData::backtrace, backtrace_functions, ErrorContextCallback::callback, CHECK_FOR_INTERRUPTS, CHECK_STACK_DEPTH, ErrorData::column_name, ErrorData::constraint_name, ErrorData::context, CritSectionCount, ErrorData::datatype_name, DestNone, DestRemote, ErrorData::detail, ErrorData::detail_log, DISCONNECT_FATAL, DISCONNECT_NORMAL, ErrorData::elevel, EmitErrorReport(), ERROR, error_context_stack, ErrorContext, errordata, errordata_stack_depth, FATAL, fflush(), filename, ErrorData::filename, ErrorData::funcname, ErrorData::hint, ErrorData::internalquery, InterruptHoldoffCount, ErrorData::lineno, matches_backtrace_functions(), MemoryContextSwitchTo(), ErrorData::message, PANIC, pfree(), PG_exception_stack, PG_RE_THROW, pgStatSessionEndCause, ErrorContextCallback::previous, proc_exit(), QueryCancelHoldoffCount, recursion_depth, ErrorData::schema_name, set_backtrace(), generate_unaccent_rules::stdout, ErrorData::table_name, and whereToSendOutput.

Referenced by pg_re_throw(), and ThrowErrorData().

◆ errhidecontext()

int errhidecontext ( bool  hide_ctx)

Definition at line 1264 of file elog.c.

1265 {
1267 
1268  /* we don't bother incrementing recursion_depth */
1270 
1271  edata->hide_ctx = hide_ctx;
1272 
1273  return 0; /* return value does not matter */
1274 }
bool hide_ctx
Definition: elog.h:361

References CHECK_STACK_DEPTH, errordata, errordata_stack_depth, and ErrorData::hide_ctx.

Referenced by llvm_compile_module(), MemoryContextStatsDetail(), MemoryContextStatsInternal(), MemoryContextStatsPrint(), and ProcessLogMemoryContextInterrupt().

◆ errhidestmt()

int int errhidestmt ( bool  hide_stmt)

Definition at line 1245 of file elog.c.

1246 {
1248 
1249  /* we don't bother incrementing recursion_depth */
1251 
1252  edata->hide_stmt = hide_stmt;
1253 
1254  return 0; /* return value does not matter */
1255 }

References CHECK_STACK_DEPTH, errordata, errordata_stack_depth, and ErrorData::hide_stmt.

Referenced by exec_bind_message(), exec_execute_message(), exec_parse_message(), exec_simple_query(), explain_ExecutorEnd(), llvm_compile_module(), MemoryContextStatsDetail(), MemoryContextStatsInternal(), MemoryContextStatsPrint(), and ProcessLogMemoryContextInterrupt().

◆ errhint()

int errhint ( const char *  fmt,
  ... 
)

◆ errhint_plural()

int int errhint_plural ( const char *  fmt_singular,
const char *  fmt_plural,
unsigned long  n,
  ... 
)

◆ errmsg()

int errmsg ( const char *  fmt,
  ... 
)

◆ errmsg_internal()

int int errmsg_internal ( const char *  fmt,
  ... 
)

◆ errmsg_plural()

int int int errmsg_plural ( const char *  fmt_singular,
const char *  fmt_plural,
unsigned long  n,
  ... 
)

◆ error_severity()

const char* error_severity ( int  elevel)

Definition at line 3298 of file elog.c.

3299 {
3300  const char *prefix;
3301 
3302  switch (elevel)
3303  {
3304  case DEBUG1:
3305  case DEBUG2:
3306  case DEBUG3:
3307  case DEBUG4:
3308  case DEBUG5:
3309  prefix = gettext_noop("DEBUG");
3310  break;
3311  case LOG:
3312  case LOG_SERVER_ONLY:
3313  prefix = gettext_noop("LOG");
3314  break;
3315  case INFO:
3316  prefix = gettext_noop("INFO");
3317  break;
3318  case NOTICE:
3319  prefix = gettext_noop("NOTICE");
3320  break;
3321  case WARNING:
3322  case WARNING_CLIENT_ONLY:
3323  prefix = gettext_noop("WARNING");
3324  break;
3325  case ERROR:
3326  prefix = gettext_noop("ERROR");
3327  break;
3328  case FATAL:
3329  prefix = gettext_noop("FATAL");
3330  break;
3331  case PANIC:
3332  prefix = gettext_noop("PANIC");
3333  break;
3334  default:
3335  prefix = "???";
3336  break;
3337  }
3338 
3339  return prefix;
3340 }
#define gettext_noop(x)
Definition: c.h:1205
#define LOG
Definition: elog.h:25
#define DEBUG3
Definition: elog.h:22
#define WARNING_CLIENT_ONLY
Definition: elog.h:32
#define WARNING
Definition: elog.h:30
#define DEBUG2
Definition: elog.h:23
#define DEBUG1
Definition: elog.h:24
#define NOTICE
Definition: elog.h:29
#define INFO
Definition: elog.h:28
#define DEBUG5
Definition: elog.h:20
#define DEBUG4
Definition: elog.h:21

References DEBUG1, DEBUG2, DEBUG3, DEBUG4, DEBUG5, ERROR, FATAL, gettext_noop, INFO, LOG, LOG_SERVER_ONLY, NOTICE, PANIC, WARNING, and WARNING_CLIENT_ONLY.

Referenced by send_message_to_frontend(), send_message_to_server_log(), write_csvlog(), and write_jsonlog().

◆ errposition()

int errposition ( int  cursorpos)

Definition at line 1280 of file elog.c.

1281 {
1283 
1284  /* we don't bother incrementing recursion_depth */
1286 
1287  edata->cursorpos = cursorpos;
1288 
1289  return 0; /* return value does not matter */
1290 }
int cursorpos
Definition: elog.h:380

References CHECK_STACK_DEPTH, ErrorData::cursorpos, errordata, and errordata_stack_depth.

Referenced by _SPI_error_callback(), executor_errposition(), function_parse_error_transpose(), import_error_callback(), parser_errposition(), sql_exec_error_callback(), and sql_inline_error_callback().

◆ errstart()

bool errstart ( int  elevel,
const char *  domain 
)

Definition at line 335 of file elog.c.

336 {
337  ErrorData *edata;
338  bool output_to_server;
339  bool output_to_client = false;
340  int i;
341 
342  /*
343  * Check some cases in which we want to promote an error into a more
344  * severe error. None of this logic applies for non-error messages.
345  */
346  if (elevel >= ERROR)
347  {
348  /*
349  * If we are inside a critical section, all errors become PANIC
350  * errors. See miscadmin.h.
351  */
352  if (CritSectionCount > 0)
353  elevel = PANIC;
354 
355  /*
356  * Check reasons for treating ERROR as FATAL:
357  *
358  * 1. we have no handler to pass the error to (implies we are in the
359  * postmaster or in backend startup).
360  *
361  * 2. ExitOnAnyError mode switch is set (initdb uses this).
362  *
363  * 3. the error occurred after proc_exit has begun to run. (It's
364  * proc_exit's responsibility to see that this doesn't turn into
365  * infinite recursion!)
366  */
367  if (elevel == ERROR)
368  {
369  if (PG_exception_stack == NULL ||
370  ExitOnAnyError ||
372  elevel = FATAL;
373  }
374 
375  /*
376  * If the error level is ERROR or more, errfinish is not going to
377  * return to caller; therefore, if there is any stacked error already
378  * in progress it will be lost. This is more or less okay, except we
379  * do not want to have a FATAL or PANIC error downgraded because the
380  * reporting process was interrupted by a lower-grade error. So check
381  * the stack and make sure we panic if panic is warranted.
382  */
383  for (i = 0; i <= errordata_stack_depth; i++)
384  elevel = Max(elevel, errordata[i].elevel);
385  }
386 
387  /*
388  * Now decide whether we need to process this report at all; if it's
389  * warning or less and not enabled for logging, just return false without
390  * starting up any error logging machinery.
391  */
392  output_to_server = should_output_to_server(elevel);
393  output_to_client = should_output_to_client(elevel);
394  if (elevel < ERROR && !output_to_server && !output_to_client)
395  return false;
396 
397  /*
398  * We need to do some actual work. Make sure that memory context
399  * initialization has finished, else we can't do anything useful.
400  */
401  if (ErrorContext == NULL)
402  {
403  /* Oops, hard crash time; very little we can do safely here */
404  write_stderr("error occurred before error message processing is available\n");
405  exit(2);
406  }
407 
408  /*
409  * Okay, crank up a stack entry to store the info in.
410  */
411 
412  if (recursion_depth++ > 0 && elevel >= ERROR)
413  {
414  /*
415  * Oops, error during error processing. Clear ErrorContext as
416  * discussed at top of file. We will not return to the original
417  * error's reporter or handler, so we don't need it.
418  */
420 
421  /*
422  * Infinite error recursion might be due to something broken in a
423  * context traceback routine. Abandon them too. We also abandon
424  * attempting to print the error statement (which, if long, could
425  * itself be the source of the recursive failure).
426  */
428  {
429  error_context_stack = NULL;
430  debug_query_string = NULL;
431  }
432  }
434  {
435  /*
436  * Wups, stack not big enough. We treat this as a PANIC condition
437  * because it suggests an infinite loop of errors during error
438  * recovery.
439  */
440  errordata_stack_depth = -1; /* make room on stack */
441  ereport(PANIC, (errmsg_internal("ERRORDATA_STACK_SIZE exceeded")));
442  }
443 
444  /* Initialize data for this error frame */
446  MemSet(edata, 0, sizeof(ErrorData));
447  edata->elevel = elevel;
448  edata->output_to_server = output_to_server;
449  edata->output_to_client = output_to_client;
450  /* the default text domain is the backend's */
451  edata->domain = domain ? domain : PG_TEXTDOMAIN("postgres");
452  /* initialize context_domain the same way (see set_errcontext_domain()) */
453  edata->context_domain = edata->domain;
454  /* Select default errcode based on elevel */
455  if (elevel >= ERROR)
456  edata->sqlerrcode = ERRCODE_INTERNAL_ERROR;
457  else if (elevel >= WARNING)
458  edata->sqlerrcode = ERRCODE_WARNING;
459  else
460  edata->sqlerrcode = ERRCODE_SUCCESSFUL_COMPLETION;
461  /* errno is saved here so that error parameter eval can't change it */
462  edata->saved_errno = errno;
463 
464  /*
465  * Any allocations for this error state level should go into ErrorContext
466  */
467  edata->assoc_context = ErrorContext;
468 
469  recursion_depth--;
470  return true;
471 }
#define Max(x, y)
Definition: c.h:991
#define PG_TEXTDOMAIN(domain)
Definition: c.h:1223
#define MemSet(start, val, len)
Definition: c.h:1019
static bool should_output_to_client(int elevel)
Definition: elog.c:237
int errmsg_internal(const char *fmt,...)
Definition: elog.c:991
static bool should_output_to_server(int elevel)
Definition: elog.c:228
void write_stderr(const char *fmt,...)
Definition: elog.c:3369
bool in_error_recursion_trouble(void)
Definition: elog.c:286
#define ERRORDATA_STACK_SIZE
Definition: elog.c:143
bool ExitOnAnyError
Definition: globals.c:117
bool proc_exit_inprogress
Definition: ipc.c:40
int i
Definition: isn.c:73
exit(1)
void MemoryContextReset(MemoryContext context)
Definition: mcxt.c:143
const char * domain
Definition: elog.h:365
const char * context_domain
Definition: elog.h:366

References ErrorData::assoc_context, ErrorData::context_domain, CritSectionCount, debug_query_string, ErrorData::domain, ErrorData::elevel, ereport, errmsg_internal(), ERROR, error_context_stack, ErrorContext, errordata, errordata_stack_depth, ERRORDATA_STACK_SIZE, exit(), ExitOnAnyError, FATAL, i, in_error_recursion_trouble(), Max, MemoryContextReset(), MemSet, ErrorData::output_to_client, ErrorData::output_to_server, PANIC, PG_exception_stack, PG_TEXTDOMAIN, proc_exit_inprogress, recursion_depth, ErrorData::saved_errno, should_output_to_client(), should_output_to_server(), ErrorData::sqlerrcode, WARNING, and write_stderr().

Referenced by errstart_cold(), and ThrowErrorData().

◆ errstart_cold()

pg_attribute_cold bool errstart_cold ( int  elevel,
const char *  domain 
)

Definition at line 319 of file elog.c.

320 {
321  return errstart(elevel, domain);
322 }
bool errstart(int elevel, const char *domain)
Definition: elog.c:335

References errstart().

◆ FlushErrorState()

void FlushErrorState ( void  )

Definition at line 1649 of file elog.c.

1650 {
1651  /*
1652  * Reset stack to empty. The only case where it would be more than one
1653  * deep is if we serviced an error that interrupted construction of
1654  * another message. We assume control escaped out of that message
1655  * construction and won't ever go back.
1656  */
1657  errordata_stack_depth = -1;
1658  recursion_depth = 0;
1659  /* Delete all data in ErrorContext */
1661 }
#define MemoryContextResetAndDeleteChildren(ctx)
Definition: memutils.h:67

References ErrorContext, errordata_stack_depth, MemoryContextResetAndDeleteChildren, and recursion_depth.

Referenced by _SPI_commit(), _SPI_rollback(), AutoVacLauncherMain(), BackgroundWriterMain(), basic_archive_file(), call_bool_check_hook(), call_enum_check_hook(), call_int_check_hook(), call_real_check_hook(), call_string_check_hook(), CheckpointerMain(), DisableSubscriptionAndExit(), do_autovacuum(), exec_stmt_block(), ExecEvalJsonExprSubtrans(), GetConnection(), initTrie(), perform_work_item(), plperl_return_next(), plperl_spi_commit(), plperl_spi_exec(), plperl_spi_exec_prepared(), plperl_spi_fetchrow(), plperl_spi_prepare(), plperl_spi_query(), plperl_spi_query_prepared(), plperl_spi_rollback(), plperl_util_elog(), pltcl_commit(), pltcl_elog(), pltcl_rollback(), pltcl_subtrans_abort(), PLy_commit(), PLy_output(), PLy_rollback(), PLy_spi_subtransaction_abort(), PostgresMain(), ReorderBufferProcessTXN(), WalWriterMain(), and xml_is_document().

◆ format_elog_string()

char* format_elog_string ( const char *  fmt,
  ... 
)

◆ FreeErrorData()

void FreeErrorData ( ErrorData edata)

Definition at line 1611 of file elog.c.

1612 {
1613  if (edata->message)
1614  pfree(edata->message);
1615  if (edata->detail)
1616  pfree(edata->detail);
1617  if (edata->detail_log)
1618  pfree(edata->detail_log);
1619  if (edata->hint)
1620  pfree(edata->hint);
1621  if (edata->context)
1622  pfree(edata->context);
1623  if (edata->backtrace)
1624  pfree(edata->backtrace);
1625  if (edata->schema_name)
1626  pfree(edata->schema_name);
1627  if (edata->table_name)
1628  pfree(edata->table_name);
1629  if (edata->column_name)
1630  pfree(edata->column_name);
1631  if (edata->datatype_name)
1632  pfree(edata->datatype_name);
1633  if (edata->constraint_name)
1634  pfree(edata->constraint_name);
1635  if (edata->internalquery)
1636  pfree(edata->internalquery);
1637  pfree(edata);
1638 }

References ErrorData::backtrace, ErrorData::column_name, ErrorData::constraint_name, ErrorData::context, ErrorData::datatype_name, ErrorData::detail, ErrorData::detail_log, ErrorData::hint, ErrorData::internalquery, ErrorData::message, pfree(), ErrorData::schema_name, and ErrorData::table_name.

Referenced by GetConnection(), pltcl_commit(), pltcl_elog(), pltcl_rollback(), pltcl_subtrans_abort(), PLy_commit(), PLy_output(), PLy_rollback(), PLy_spi_subtransaction_abort(), and ReorderBufferProcessTXN().

◆ get_backend_type_for_log()

const char* get_backend_type_for_log ( void  )

Definition at line 2391 of file elog.c.

2392 {
2393  const char *backend_type_str;
2394 
2395  if (MyProcPid == PostmasterPid)
2396  backend_type_str = "postmaster";
2397  else if (MyBackendType == B_BG_WORKER)
2398  backend_type_str = MyBgworkerEntry->bgw_type;
2399  else
2400  backend_type_str = GetBackendTypeDesc(MyBackendType);
2401 
2402  return backend_type_str;
2403 }
pid_t PostmasterPid
Definition: globals.c:99
int MyProcPid
Definition: globals.c:44
@ B_BG_WORKER
Definition: miscadmin.h:330
const char * GetBackendTypeDesc(BackendType backendType)
Definition: miscinit.c:249
BackendType MyBackendType
Definition: miscinit.c:63
BackgroundWorker * MyBgworkerEntry
Definition: postmaster.c:197
char bgw_type[BGW_MAXLEN]
Definition: bgworker.h:92

References B_BG_WORKER, BackgroundWorker::bgw_type, GetBackendTypeDesc(), MyBackendType, MyBgworkerEntry, MyProcPid, and PostmasterPid.

Referenced by log_line_prefix(), write_csvlog(), and write_jsonlog().

◆ get_formatted_log_time()

char* get_formatted_log_time ( void  )

Definition at line 2294 of file elog.c.

2295 {
2296  pg_time_t stamp_time;
2297  char msbuf[13];
2298 
2299  /* leave if already computed */
2300  if (formatted_log_time[0] != '\0')
2301  return formatted_log_time;
2302 
2303  if (!saved_timeval_set)
2304  {
2305  gettimeofday(&saved_timeval, NULL);
2306  saved_timeval_set = true;
2307  }
2308 
2309  stamp_time = (pg_time_t) saved_timeval.tv_sec;
2310 
2311  /*
2312  * Note: we expect that guc.c will ensure that log_timezone is set up (at
2313  * least with a minimal GMT value) before Log_line_prefix can become
2314  * nonempty or CSV mode can be selected.
2315  */
2317  /* leave room for milliseconds... */
2318  "%Y-%m-%d %H:%M:%S %Z",
2319  pg_localtime(&stamp_time, log_timezone));
2320 
2321  /* 'paste' milliseconds into place... */
2322  sprintf(msbuf, ".%03d", (int) (saved_timeval.tv_usec / 1000));
2323  memcpy(formatted_log_time + 19, msbuf, 4);
2324 
2325  return formatted_log_time;
2326 }
static char formatted_log_time[FORMATTED_TS_LEN]
Definition: elog.c:160
#define FORMATTED_TS_LEN
Definition: elog.c:158
static bool saved_timeval_set
Definition: elog.c:156
static struct timeval saved_timeval
Definition: elog.c:155
int gettimeofday(struct timeval *tp, struct timezone *tzp)
Definition: gettimeofday.c:104
size_t pg_strftime(char *s, size_t max, const char *format, const struct pg_tm *tm)
Definition: strftime.c:128
int64 pg_time_t
Definition: pgtime.h:23
struct pg_tm * pg_localtime(const pg_time_t *timep, const pg_tz *tz)
Definition: localtime.c:1342
PGDLLIMPORT pg_tz * log_timezone
Definition: pgtz.c:31
#define sprintf
Definition: port.h:227

References formatted_log_time, FORMATTED_TS_LEN, gettimeofday(), log_timezone, pg_localtime(), pg_strftime(), saved_timeval, saved_timeval_set, and sprintf.

Referenced by log_line_prefix(), write_csvlog(), and write_jsonlog().

◆ get_formatted_start_time()

char* get_formatted_start_time ( void  )

Definition at line 2344 of file elog.c.

2345 {
2346  pg_time_t stamp_time = (pg_time_t) MyStartTime;
2347 
2348  /* leave if already computed */
2349  if (formatted_start_time[0] != '\0')
2350  return formatted_start_time;
2351 
2352  /*
2353  * Note: we expect that guc.c will ensure that log_timezone is set up (at
2354  * least with a minimal GMT value) before Log_line_prefix can become
2355  * nonempty or CSV mode can be selected.
2356  */
2358  "%Y-%m-%d %H:%M:%S %Z",
2359  pg_localtime(&stamp_time, log_timezone));
2360 
2361  return formatted_start_time;
2362 }
static char formatted_start_time[FORMATTED_TS_LEN]
Definition: elog.c:159
pg_time_t MyStartTime
Definition: globals.c:45

References formatted_start_time, FORMATTED_TS_LEN, log_timezone, MyStartTime, pg_localtime(), and pg_strftime().

Referenced by log_line_prefix(), write_csvlog(), and write_jsonlog().

◆ geterrcode()

int geterrcode ( void  )

Definition at line 1395 of file elog.c.

1396 {
1398 
1399  /* we don't bother incrementing recursion_depth */
1401 
1402  return edata->sqlerrcode;
1403 }

References CHECK_STACK_DEPTH, errordata, errordata_stack_depth, and ErrorData::sqlerrcode.

Referenced by pcb_error_callback().

◆ GetErrorContextStack()

char* GetErrorContextStack ( void  )

Definition at line 1850 of file elog.c.

1851 {
1852  ErrorData *edata;
1853  ErrorContextCallback *econtext;
1854 
1855  /*
1856  * Okay, crank up a stack entry to store the info in.
1857  */
1858  recursion_depth++;
1859 
1861  {
1862  /*
1863  * Wups, stack not big enough. We treat this as a PANIC condition
1864  * because it suggests an infinite loop of errors during error
1865  * recovery.
1866  */
1867  errordata_stack_depth = -1; /* make room on stack */
1868  ereport(PANIC, (errmsg_internal("ERRORDATA_STACK_SIZE exceeded")));
1869  }
1870 
1871  /*
1872  * Things look good so far, so initialize our error frame
1873  */
1874  edata = &errordata[errordata_stack_depth];
1875  MemSet(edata, 0, sizeof(ErrorData));
1876 
1877  /*
1878  * Set up assoc_context to be the caller's context, so any allocations
1879  * done (which will include edata->context) will use their context.
1880  */
1882 
1883  /*
1884  * Call any context callback functions to collect the context information
1885  * into edata->context.
1886  *
1887  * Errors occurring in callback functions should go through the regular
1888  * error handling code which should handle any recursive errors, though we
1889  * double-check above, just in case.
1890  */
1891  for (econtext = error_context_stack;
1892  econtext != NULL;
1893  econtext = econtext->previous)
1894  econtext->callback(econtext->arg);
1895 
1896  /*
1897  * Clean ourselves off the stack, any allocations done should have been
1898  * using edata->assoc_context, which we set up earlier to be the caller's
1899  * context, so we're free to just remove our entry off the stack and
1900  * decrement recursion depth and exit.
1901  */
1903  recursion_depth--;
1904 
1905  /*
1906  * Return a pointer to the string the caller asked for, which should have
1907  * been allocated in their context.
1908  */
1909  return edata->context;
1910 }

References ErrorContextCallback::arg, ErrorData::assoc_context, ErrorContextCallback::callback, ErrorData::context, CurrentMemoryContext, ereport, errmsg_internal(), error_context_stack, errordata, errordata_stack_depth, ERRORDATA_STACK_SIZE, MemSet, PANIC, ErrorContextCallback::previous, and recursion_depth.

Referenced by exec_stmt_getdiag().

◆ geterrposition()

int geterrposition ( void  )

Definition at line 1412 of file elog.c.

1413 {
1415 
1416  /* we don't bother incrementing recursion_depth */
1418 
1419  return edata->cursorpos;
1420 }

References CHECK_STACK_DEPTH, ErrorData::cursorpos, errordata, and errordata_stack_depth.

Referenced by _SPI_error_callback(), function_parse_error_transpose(), import_error_callback(), sql_exec_error_callback(), and sql_inline_error_callback().

◆ getinternalerrposition()

int getinternalerrposition ( void  )

Definition at line 1429 of file elog.c.

1430 {
1432 
1433  /* we don't bother incrementing recursion_depth */
1435 
1436  return edata->internalpos;
1437 }
int internalpos
Definition: elog.h:381

References CHECK_STACK_DEPTH, errordata, errordata_stack_depth, and ErrorData::internalpos.

Referenced by function_parse_error_transpose().

◆ in_error_recursion_trouble()

bool in_error_recursion_trouble ( void  )

Definition at line 286 of file elog.c.

287 {
288  /* Pull the plug if recurse more than once */
289  return (recursion_depth > 2);
290 }

References recursion_depth.

Referenced by err_gettext(), err_sendstring(), errstart(), pgfdw_abort_cleanup(), and write_console().

◆ internalerrposition()

int internalerrposition ( int  cursorpos)

Definition at line 1296 of file elog.c.

1297 {
1299 
1300  /* we don't bother incrementing recursion_depth */
1302 
1303  edata->internalpos = cursorpos;
1304 
1305  return 0; /* return value does not matter */
1306 }

References CHECK_STACK_DEPTH, errordata, errordata_stack_depth, and ErrorData::internalpos.

Referenced by _SPI_error_callback(), function_parse_error_transpose(), import_error_callback(), plpgsql_scanner_errposition(), PLy_elog_impl(), sql_exec_error_callback(), and sql_inline_error_callback().

◆ internalerrquery()

int internalerrquery ( const char *  query)

Definition at line 1316 of file elog.c.

1317 {
1319 
1320  /* we don't bother incrementing recursion_depth */
1322 
1323  if (edata->internalquery)
1324  {
1325  pfree(edata->internalquery);
1326  edata->internalquery = NULL;
1327  }
1328 
1329  if (query)
1330  edata->internalquery = MemoryContextStrdup(edata->assoc_context, query);
1331 
1332  return 0; /* return value does not matter */
1333 }
char * MemoryContextStrdup(MemoryContext context, const char *string)
Definition: mcxt.c:1292

References ErrorData::assoc_context, CHECK_STACK_DEPTH, errordata, errordata_stack_depth, ErrorData::internalquery, MemoryContextStrdup(), and pfree().

Referenced by _SPI_error_callback(), function_parse_error_transpose(), import_error_callback(), plpgsql_scanner_errposition(), PLy_elog_impl(), sql_exec_error_callback(), and sql_inline_error_callback().

◆ message_level_is_interesting()

bool message_level_is_interesting ( int  elevel)

Definition at line 265 of file elog.c.

266 {
267  /*
268  * Keep this in sync with the decision-making in errstart().
269  */
270  if (elevel >= ERROR ||
271  should_output_to_server(elevel) ||
272  should_output_to_client(elevel))
273  return true;
274  return false;
275 }

References ERROR, should_output_to_client(), and should_output_to_server().

Referenced by forget_invalid_pages(), forget_invalid_pages_db(), log_invalid_page(), ProcessStandbyHSFeedbackMessage(), ProcessStandbyReplyMessage(), ProcessWalSndrMessage(), ProcSleep(), reportDependentObjects(), and ShowTransactionState().

◆ pg_attribute_printf()

int int pg_attribute_printf ( ,
 
)

◆ pg_re_throw()

void pg_re_throw ( void  )

Definition at line 1794 of file elog.c.

1795 {
1796  /* If possible, throw the error to the next outer setjmp handler */
1797  if (PG_exception_stack != NULL)
1798  siglongjmp(*PG_exception_stack, 1);
1799  else
1800  {
1801  /*
1802  * If we get here, elog(ERROR) was thrown inside a PG_TRY block, which
1803  * we have now exited only to discover that there is no outer setjmp
1804  * handler to pass the error to. Had the error been thrown outside
1805  * the block to begin with, we'd have promoted the error to FATAL, so
1806  * the correct behavior is to make it FATAL now; that is, emit it and
1807  * then call proc_exit.
1808  */
1810 
1812  Assert(edata->elevel == ERROR);
1813  edata->elevel = FATAL;
1814 
1815  /*
1816  * At least in principle, the increase in severity could have changed
1817  * where-to-output decisions, so recalculate.
1818  */
1821 
1822  /*
1823  * We can use errfinish() for the rest, but we don't want it to call
1824  * any error context routines a second time. Since we know we are
1825  * about to exit, it should be OK to just clear the context stack.
1826  */
1827  error_context_stack = NULL;
1828 
1829  errfinish(edata->filename, edata->lineno, edata->funcname);
1830  }
1831 
1832  /* Doesn't return ... */
1833  ExceptionalCondition("pg_re_throw tried to return", "FailedAssertion",
1834  __FILE__, __LINE__);
1835 }
void ExceptionalCondition(const char *conditionName, const char *errorType, const char *fileName, int lineNumber)
Definition: assert.c:30
void errfinish(const char *filename, int lineno, const char *funcname)
Definition: elog.c:508

References Assert(), ErrorData::elevel, errfinish(), ERROR, error_context_stack, errordata, errordata_stack_depth, ExceptionalCondition(), FATAL, ErrorData::filename, ErrorData::funcname, ErrorData::lineno, ErrorData::output_to_client, ErrorData::output_to_server, PG_exception_stack, should_output_to_client(), and should_output_to_server().

◆ pre_format_elog_string()

void pre_format_elog_string ( int  errnumber,
const char *  domain 
)

Definition at line 1462 of file elog.c.

1463 {
1464  /* Save errno before evaluation of argument functions can change it */
1465  save_format_errnumber = errnumber;
1466  /* Save caller's text domain */
1467  save_format_domain = domain;
1468 }
static int save_format_errnumber
Definition: elog.c:1458
static const char * save_format_domain
Definition: elog.c:1459

References save_format_domain, and save_format_errnumber.

◆ reset_formatted_start_time()

void reset_formatted_start_time ( void  )

Definition at line 2332 of file elog.c.

2333 {
2334  formatted_start_time[0] = '\0';
2335 }

References formatted_start_time.

Referenced by log_line_prefix(), write_csvlog(), and write_jsonlog().

◆ ReThrowError()

void ReThrowError ( ErrorData edata)

Definition at line 1733 of file elog.c.

1734 {
1735  ErrorData *newedata;
1736 
1737  Assert(edata->elevel == ERROR);
1738 
1739  /* Push the data back into the error context */
1740  recursion_depth++;
1742 
1744  {
1745  /*
1746  * Wups, stack not big enough. We treat this as a PANIC condition
1747  * because it suggests an infinite loop of errors during error
1748  * recovery.
1749  */
1750  errordata_stack_depth = -1; /* make room on stack */
1751  ereport(PANIC, (errmsg_internal("ERRORDATA_STACK_SIZE exceeded")));
1752  }
1753 
1754  newedata = &errordata[errordata_stack_depth];
1755  memcpy(newedata, edata, sizeof(ErrorData));
1756 
1757  /* Make copies of separately-allocated fields */
1758  if (newedata->message)
1759  newedata->message = pstrdup(newedata->message);
1760  if (newedata->detail)
1761  newedata->detail = pstrdup(newedata->detail);
1762  if (newedata->detail_log)
1763  newedata->detail_log = pstrdup(newedata->detail_log);
1764  if (newedata->hint)
1765  newedata->hint = pstrdup(newedata->hint);
1766  if (newedata->context)
1767  newedata->context = pstrdup(newedata->context);
1768  if (newedata->backtrace)
1769  newedata->backtrace = pstrdup(newedata->backtrace);
1770  if (newedata->schema_name)
1771  newedata->schema_name = pstrdup(newedata->schema_name);
1772  if (newedata->table_name)
1773  newedata->table_name = pstrdup(newedata->table_name);
1774  if (newedata->column_name)
1775  newedata->column_name = pstrdup(newedata->column_name);
1776  if (newedata->datatype_name)
1777  newedata->datatype_name = pstrdup(newedata->datatype_name);
1778  if (newedata->constraint_name)
1779  newedata->constraint_name = pstrdup(newedata->constraint_name);
1780  if (newedata->internalquery)
1781  newedata->internalquery = pstrdup(newedata->internalquery);
1782 
1783  /* Reset the assoc_context to be ErrorContext */
1784  newedata->assoc_context = ErrorContext;
1785 
1786  recursion_depth--;
1787  PG_RE_THROW();
1788 }

References Assert(), ErrorData::assoc_context, ErrorData::backtrace, ErrorData::column_name, ErrorData::constraint_name, ErrorData::context, ErrorData::datatype_name, ErrorData::detail, ErrorData::detail_log, ErrorData::elevel, ereport, errmsg_internal(), ERROR, ErrorContext, errordata, errordata_stack_depth, ERRORDATA_STACK_SIZE, ErrorData::hint, ErrorData::internalquery, MemoryContextSwitchTo(), ErrorData::message, PANIC, PG_RE_THROW, pstrdup(), recursion_depth, ErrorData::schema_name, and ErrorData::table_name.

Referenced by _SPI_commit(), _SPI_rollback(), exec_stmt_block(), exec_stmt_raise(), and ExecEvalJsonExprSubtrans().

◆ set_errcontext_domain()

int set_errcontext_domain ( const char *  domain)

Definition at line 1225 of file elog.c.

1226 {
1228 
1229  /* we don't bother incrementing recursion_depth */
1231 
1232  /* the default text domain is the backend's */
1233  edata->context_domain = domain ? domain : PG_TEXTDOMAIN("postgres");
1234 
1235  return 0; /* return value does not matter */
1236 }

References CHECK_STACK_DEPTH, ErrorData::context_domain, errordata, errordata_stack_depth, and PG_TEXTDOMAIN.

◆ ThrowErrorData()

void ThrowErrorData ( ErrorData edata)

Definition at line 1674 of file elog.c.

1675 {
1676  ErrorData *newedata;
1677  MemoryContext oldcontext;
1678 
1679  if (!errstart(edata->elevel, edata->domain))
1680  return; /* error is not to be reported at all */
1681 
1682  newedata = &errordata[errordata_stack_depth];
1683  recursion_depth++;
1684  oldcontext = MemoryContextSwitchTo(newedata->assoc_context);
1685 
1686  /* Copy the supplied fields to the error stack entry. */
1687  if (edata->sqlerrcode != 0)
1688  newedata->sqlerrcode = edata->sqlerrcode;
1689  if (edata->message)
1690  newedata->message = pstrdup(edata->message);
1691  if (edata->detail)
1692  newedata->detail = pstrdup(edata->detail);
1693  if (edata->detail_log)
1694  newedata->detail_log = pstrdup(edata->detail_log);
1695  if (edata->hint)
1696  newedata->hint = pstrdup(edata->hint);
1697  if (edata->context)
1698  newedata->context = pstrdup(edata->context);
1699  if (edata->backtrace)
1700  newedata->backtrace = pstrdup(edata->backtrace);
1701  /* assume message_id is not available */
1702  if (edata->schema_name)
1703  newedata->schema_name = pstrdup(edata->schema_name);
1704  if (edata->table_name)
1705  newedata->table_name = pstrdup(edata->table_name);
1706  if (edata->column_name)
1707  newedata->column_name = pstrdup(edata->column_name);
1708  if (edata->datatype_name)
1709  newedata->datatype_name = pstrdup(edata->datatype_name);
1710  if (edata->constraint_name)
1711  newedata->constraint_name = pstrdup(edata->constraint_name);
1712  newedata->cursorpos = edata->cursorpos;
1713  newedata->internalpos = edata->internalpos;
1714  if (edata->internalquery)
1715  newedata->internalquery = pstrdup(edata->internalquery);
1716 
1717  MemoryContextSwitchTo(oldcontext);
1718  recursion_depth--;
1719 
1720  /* Process the error. */
1721  errfinish(edata->filename, edata->lineno, edata->funcname);
1722 }

References ErrorData::assoc_context, ErrorData::backtrace, ErrorData::column_name, ErrorData::constraint_name, ErrorData::context, ErrorData::cursorpos, ErrorData::datatype_name, ErrorData::detail, ErrorData::detail_log, ErrorData::domain, ErrorData::elevel, errfinish(), errordata, errordata_stack_depth, errstart(), ErrorData::filename, ErrorData::funcname, ErrorData::hint, ErrorData::internalpos, ErrorData::internalquery, ErrorData::lineno, MemoryContextSwitchTo(), ErrorData::message, pstrdup(), recursion_depth, ErrorData::schema_name, ErrorData::sqlerrcode, and ErrorData::table_name.

Referenced by HandleParallelMessage().

◆ unpack_sql_state()

char* unpack_sql_state ( int  sql_state)

Definition at line 2797 of file elog.c.

2798 {
2799  static char buf[12];
2800  int i;
2801 
2802  for (i = 0; i < 5; i++)
2803  {
2804  buf[i] = PGUNSIXBIT(sql_state);
2805  sql_state >>= 6;
2806  }
2807 
2808  buf[i] = '\0';
2809  return buf;
2810 }
#define PGUNSIXBIT(val)
Definition: elog.h:48
static char * buf
Definition: pg_test_fsync.c:67

References buf, i, and PGUNSIXBIT.

Referenced by exec_stmt_block(), exec_stmt_getdiag(), exec_stmt_raise(), log_line_prefix(), pltcl_construct_errorCode(), PLy_exception_set_with_details(), PLy_generate_spi_exceptions(), send_message_to_frontend(), send_message_to_server_log(), write_csvlog(), and write_jsonlog().

◆ write_csvlog()

void write_csvlog ( ErrorData edata)

Definition at line 65 of file csvlog.c.

66 {
68  bool print_stmt = false;
69 
70  /* static counter for line numbers */
71  static long log_line_number = 0;
72 
73  /* has counter been reset in current process? */
74  static int log_my_pid = 0;
75 
76  /*
77  * This is one of the few places where we'd rather not inherit a static
78  * variable's value from the postmaster. But since we will, reset it when
79  * MyProcPid changes.
80  */
81  if (log_my_pid != MyProcPid)
82  {
83  log_line_number = 0;
84  log_my_pid = MyProcPid;
86  }
87  log_line_number++;
88 
90 
91  /* timestamp with milliseconds */
94 
95  /* username */
96  if (MyProcPort)
99 
100  /* database name */
101  if (MyProcPort)
103  appendStringInfoChar(&buf, ',');
104 
105  /* Process id */
106  if (MyProcPid != 0)
107  appendStringInfo(&buf, "%d", MyProcPid);
108  appendStringInfoChar(&buf, ',');
109 
110  /* Remote host and port */
112  {
113  appendStringInfoChar(&buf, '"');
115  if (MyProcPort->remote_port && MyProcPort->remote_port[0] != '\0')
116  {
117  appendStringInfoChar(&buf, ':');
119  }
120  appendStringInfoChar(&buf, '"');
121  }
122  appendStringInfoChar(&buf, ',');
123 
124  /* session id */
125  appendStringInfo(&buf, "%lx.%x", (long) MyStartTime, MyProcPid);
126  appendStringInfoChar(&buf, ',');
127 
128  /* Line number */
129  appendStringInfo(&buf, "%ld", log_line_number);
130  appendStringInfoChar(&buf, ',');
131 
132  /* PS display */
133  if (MyProcPort)
134  {
135  StringInfoData msgbuf;
136  const char *psdisp;
137  int displen;
138 
139  initStringInfo(&msgbuf);
140 
141  psdisp = get_ps_display(&displen);
142  appendBinaryStringInfo(&msgbuf, psdisp, displen);
143  appendCSVLiteral(&buf, msgbuf.data);
144 
145  pfree(msgbuf.data);
146  }
147  appendStringInfoChar(&buf, ',');
148 
149  /* session start timestamp */
151  appendStringInfoChar(&buf, ',');
152 
153  /* Virtual transaction id */
154  /* keep VXID format in sync with lockfuncs.c */
155  if (MyProc != NULL && MyProc->backendId != InvalidBackendId)
157  appendStringInfoChar(&buf, ',');
158 
159  /* Transaction id */
161  appendStringInfoChar(&buf, ',');
162 
163  /* Error severity */
165  appendStringInfoChar(&buf, ',');
166 
167  /* SQL state code */
169  appendStringInfoChar(&buf, ',');
170 
171  /* errmessage */
172  appendCSVLiteral(&buf, edata->message);
173  appendStringInfoChar(&buf, ',');
174 
175  /* errdetail or errdetail_log */
176  if (edata->detail_log)
177  appendCSVLiteral(&buf, edata->detail_log);
178  else
179  appendCSVLiteral(&buf, edata->detail);
180  appendStringInfoChar(&buf, ',');
181 
182  /* errhint */
183  appendCSVLiteral(&buf, edata->hint);
184  appendStringInfoChar(&buf, ',');
185 
186  /* internal query */
188  appendStringInfoChar(&buf, ',');
189 
190  /* if printed internal query, print internal pos too */
191  if (edata->internalpos > 0 && edata->internalquery != NULL)
192  appendStringInfo(&buf, "%d", edata->internalpos);
193  appendStringInfoChar(&buf, ',');
194 
195  /* errcontext */
196  if (!edata->hide_ctx)
197  appendCSVLiteral(&buf, edata->context);
198  appendStringInfoChar(&buf, ',');
199 
200  /* user query --- only reported if not disabled by the caller */
201  print_stmt = check_log_of_query(edata);
202  if (print_stmt)
204  appendStringInfoChar(&buf, ',');
205  if (print_stmt && edata->cursorpos > 0)
206  appendStringInfo(&buf, "%d", edata->cursorpos);
207  appendStringInfoChar(&buf, ',');
208 
209  /* file error location */
211  {
212  StringInfoData msgbuf;
213 
214  initStringInfo(&msgbuf);
215 
216  if (edata->funcname && edata->filename)
217  appendStringInfo(&msgbuf, "%s, %s:%d",
218  edata->funcname, edata->filename,
219  edata->lineno);
220  else if (edata->filename)
221  appendStringInfo(&msgbuf, "%s:%d",
222  edata->filename, edata->lineno);
223  appendCSVLiteral(&buf, msgbuf.data);
224  pfree(msgbuf.data);
225  }
226  appendStringInfoChar(&buf, ',');
227 
228  /* application name */
229  if (application_name)
231 
232  appendStringInfoChar(&buf, ',');
233 
234  /* backend type */
236  appendStringInfoChar(&buf, ',');
237 
238  /* leader PID */
239  if (MyProc)
240  {
241  PGPROC *leader = MyProc->lockGroupLeader;
242 
243  /*
244  * Show the leader only for active parallel workers. This leaves out
245  * the leader of a parallel group.
246  */
247  if (leader && leader->pid != MyProcPid)
248  appendStringInfo(&buf, "%d", leader->pid);
249  }
250  appendStringInfoChar(&buf, ',');
251 
252  /* query id */
253  appendStringInfo(&buf, "%lld", (long long) pgstat_get_my_query_id());
254 
255  appendStringInfoChar(&buf, '\n');
256 
257  /* If in the syslogger process, try to write messages direct to file */
258  if (MyBackendType == B_LOGGER)
260  else
262 
263  pfree(buf.data);
264 }
uint64 pgstat_get_my_query_id(void)
#define InvalidBackendId
Definition: backendid.h:23
static void appendCSVLiteral(StringInfo buf, const char *data)
Definition: csvlog.c:39
bool check_log_of_query(ErrorData *edata)
Definition: elog.c:2368
char * get_formatted_log_time(void)
Definition: elog.c:2294
int Log_error_verbosity
Definition: elog.c:109
const char * error_severity(int elevel)
Definition: elog.c:3298
const char * get_backend_type_for_log(void)
Definition: elog.c:2391
void write_pipe_chunks(char *data, int len, int dest)
Definition: elog.c:3060
char * unpack_sql_state(int sql_state)
Definition: elog.c:2797
char * get_formatted_start_time(void)
Definition: elog.c:2344
#define _(x)
Definition: elog.c:89
void reset_formatted_start_time(void)
Definition: elog.c:2332
@ PGERROR_VERBOSE
Definition: elog.h:410
#define LOG_DESTINATION_CSVLOG
Definition: elog.h:424
struct Port * MyProcPort
Definition: globals.c:47
char * application_name
Definition: guc.c:661
@ B_LOGGER
Definition: miscadmin.h:338
const char * get_ps_display(int *displen)
Definition: ps_status.c:430
PGPROC * MyProc
Definition: proc.c:68
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:91
void appendBinaryStringInfo(StringInfo str, const char *data, int datalen)
Definition: stringinfo.c:227
void appendStringInfoString(StringInfo str, const char *s)
Definition: stringinfo.c:176
void appendStringInfoChar(StringInfo str, char ch)
Definition: stringinfo.c:188
void initStringInfo(StringInfo str)
Definition: stringinfo.c:59
Definition: proc.h:160
LocalTransactionId lxid
Definition: proc.h:181
BackendId backendId
Definition: proc.h:191
int pid
Definition: proc.h:184
PGPROC * lockGroupLeader
Definition: proc.h:289
char * user_name
Definition: libpq-be.h:145
char * remote_port
Definition: libpq-be.h:136
char * database_name
Definition: libpq-be.h:144
char * remote_host
Definition: libpq-be.h:131
void write_syslogger_file(const char *buffer, int count, int destination)
Definition: syslogger.c:1143
TransactionId GetTopTransactionIdIfAny(void)
Definition: xact.c:428

References _, appendBinaryStringInfo(), appendCSVLiteral(), appendStringInfo(), appendStringInfoChar(), appendStringInfoString(), application_name, B_LOGGER, PGPROC::backendId, buf, check_log_of_query(), ErrorData::context, ErrorData::cursorpos, StringInfoData::data, Port::database_name, debug_query_string, ErrorData::detail, ErrorData::detail_log, ErrorData::elevel, error_severity(), ErrorData::filename, ErrorData::funcname, get_backend_type_for_log(), get_formatted_log_time(), get_formatted_start_time(), get_ps_display(), GetTopTransactionIdIfAny(), ErrorData::hide_ctx, ErrorData::hint, initStringInfo(), ErrorData::internalpos, ErrorData::internalquery, InvalidBackendId, ErrorData::lineno, PGPROC::lockGroupLeader, LOG_DESTINATION_CSVLOG, Log_error_verbosity, PGPROC::lxid, ErrorData::message, MyBackendType, MyProc, MyProcPid, MyProcPort, MyStartTime, pfree(), PGERROR_VERBOSE, pgstat_get_my_query_id(), PGPROC::pid, Port::remote_host, Port::remote_port, reset_formatted_start_time(), ErrorData::sqlerrcode, unpack_sql_state(), Port::user_name, write_pipe_chunks(), and write_syslogger_file().

Referenced by send_message_to_server_log().

◆ write_jsonlog()

void write_jsonlog ( ErrorData edata)

Definition at line 111 of file jsonlog.c.

112 {
114  char *start_time;
115  char *log_time;
116 
117  /* static counter for line numbers */
118  static long log_line_number = 0;
119 
120  /* Has the counter been reset in the current process? */
121  static int log_my_pid = 0;
122 
123  /*
124  * This is one of the few places where we'd rather not inherit a static
125  * variable's value from the postmaster. But since we will, reset it when
126  * MyProcPid changes.
127  */
128  if (log_my_pid != MyProcPid)
129  {
130  log_line_number = 0;
131  log_my_pid = MyProcPid;
133  }
134  log_line_number++;
135 
137 
138  /* Initialize string */
139  appendStringInfoChar(&buf, '{');
140 
141  /* timestamp with milliseconds */
142  log_time = get_formatted_log_time();
143 
144  /*
145  * First property does not use appendJSONKeyValue as it does not have
146  * comma prefix.
147  */
148  escape_json(&buf, "timestamp");
149  appendStringInfoChar(&buf, ':');
150  escape_json(&buf, log_time);
151 
152  /* username */
153  if (MyProcPort)
154  appendJSONKeyValue(&buf, "user", MyProcPort->user_name, true);
155 
156  /* database name */
157  if (MyProcPort)
158  appendJSONKeyValue(&buf, "dbname", MyProcPort->database_name, true);
159 
160  /* Process ID */
161  if (MyProcPid != 0)
162  appendJSONKeyValueFmt(&buf, "pid", false, "%d", MyProcPid);
163 
164  /* Remote host and port */
166  {
167  appendJSONKeyValue(&buf, "remote_host", MyProcPort->remote_host, true);
168  if (MyProcPort->remote_port && MyProcPort->remote_port[0] != '\0')
169  appendJSONKeyValue(&buf, "remote_port", MyProcPort->remote_port, false);
170  }
171 
172  /* Session id */
173  appendJSONKeyValueFmt(&buf, "session_id", true, "%lx.%x",
174  (long) MyStartTime, MyProcPid);
175 
176  /* Line number */
177  appendJSONKeyValueFmt(&buf, "line_num", false, "%ld", log_line_number);
178 
179  /* PS display */
180  if (MyProcPort)
181  {
182  StringInfoData msgbuf;
183  const char *psdisp;
184  int displen;
185 
186  initStringInfo(&msgbuf);
187  psdisp = get_ps_display(&displen);
188  appendBinaryStringInfo(&msgbuf, psdisp, displen);
189  appendJSONKeyValue(&buf, "ps", msgbuf.data, true);
190 
191  pfree(msgbuf.data);
192  }
193 
194  /* session start timestamp */
196  appendJSONKeyValue(&buf, "session_start", start_time, true);
197 
198  /* Virtual transaction id */
199  /* keep VXID format in sync with lockfuncs.c */
200  if (MyProc != NULL && MyProc->backendId != InvalidBackendId)
201  appendJSONKeyValueFmt(&buf, "vxid", true, "%d/%u", MyProc->backendId,
202  MyProc->lxid);
203 
204  /* Transaction id */
205  appendJSONKeyValueFmt(&buf, "txid", false, "%u",
207 
208  /* Error severity */
209  if (edata->elevel)
210  appendJSONKeyValue(&buf, "error_severity",
211  (char *) error_severity(edata->elevel), true);
212 
213  /* SQL state code */
214  if (edata->sqlerrcode)
215  appendJSONKeyValue(&buf, "state_code",
216  unpack_sql_state(edata->sqlerrcode), true);
217 
218  /* errmessage */
219  appendJSONKeyValue(&buf, "message", edata->message, true);
220 
221  /* errdetail or error_detail log */
222  if (edata->detail_log)
223  appendJSONKeyValue(&buf, "detail", edata->detail_log, true);
224  else
225  appendJSONKeyValue(&buf, "detail", edata->detail, true);
226 
227  /* errhint */
228  if (edata->hint)
229  appendJSONKeyValue(&buf, "hint", edata->hint, true);
230 
231  /* internal query */
232  if (edata->internalquery)
233  appendJSONKeyValue(&buf, "internal_query", edata->internalquery,
234  true);
235 
236  /* if printed internal query, print internal pos too */
237  if (edata->internalpos > 0 && edata->internalquery != NULL)
238  appendJSONKeyValueFmt(&buf, "internal_position", false, "%d",
239  edata->internalpos);
240 
241  /* errcontext */
242  if (edata->context && !edata->hide_ctx)
243  appendJSONKeyValue(&buf, "context", edata->context, true);
244 
245  /* user query --- only reported if not disabled by the caller */
246  if (check_log_of_query(edata))
247  {
248  appendJSONKeyValue(&buf, "statement", debug_query_string, true);
249  if (edata->cursorpos > 0)
250  appendJSONKeyValueFmt(&buf, "cursor_position", false, "%d",
251  edata->cursorpos);
252  }
253 
254  /* file error location */
256  {
257  if (edata->funcname)
258  appendJSONKeyValue(&buf, "func_name", edata->funcname, true);
259  if (edata->filename)
260  {
261  appendJSONKeyValue(&buf, "file_name", edata->filename, true);
262  appendJSONKeyValueFmt(&buf, "file_line_num", false, "%d",
263  edata->lineno);
264  }
265  }
266 
267  /* Application name */
268  if (application_name && application_name[0] != '\0')
269  appendJSONKeyValue(&buf, "application_name", application_name, true);
270 
271  /* backend type */
272  appendJSONKeyValue(&buf, "backend_type", get_backend_type_for_log(), true);
273 
274  /* leader PID */
275  if (MyProc)
276  {
277  PGPROC *leader = MyProc->lockGroupLeader;
278 
279  /*
280  * Show the leader only for active parallel workers. This leaves out
281  * the leader of a parallel group.
282  */
283  if (leader && leader->pid != MyProcPid)
284  appendJSONKeyValueFmt(&buf, "leader_pid", false, "%d",
285  leader->pid);
286  }
287 
288  /* query id */
289  appendJSONKeyValueFmt(&buf, "query_id", false, "%lld",
290  (long long) pgstat_get_my_query_id());
291 
292  /* Finish string */
293  appendStringInfoChar(&buf, '}');
294  appendStringInfoChar(&buf, '\n');
295 
296  /* If in the syslogger process, try to write messages direct to file */
297  if (MyBackendType == B_LOGGER)
299  else
301 
302  pfree(buf.data);
303 }
#define LOG_DESTINATION_JSONLOG
Definition: elog.h:425
void escape_json(StringInfo buf, const char *str)
Definition: json.c:1580
static void static void appendJSONKeyValue(StringInfo buf, const char *key, const char *value, bool escape_value)
Definition: jsonlog.c:45
static void appendJSONKeyValueFmt(StringInfo buf, const char *key, bool escape_key, const char *fmt,...) pg_attribute_printf(4
Definition: jsonlog.c:72
static time_t start_time
Definition: pg_ctl.c:99

References appendBinaryStringInfo(), appendJSONKeyValue(), appendJSONKeyValueFmt(), appendStringInfoChar(), application_name, B_LOGGER, PGPROC::backendId, buf, check_log_of_query(), ErrorData::context, ErrorData::cursorpos, StringInfoData::data, Port::database_name, debug_query_string, ErrorData::detail, ErrorData::detail_log, ErrorData::elevel, error_severity(), escape_json(), ErrorData::filename, ErrorData::funcname, get_backend_type_for_log(), get_formatted_log_time(), get_formatted_start_time(), get_ps_display(), GetTopTransactionIdIfAny(), ErrorData::hide_ctx, ErrorData::hint, initStringInfo(), ErrorData::internalpos, ErrorData::internalquery, InvalidBackendId, ErrorData::lineno, PGPROC::lockGroupLeader, LOG_DESTINATION_JSONLOG, Log_error_verbosity, PGPROC::lxid, ErrorData::message, MyBackendType, MyProc, MyProcPid, MyProcPort, MyStartTime, pfree(), PGERROR_VERBOSE, pgstat_get_my_query_id(), PGPROC::pid, Port::remote_host, Port::remote_port, reset_formatted_start_time(), ErrorData::sqlerrcode, start_time, unpack_sql_state(), Port::user_name, write_pipe_chunks(), and write_syslogger_file().

Referenced by send_message_to_server_log().

◆ write_pipe_chunks()

void write_pipe_chunks ( char *  data,
int  len,
int  dest 
)

Definition at line 3060 of file elog.c.

3061 {
3062  PipeProtoChunk p;
3063  int fd = fileno(stderr);
3064  int rc;
3065 
3066  Assert(len > 0);
3067 
3068  p.proto.nuls[0] = p.proto.nuls[1] = '\0';
3069  p.proto.pid = MyProcPid;
3070  p.proto.flags = 0;
3073  else if (dest == LOG_DESTINATION_CSVLOG)
3075  else if (dest == LOG_DESTINATION_JSONLOG)
3077 
3078  /* write all but the last chunk */
3079  while (len > PIPE_MAX_PAYLOAD)
3080  {
3081  /* no need to set PIPE_PROTO_IS_LAST yet */
3083  memcpy(p.proto.data, data, PIPE_MAX_PAYLOAD);
3085  (void) rc;
3087  len -= PIPE_MAX_PAYLOAD;
3088  }
3089 
3090  /* write the last chunk */
3092  p.proto.len = len;
3093  memcpy(p.proto.data, data, len);
3094  rc = write(fd, &p, PIPE_HEADER_SIZE + len);
3095  (void) rc;
3096 }
#define LOG_DESTINATION_STDERR
Definition: elog.h:421
#define write(a, b, c)
Definition: win32.h:14
const void size_t len
const void * data
char data[FLEXIBLE_ARRAY_MEMBER]
Definition: syslogger.h:50
char nuls[2]
Definition: syslogger.h:46
#define PIPE_PROTO_DEST_JSONLOG
Definition: syslogger.h:67
#define PIPE_PROTO_IS_LAST
Definition: syslogger.h:63
#define PIPE_PROTO_DEST_CSVLOG
Definition: syslogger.h:66
#define PIPE_PROTO_DEST_STDERR
Definition: syslogger.h:65
#define PIPE_MAX_PAYLOAD
Definition: syslogger.h:60
#define PIPE_HEADER_SIZE
Definition: syslogger.h:59
PipeProtoHeader proto
Definition: syslogger.h:55

References Assert(), PipeProtoHeader::data, data, generate_unaccent_rules::dest, fd(), PipeProtoHeader::flags, PipeProtoHeader::len, len, LOG_DESTINATION_CSVLOG, LOG_DESTINATION_JSONLOG, LOG_DESTINATION_STDERR, MyProcPid, PipeProtoHeader::nuls, PipeProtoHeader::pid, PIPE_HEADER_SIZE, PIPE_MAX_PAYLOAD, PIPE_PROTO_DEST_CSVLOG, PIPE_PROTO_DEST_JSONLOG, PIPE_PROTO_DEST_STDERR, PIPE_PROTO_IS_LAST, PipeProtoChunk::proto, and write.

Referenced by send_message_to_server_log(), write_csvlog(), and write_jsonlog().

◆ write_stderr()

void write_stderr ( const char *  fmt,
  ... 
)

Variable Documentation

◆ emit_log_hook

PGDLLIMPORT emit_log_hook_type emit_log_hook
extern

Definition at line 106 of file elog.c.

Referenced by EmitErrorReport().

◆ error_context_stack

PGDLLIMPORT ErrorContextCallback* error_context_stack
extern

Definition at line 93 of file elog.c.

Referenced by _SPI_execute_plan(), _SPI_prepare_oneshot_plan(), _SPI_prepare_plan(), ApplyWalRecord(), AutoVacLauncherMain(), AutoVacWorkerMain(), BackgroundWriterMain(), basic_archive_file(), begin_cb_wrapper(), begin_prepare_cb_wrapper(), call_pltcl_start_proc(), cancel_parser_errposition_callback(), change_cb_wrapper(), CheckpointerMain(), commit_cb_wrapper(), commit_prepared_cb_wrapper(), compile_plperl_function(), CopyFrom(), CreateParallelContext(), do_compile(), errfinish(), errstart(), exec_bind_message(), exec_execute_message(), file_acquire_sample_rows(), fileIterateForeignScan(), filter_by_origin_cb_wrapper(), filter_prepare_cb_wrapper(), FlushBuffer(), FlushRelationBuffers(), fmgr_sql(), fmgr_sql_validator(), GetErrorContextStack(), HandleParallelMessage(), heap_vacuum_rel(), ImportForeignSchema(), inline_function(), inline_set_returning_function(), LogicalRepApplyLoop(), make_tuple_from_result_row(), message_cb_wrapper(), parallel_vacuum_main(), pg_re_throw(), plperl_event_trigger_handler(), plperl_func_handler(), plperl_inline_handler(), plperl_trigger_handler(), plpgsql_compile_inline(), plpgsql_exec_event_trigger(), plpgsql_exec_function(), plpgsql_exec_trigger(), plpython3_call_handler(), plpython3_inline_handler(), PLy_exec_function(), PLy_modify_tuple(), PostgresMain(), prepare_cb_wrapper(), proc_exit_prepare(), quickdie(), ReindexPartitions(), RestoreGUCState(), rollback_prepared_cb_wrapper(), setup_parser_errposition_callback(), shutdown_cb_wrapper(), SPI_cursor_open_internal(), SPI_plan_get_cached_plan(), StartBackgroundWorker(), startup_cb_wrapper(), stream_abort_cb_wrapper(), stream_change_cb_wrapper(), stream_commit_cb_wrapper(), stream_message_cb_wrapper(), stream_prepare_cb_wrapper(), stream_start_cb_wrapper(), stream_stop_cb_wrapper(), stream_truncate_cb_wrapper(), truncate_cb_wrapper(), tsearch_readline_begin(), tsearch_readline_end(), typeStringToTypeName(), WalWriterMain(), and XactLockTableWait().

◆ Log_destination

◆ Log_destination_string

PGDLLIMPORT char* Log_destination_string
extern

Definition at line 112 of file elog.c.

Referenced by PostmasterMain().

◆ Log_error_verbosity

PGDLLIMPORT int Log_error_verbosity
extern

Definition at line 109 of file elog.c.

Referenced by send_message_to_server_log(), write_csvlog(), and write_jsonlog().

◆ Log_line_prefix

PGDLLIMPORT char* Log_line_prefix
extern

Definition at line 110 of file elog.c.

Referenced by log_line_prefix().

◆ PG_exception_stack

◆ syslog_sequence_numbers

PGDLLIMPORT bool syslog_sequence_numbers
extern

Definition at line 113 of file elog.c.

◆ syslog_split_messages

PGDLLIMPORT bool syslog_split_messages
extern

Definition at line 114 of file elog.c.