postgresql/src/backend/utils
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
..
adt Improve snprintf.c's handling of NaN, Infinity, and minus zero. 2018-10-08 12:19:20 -04:00
cache Change rewriter/planner/executor/plancache to depend on RTE rellockmode. 2018-10-02 14:43:09 -04:00
error Implement %m in src/port/snprintf.c, and teach elog.c to rely on that. 2018-09-26 13:31:56 -04:00
fmgr Clean up in the wake of TupleDescGetSlot() removal / 10763358c3. 2018-09-27 11:38:11 -07:00
hash Allow memory contexts to have both fixed and variable ident strings. 2018-03-27 16:46:51 -04:00
init Add application_name to connection authorized msg 2018-09-28 19:04:50 -04:00
mb Avoid use of unportable hex constant in convutils.pm 2018-05-27 10:41:19 -04:00
misc Add application_name to connection authorized msg 2018-09-28 19:04:50 -04:00
mmgr Constify dsa_size_class_map and use a better type. 2018-09-25 14:58:41 +12:00
resowner Use a ResourceOwner to track buffer pins in all cases. 2018-07-18 12:15:16 -04:00
sort Split ExecStoreTuple into ExecStoreHeapTuple and ExecStoreBufferHeapTuple. 2018-09-25 16:27:48 -07:00
time Fix misc typos, mostly in comments. 2018-07-18 16:17:32 +03:00
.gitignore Rearrange makefile rules for running Gen_fmgrtab.pl. 2018-05-03 17:54:18 -04:00
Gen_dummy_probes.pl Clean up some perlcritic warnings 2018-05-07 15:35:32 -04:00
Gen_dummy_probes.sed Update copyright for 2018 2018-01-02 23:30:12 -05:00
Gen_fmgrtab.pl Assorted minor cleanups for bootstrap-data Perl scripts. 2018-05-19 16:04:47 -04:00
Makefile Suppress compiler warnings when building with --enable-dtrace. 2018-05-07 13:44:09 -04:00
errcodes.txt Update comment in header of errcodes.txt 2018-08-16 09:47:59 +02:00
generate-errcodes.pl Update copyright for 2018 2018-01-02 23:30:12 -05:00
probes.d Support parallel btree index builds. 2018-02-02 13:32:44 -05:00