postgresql/src/include
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 Propagate xactStartTimestamp and stmtStartTimestamp to parallel workers. 2018-10-06 12:00:09 -04:00
bootstrap Rationalize handling of array type names in bootstrap data. 2018-04-17 18:29:11 -04:00
catalog Fix event triggers for partitioned tables 2018-10-06 19:17:46 -03:00
commands Fix issues around EXPLAIN with JIT. 2018-10-03 12:48:37 -07:00
common Add application_name to connection authorized msg 2018-09-28 19:04:50 -04:00
datatype Update copyright for 2018 2018-01-02 23:30:12 -05:00
executor Remove more redundant relation locking during executor startup. 2018-10-06 15:12:51 -04:00
fe_utils Add semicolons to end of internally run queries 2018-08-30 19:23:22 +02:00
foreign Allow insert and update tuple routing and COPY for foreign tables. 2018-04-06 19:22:03 -04:00
jit Collect JIT instrumentation from workers. 2018-09-25 13:12:44 -07:00
lib Code review for simplehash.h. 2018-08-28 12:32:22 +12:00
libpq Add application_name to connection authorized msg 2018-09-28 19:04:50 -04:00
mb Fix a boatload of typos in C comments. 2018-04-01 15:01:28 -04:00
nodes Avoid O(N^2) cost in ExecFindRowMark(). 2018-10-08 10:41:34 -04:00
optimizer Remove some unnecessary fields from Plan trees. 2018-10-07 14:33:17 -04:00
parser In the executor, use an array of pointers to access the rangetable. 2018-10-04 15:48:17 -04:00
partitioning Centralize executor's opening/closing of Relations for rangetable entries. 2018-10-04 14:03:42 -04:00
port Convert elog.c's useful_strerror() into a globally-used strerror wrapper. 2018-09-26 11:06:42 -04:00
portability Update copyright for 2018 2018-01-02 23:30:12 -05:00
postmaster Implement "pg_ctl logrotate" command 2018-09-01 19:46:49 +03:00
regex Update copyright for 2018 2018-01-02 23:30:12 -05:00
replication Fix memory leak in TRUNCATE decoding 2018-09-03 02:10:24 +02:00
rewrite Revert MERGE patch 2018-04-12 11:22:56 +01:00
snowball Sync our Snowball stemmer dictionaries with current upstream. 2018-09-24 17:29:38 -04:00
statistics Update copyright for 2018 2018-01-02 23:30:12 -05:00
storage Add assertions that we hold some relevant lock during relation open. 2018-10-01 12:43:21 -04:00
tcop Fix event triggers for partitioned tables 2018-10-06 19:17:46 -03:00
tsearch Post-feature-freeze pgindent run. 2018-04-26 14:47:16 -04:00
utils Allow btree comparison functions to return INT_MIN. 2018-10-05 16:01:29 -04:00
.gitignore Refactor dlopen() support 2018-09-06 11:33:04 +02:00
c.h Allow btree comparison functions to return INT_MIN. 2018-10-05 16:01:29 -04:00
fmgr.h Add expression compilation support to LLVM JIT provider. 2018-03-22 14:45:59 -07:00
funcapi.h Clean up in the wake of TupleDescGetSlot() removal / 10763358c3. 2018-09-27 11:38:11 -07:00
getaddrinfo.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
getopt_long.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
Makefile Refactor dlopen() support 2018-09-06 11:33:04 +02:00
miscadmin.h Switch flags tracking pending interrupts to sig_atomic_t 2018-09-27 07:47:20 +09:00
pg_config.h.in Make assorted performance improvements in snprintf.c. 2018-10-03 10:18:15 -04:00
pg_config.h.win32 Make assorted performance improvements in snprintf.c. 2018-10-03 10:18:15 -04:00
pg_config_ext.h.in Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
pg_config_ext.h.win32 Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
pg_config_manual.h Improve error reporting for unsupported effective_io_concurrency setting. 2018-09-28 16:12:13 -04:00
pg_getopt.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
pg_trace.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
pgstat.h Add wait event for fsync of WAL segments 2018-07-02 22:19:46 +09:00
pgtar.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
pgtime.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
port.h Improve snprintf.c's handling of NaN, Infinity, and minus zero. 2018-10-08 12:19:20 -04:00
postgres.h Detoast plpgsql variables if they might live across a transaction boundary. 2018-05-16 14:56:52 -04:00
postgres_ext.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
postgres_fe.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
rusagestub.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
windowapi.h Update copyright for 2018 2018-01-02 23:30:12 -05:00