diff options
author | Bruce Momjian <bruce@momjian.us> | 2014-05-06 12:12:18 -0400 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2014-05-06 12:12:18 -0400 |
commit | 0a7832005792fa6dad171f9cadb8d587fe0dd800 (patch) | |
tree | 365cfc42c521a52607e41394b08ef44d338d8fc1 /src/backend/utils/error | |
parent | fb85cd4320414c3f6e9c8bc69ec944200ae1e493 (diff) | |
download | postgresql-0a7832005792fa6dad171f9cadb8d587fe0dd800.tar.gz postgresql-0a7832005792fa6dad171f9cadb8d587fe0dd800.zip |
pgindent run for 9.4
This includes removing tabs after periods in C comments, which was
applied to back branches, so this change should not effect backpatching.
Diffstat (limited to 'src/backend/utils/error')
-rw-r--r-- | src/backend/utils/error/elog.c | 99 |
1 files changed, 52 insertions, 47 deletions
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index 977fc66418c..0d92dcd036c 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -5,7 +5,7 @@ * * Because of the extremely high rate at which log messages can be generated, * we need to be mindful of the performance cost of obtaining any information - * that may be logged. Also, it's important to keep in mind that this code may + * that may be logged. Also, it's important to keep in mind that this code may * get called from within an aborted transaction, in which case operations * such as syscache lookups are unsafe. * @@ -15,23 +15,23 @@ * if we run out of memory, it's important to be able to report that fact. * There are a number of considerations that go into this. * - * First, distinguish between re-entrant use and actual recursion. It + * First, distinguish between re-entrant use and actual recursion. It * is possible for an error or warning message to be emitted while the - * parameters for an error message are being computed. In this case + * parameters for an error message are being computed. In this case * errstart has been called for the outer message, and some field values - * may have already been saved, but we are not actually recursing. We handle - * this by providing a (small) stack of ErrorData records. The inner message + * may have already been saved, but we are not actually recursing. We handle + * this by providing a (small) stack of ErrorData records. The inner message * can be computed and sent without disturbing the state of the outer message. * (If the inner message is actually an error, this isn't very interesting * because control won't come back to the outer message generator ... but * if the inner message is only debug or log data, this is critical.) * * Second, actual recursion will occur if an error is reported by one of - * the elog.c routines or something they call. By far the most probable + * the elog.c routines or something they call. By far the most probable * scenario of this sort is "out of memory"; and it's also the nastiest * to handle because we'd likely also run out of memory while trying to * report this error! Our escape hatch for this case is to reset the - * ErrorContext to empty before trying to process the inner error. Since + * ErrorContext to empty before trying to process the inner error. Since * ErrorContext is guaranteed to have at least 8K of space in it (see mcxt.c), * we should be able to process an "out of memory" message successfully. * Since we lose the prior error state due to the reset, we won't be able @@ -116,7 +116,7 @@ char *Log_destination_string = NULL; /* * Max string length to send to syslog(). Note that this doesn't count the * sequence-number prefix we add, and of course it doesn't count the prefix - * added by syslog itself. Solaris and sysklogd truncate the final message + * added by syslog itself. Solaris and sysklogd truncate the final message * at 1024 bytes, so this value leaves 124 bytes for those prefixes. (Most * other syslog implementations seem to have limits of 2KB or so.) */ @@ -244,7 +244,7 @@ errstart(int elevel, const char *filename, int lineno, { /* * If we are inside a critical section, all errors become PANIC - * errors. See miscadmin.h. + * errors. See miscadmin.h. */ if (CritSectionCount > 0) elevel = PANIC; @@ -257,7 +257,7 @@ errstart(int elevel, const char *filename, int lineno, * * 2. ExitOnAnyError mode switch is set (initdb uses this). * - * 3. the error occurred after proc_exit has begun to run. (It's + * 3. the error occurred after proc_exit has begun to run. (It's * proc_exit's responsibility to see that this doesn't turn into * infinite recursion!) */ @@ -350,7 +350,7 @@ errstart(int elevel, const char *filename, int lineno, if (++errordata_stack_depth >= ERRORDATA_STACK_SIZE) { /* - * Wups, stack not big enough. We treat this as a PANIC condition + * Wups, stack not big enough. We treat this as a PANIC condition * because it suggests an infinite loop of errors during error * recovery. */ @@ -424,8 +424,8 @@ errfinish(int dummy,...) * may not be re-entrant. * * Note: other places that save-and-clear ImmediateInterruptOK also do - * HOLD_INTERRUPTS(), but that should not be necessary here since we - * don't call anything that could turn on ImmediateInterruptOK. + * HOLD_INTERRUPTS(), but that should not be necessary here since we don't + * call anything that could turn on ImmediateInterruptOK. */ save_ImmediateInterruptOK = ImmediateInterruptOK; ImmediateInterruptOK = false; @@ -458,7 +458,7 @@ errfinish(int dummy,...) * * Reset InterruptHoldoffCount in case we ereport'd from inside an * interrupt holdoff section. (We assume here that no handler will - * itself be inside a holdoff section. If necessary, such a handler + * itself be inside a holdoff section. If necessary, such a handler * could save and restore InterruptHoldoffCount for itself, but this * should make life easier for most.) * @@ -484,7 +484,7 @@ errfinish(int dummy,...) * progress, so that we can report the message before dying. (Without * this, pq_putmessage will refuse to send the message at all, which is * what we want for NOTICE messages, but not for fatal exits.) This hack - * is necessary because of poor design of old-style copy protocol. Note + * is necessary because of poor design of old-style copy protocol. Note * we must do this even if client is fool enough to have set * client_min_messages above FATAL, so don't look at output_to_client. */ @@ -606,7 +606,7 @@ errcode(int sqlerrcode) /* * errcode_for_file_access --- add SQLSTATE error code to the current error * - * The SQLSTATE code is chosen based on the saved errno value. We assume + * The SQLSTATE code is chosen based on the saved errno value. We assume * that the failing operation was some type of disk file access. * * NOTE: the primary error message string should generally include %m @@ -677,7 +677,7 @@ errcode_for_file_access(void) /* * errcode_for_socket_access --- add SQLSTATE error code to the current error * - * The SQLSTATE code is chosen based on the saved errno value. We assume + * The SQLSTATE code is chosen based on the saved errno value. We assume * that the failing operation was some type of socket access. * * NOTE: the primary error message string should generally include %m @@ -715,7 +715,7 @@ errcode_for_socket_access(void) * This macro handles expansion of a format string and associated parameters; * it's common code for errmsg(), errdetail(), etc. Must be called inside * a routine that is declared like "const char *fmt, ..." and has an edata - * pointer set up. The message is assigned to edata->targetfield, or + * pointer set up. The message is assigned to edata->targetfield, or * appended to it if appendval is true. The message is subject to translation * if translateit is true. * @@ -1296,7 +1296,7 @@ elog_start(const char *filename, int lineno, const char *funcname) if (++errordata_stack_depth >= ERRORDATA_STACK_SIZE) { /* - * Wups, stack not big enough. We treat this as a PANIC condition + * Wups, stack not big enough. We treat this as a PANIC condition * because it suggests an infinite loop of errors during error * recovery. Note that the message is intentionally not localized, * else failure to convert it to client encoding could cause further @@ -1467,7 +1467,7 @@ EmitErrorReport(void) /* * CopyErrorData --- obtain a copy of the topmost error stack entry * - * This is only for use in error handler code. The data is copied into the + * This is only for use in error handler code. The data is copied into the * current memory context, so callers should always switch away from * ErrorContext first; otherwise it will be lost when FlushErrorState is done. */ @@ -1581,7 +1581,7 @@ FlushErrorState(void) * * A handler can do CopyErrorData/FlushErrorState to get out of the error * subsystem, then do some processing, and finally ReThrowError to re-throw - * the original error. This is slower than just PG_RE_THROW() but should + * the original error. This is slower than just PG_RE_THROW() but should * be used if the "some processing" is likely to incur another error. */ void @@ -1598,7 +1598,7 @@ ReThrowError(ErrorData *edata) if (++errordata_stack_depth >= ERRORDATA_STACK_SIZE) { /* - * Wups, stack not big enough. We treat this as a PANIC condition + * Wups, stack not big enough. We treat this as a PANIC condition * because it suggests an infinite loop of errors during error * recovery. */ @@ -1713,8 +1713,8 @@ pg_re_throw(void) char * GetErrorContextStack(void) { - ErrorData *edata; - ErrorContextCallback *econtext; + ErrorData *edata; + ErrorContextCallback *econtext; /* * Okay, crank up a stack entry to store the info in. @@ -1724,7 +1724,7 @@ GetErrorContextStack(void) if (++errordata_stack_depth >= ERRORDATA_STACK_SIZE) { /* - * Wups, stack not big enough. We treat this as a PANIC condition + * Wups, stack not big enough. We treat this as a PANIC condition * because it suggests an infinite loop of errors during error * recovery. */ @@ -1749,8 +1749,8 @@ GetErrorContextStack(void) * into edata->context. * * Errors occurring in callback functions should go through the regular - * error handling code which should handle any recursive errors, though - * we double-check above, just in case. + * error handling code which should handle any recursive errors, though we + * double-check above, just in case. */ for (econtext = error_context_stack; econtext != NULL; @@ -1833,7 +1833,7 @@ set_syslog_parameters(const char *ident, int facility) { /* * guc.c is likely to call us repeatedly with same parameters, so don't - * thrash the syslog connection unnecessarily. Also, we do not re-open + * thrash the syslog connection unnecessarily. Also, we do not re-open * the connection until needed, since this routine will get called whether * or not Log_destination actually mentions syslog. * @@ -2069,6 +2069,7 @@ write_console(const char *line, int len) int rc; #ifdef WIN32 + /* * Try to convert the message to UTF16 and write it with WriteConsoleW(). * Fall back on write() if anything fails. @@ -2186,14 +2187,14 @@ setup_formatted_start_time(void) static const char * process_log_prefix_padding(const char *p, int *ppadding) { - int paddingsign = 1; - int padding = 0; + int paddingsign = 1; + int padding = 0; if (*p == '-') { p++; - if (*p == '\0') /* Did the buf end in %- ? */ + if (*p == '\0') /* Did the buf end in %- ? */ return NULL; paddingsign = -1; } @@ -2268,9 +2269,9 @@ log_line_prefix(StringInfo buf, ErrorData *edata) * process_log_prefix_padding moves p past the padding number if it * exists. * - * Note: Since only '-', '0' to '9' are valid formatting characters - * we can do a quick check here to pre-check for formatting. If the - * char is not formatting then we can skip a useless function call. + * Note: Since only '-', '0' to '9' are valid formatting characters we + * can do a quick check here to pre-check for formatting. If the char + * is not formatting then we can skip a useless function call. * * Further note: At least on some platforms, passing %*s rather than * %s to appendStringInfo() is substantially slower, so many of the @@ -2337,9 +2338,10 @@ log_line_prefix(StringInfo buf, ErrorData *edata) case 'c': if (padding != 0) { - char strfbuf[128]; + char strfbuf[128]; + snprintf(strfbuf, sizeof(strfbuf) - 1, "%lx.%x", - (long) (MyStartTime), MyProcPid); + (long) (MyStartTime), MyProcPid); appendStringInfo(buf, "%*s", padding, strfbuf); } else @@ -2411,14 +2413,15 @@ log_line_prefix(StringInfo buf, ErrorData *edata) if (MyProcPort->remote_port && MyProcPort->remote_port[0] != '\0') { /* - * This option is slightly special as the port number - * may be appended onto the end. Here we need to build - * 1 string which contains the remote_host and optionally - * the remote_port (if set) so we can properly align the - * string. + * This option is slightly special as the port + * number may be appended onto the end. Here we + * need to build 1 string which contains the + * remote_host and optionally the remote_port (if + * set) so we can properly align the string. */ - char *hostport; + char *hostport; + hostport = psprintf("%s(%s)", MyProcPort->remote_host, MyProcPort->remote_port); appendStringInfo(buf, "%*s", padding, hostport); pfree(hostport); @@ -2433,7 +2436,7 @@ log_line_prefix(StringInfo buf, ErrorData *edata) if (MyProcPort->remote_port && MyProcPort->remote_port[0] != '\0') appendStringInfo(buf, "(%s)", - MyProcPort->remote_port); + MyProcPort->remote_port); } } @@ -2465,9 +2468,10 @@ log_line_prefix(StringInfo buf, ErrorData *edata) { if (padding != 0) { - char strfbuf[128]; + char strfbuf[128]; + snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%u", - MyProc->backendId, MyProc->lxid); + MyProc->backendId, MyProc->lxid); appendStringInfo(buf, "%*s", padding, strfbuf); } else @@ -2898,6 +2902,7 @@ send_message_to_server_log(ErrorData *edata) if (redirection_done && !am_syslogger) write_pipe_chunks(buf.data, buf.len, LOG_DESTINATION_STDERR); #ifdef WIN32 + /* * In a win32 service environment, there is no usable stderr. Capture * anything going there and write it to the eventlog instead. @@ -2951,7 +2956,7 @@ send_message_to_server_log(ErrorData *edata) * * Note: when there are multiple backends writing into the syslogger pipe, * it's critical that each write go into the pipe indivisibly, and not - * get interleaved with data from other processes. Fortunately, the POSIX + * get interleaved with data from other processes. Fortunately, the POSIX * spec requires that writes to pipes be atomic so long as they are not * more than PIPE_BUF bytes long. So we divide long messages into chunks * that are no more than that length, and send one chunk per write() call. @@ -3271,7 +3276,7 @@ useful_strerror(int errnum) str = strerror(errnum); /* - * Some strerror()s return an empty string for out-of-range errno. This + * Some strerror()s return an empty string for out-of-range errno. This * is ANSI C spec compliant, but not exactly useful. Also, we may get * back strings of question marks if libc cannot transcode the message to * the codeset specified by LC_CTYPE. If we get nothing useful, first try |