1/*-------------------------------------------------------------------------
6 * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
11 * src/backend/utils/error/csvlog.c
13 *-------------------------------------------------------------------------
32 * append a CSV'd version of a string to a StringInfo
33 * We use the PostgreSQL defaults for CSV, i.e. quote = escape = '"'
34 * If it's NULL, append nothing.
42 /* avoid confusing an empty string with NULL */
47 while ((
c = *p++) !=
'0円')
57 * write_csvlog -- Generate and write CSV log entry
59 * Constructs the error message, depending on the Errordata it gets, in a CSV
60 * format which is described in doc/src/sgml/config.sgml.
66 bool print_stmt =
false;
68 /* static counter for line numbers */
69 static long log_line_number = 0;
71 /* has counter been reset in current process? */
72 static int log_my_pid = 0;
75 * This is one of the few places where we'd rather not inherit a static
76 * variable's value from the postmaster. But since we will, reset it when
89 /* timestamp with milliseconds */
108 /* Remote host and port */
147 /* session start timestamp */
151 /* Virtual transaction id */
152 /* keep VXID format in sync with lockfuncs.c */
173 /* errdetail or errdetail_log */
188 /* if printed internal query, print internal pos too */
198 /* user query --- only reported if not disabled by the caller */
207 /* file error location */
226 /* application name */
242 * Show the leader only for active parallel workers. This leaves out
243 * the leader of a parallel group.
255 /* If in the syslogger process, try to write messages direct to file */
int64 pgstat_get_my_query_id(void)
static void appendCSVLiteral(StringInfo buf, const char *data)
void write_csvlog(ErrorData *edata)
bool check_log_of_query(ErrorData *edata)
const char * error_severity(int elevel)
char * get_formatted_start_time(void)
void write_pipe_chunks(char *data, int len, int dest)
const char * get_backend_type_for_log(void)
char * get_formatted_log_time(void)
char * unpack_sql_state(int sql_state)
void reset_formatted_start_time(void)
#define LOG_DESTINATION_CSVLOG
void pfree(void *pointer)
BackendType MyBackendType
const char * debug_query_string
#define INVALID_PROC_NUMBER
const char * get_ps_display(int *displen)
void appendStringInfo(StringInfo str, const char *fmt,...)
void appendBinaryStringInfo(StringInfo str, const void *data, int datalen)
void appendStringInfoString(StringInfo str, const char *s)
void appendStringInfoChar(StringInfo str, char ch)
void initStringInfo(StringInfo str)
#define appendStringInfoCharMacro(str, ch)
void write_syslogger_file(const char *buffer, int count, int destination)
TransactionId GetTopTransactionIdIfAny(void)