postgresql/src/backend
Tom Lane 6eb3eb577d Improve snprintf.c's handling of NaN, Infinity, and minus zero.
Up to now, float4out/float8out handled NaN and Infinity cases explicitly,
and invoked psprintf only for ordinary float values.  This was done because
platform implementations of snprintf produce varying representations of
these special cases.  But now that we use snprintf.c always, it's better
to give it the responsibility to produce a uniform representation of
these cases, so that we have uniformity across the board not only in
float4out/float8out.  Hence, move that work into fmtfloat().

Also, teach fmtfloat() to recognize IEEE minus zero and handle it
correctly.  The previous coding worked only accidentally, and would
fail for e.g. "%+f" format (it'd print "+-0.00000").  Now that we're
using snprintf.c everywhere, it's not acceptable for it to do weird
things in corner cases.  (This incidentally avoids a portability
problem we've seen on some really ancient platforms, that native
sprintf does the wrong thing with minus zero.)

Also, introduce a new entry point in snprintf.c to allow float[48]out
to bypass the work of interpreting a well-known format spec, as well
as bypassing the overhead of the psprintf layer.  I modeled this API
loosely on strfromd().  In my testing, this brings float[48]out back
to approximately the same speed they had when using native snprintf,
fixing one of the main performance issues caused by using snprintf.c.

(There is some talk of more aggressive work to improve the speed of
floating-point output conversion, but these changes seem to provide
a better starting point for such work anyway.)

Getting rid of the previous ad-hoc hack for Infinity/NaN in fmtfloat()
allows removing <ctype.h> from snprintf.c's #includes.  I also removed
a few other #includes that I think are historical, though the buildfarm
may expose that as wrong.

Discussion: https://postgr.es/m/13178.1538794717@sss.pgh.pa.us
2018-10-08 12:19:20 -04:00
..
access Restore sane locking behavior during parallel query. 2018-10-06 15:49:37 -04:00
bootstrap Install a check for mis-linking of src/port and src/common functions. 2018-09-09 12:23:23 -04:00
catalog Fix event triggers for partitioned tables 2018-10-06 19:17:46 -03:00
commands Silence compiler warning in Assert() 2018-10-08 10:37:21 -03:00
executor Avoid O(N^2) cost in ExecFindRowMark(). 2018-10-08 10:41:34 -04:00
foreign Remove bogus "extern" annotations on function definitions. 2018-02-19 12:07:44 -05:00
jit Change TupleTableSlot->tts_nvalid to type AttrNumber. 2018-09-25 15:59:46 -07:00
lib Implement %m in src/port/snprintf.c, and teach elog.c to rely on that. 2018-09-26 13:31:56 -04:00
libpq Minor cleanup/future-proofing for pg_saslprep(). 2018-09-08 18:20:36 -04:00
main Update copyright for 2018 2018-01-02 23:30:12 -05:00
nodes Remove some unnecessary fields from Plan trees. 2018-10-07 14:33:17 -04:00
optimizer Remove some unnecessary fields from Plan trees. 2018-10-07 14:33:17 -04:00
parser Add option SKIP_LOCKED to VACUUM and ANALYZE 2018-10-04 09:00:33 +09:00
partitioning Centralize executor's opening/closing of Relations for rangetable entries. 2018-10-04 14:03:42 -04:00
po Translation updates 2018-06-25 12:37:18 +02:00
port Convert elog.c's useful_strerror() into a globally-used strerror wrapper. 2018-09-26 11:06:42 -04:00
postmaster Add application_name to connection authorized msg 2018-09-28 19:04:50 -04:00
regex Clean up warnings from -Wimplicit-fallthrough. 2018-05-01 19:35:08 -04:00
replication In the executor, use an array of pointers to access the rangetable. 2018-10-04 15:48:17 -04:00
rewrite Change rewriter/planner/executor/plancache to depend on RTE rellockmode. 2018-10-02 14:43:09 -04:00
snowball Sync our Snowball stemmer dictionaries with current upstream. 2018-09-24 17:29:38 -04:00
statistics Fix typos. 2018-08-27 09:32:59 +12:00
storage Refactor user-facing SQL functions signalling backends 2018-10-04 18:27:25 +09:00
tcop Add a debugging option to stress-test outfuncs.c and readfuncs.c. 2018-09-18 17:11:54 -04:00
tsearch Hand code string to integer conversion for performance. 2018-07-22 14:58:23 -07:00
utils Improve snprintf.c's handling of NaN, Infinity, and minus zero. 2018-10-08 12:19:20 -04:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
Makefile Refactor dlopen() support 2018-09-06 11:33:04 +02:00
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
nls.mk Translation updates 2018-06-25 12:37:18 +02:00