diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index 7ee60ddfec6..f8c0f0d3843 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -3577,13 +3577,24 @@ write_stderr(const char *fmt,...) { va_list ap; + va_start(ap, fmt); + vwrite_stderr(fmt, ap); + va_end(ap); +} + + +/* + * Write errors to stderr (or by equal means when stderr is + * not available) - va_list version + */ +void +vwrite_stderr(const char *fmt, va_list ap) +{ #ifdef WIN32 char errbuf[2048]; /* Arbitrary size? */ #endif fmt = _(fmt); - - va_start(ap, fmt); #ifndef WIN32 /* On Unix, we just fprintf to stderr */ vfprintf(stderr, fmt, ap); @@ -3606,7 +3617,6 @@ write_stderr(const char *fmt,...) fflush(stderr); } #endif - va_end(ap); } diff --git a/src/include/utils/elog.h b/src/include/utils/elog.h index f98a1e8b629..cde7942b1eb 100644 --- a/src/include/utils/elog.h +++ b/src/include/utils/elog.h @@ -452,6 +452,7 @@ extern void set_syslog_parameters(const char *ident, int facility); * safely (memory context, GUC load etc) */ extern void write_stderr(const char *fmt,...) pg_attribute_printf(1, 2); +extern void vwrite_stderr(const char *fmt, va_list ap) pg_attribute_printf(1, 0); /* * Write a message to STDERR using only async-signal-safe functions. This can diff --git a/src/port/win32security.c b/src/port/win32security.c index 4a673fde19a..5098a8d8489 100644 --- a/src/port/win32security.c +++ b/src/port/win32security.c @@ -31,9 +31,9 @@ log_error(const char *fmt,...) va_start(ap, fmt); #ifndef FRONTEND - write_stderr(fmt, ap); + vwrite_stderr(fmt, ap); #else - fprintf(stderr, fmt, ap); + vfprintf(stderr, fmt, ap); #endif va_end(ap); }