1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-02 04:21:28 +03:00

Always use our own versions of *printf().

We've spent an awful lot of effort over the years in coping with
platform-specific vagaries of the *printf family of functions.  Let's just
forget all that mess and standardize on always using src/port/snprintf.c.
This gets rid of a lot of configure logic, and it will allow a saner
approach to dealing with %m (though actually changing that is left for
a follow-on patch).

Preliminary performance testing suggests that as it stands, snprintf.c is
faster than the native printf functions for some tasks on some platforms,
and slower for other cases.  A pending patch will improve that, though
cases with floating-point conversions will doubtless remain slower unless
we want to put a *lot* of effort into that.  Still, we've not observed
that *printf is really a performance bottleneck for most workloads, so
I doubt this matters much.

Patch by me, reviewed by Michael Paquier

Discussion: https://postgr.es/m/2975.1526862605@sss.pgh.pa.us
This commit is contained in:
Tom Lane
2018-09-26 13:13:57 -04:00
parent 758ce9b779
commit 96bf88d527
16 changed files with 19 additions and 509 deletions

View File

@@ -134,7 +134,12 @@ extern unsigned char pg_tolower(unsigned char ch);
extern unsigned char pg_ascii_toupper(unsigned char ch);
extern unsigned char pg_ascii_tolower(unsigned char ch);
#ifdef USE_REPL_SNPRINTF
/*
* Beginning in v12, we always replace snprintf() and friends with our own
* implementation. This symbol is no longer consulted by the core code,
* but keep it defined anyway in case any extensions are looking at it.
*/
#define USE_REPL_SNPRINTF 1
/*
* Versions of libintl >= 0.13 try to replace printf() and friends with
@@ -187,7 +192,6 @@ extern int pg_printf(const char *fmt,...) pg_attribute_printf(1, 2);
#define fprintf pg_fprintf
#define printf pg_printf
#endif
#endif /* USE_REPL_SNPRINTF */
/* Replace strerror() with our own, somewhat more robust wrapper */
extern char *pg_strerror(int errnum);