postgresql/src/include
Tom Lane e87139b433 Fix and simplify some usages of TimestampDifference().
Introduce TimestampDifferenceMilliseconds() to simplify callers
that would rather have the difference in milliseconds, instead of
the select()-oriented seconds-and-microseconds format.  This gets
rid of at least one integer division per call, and it eliminates
some apparently-easy-to-mess-up arithmetic.

Two of these call sites were in fact wrong:

* pg_prewarm's autoprewarm_main() forgot to multiply the seconds
by 1000, thus ending up with a delay 1000X shorter than intended.
That doesn't quite make it a busy-wait, but close.

* postgres_fdw's pgfdw_get_cleanup_result() thought it needed to compute
microseconds not milliseconds, thus ending up with a delay 1000X longer
than intended.  Somebody along the way had noticed this problem but
misdiagnosed the cause, and imposed an ad-hoc 60-second limit rather
than fixing the units.  This was relatively harmless in context, because
we don't care that much about exactly how long this delay is; still,
it's wrong.

There are a few more callers of TimestampDifference() that don't
have a direct need for seconds-and-microseconds, but can't use
TimestampDifferenceMilliseconds() either because they do need
microsecond precision or because they might possibly deal with
intervals long enough to overflow 32-bit milliseconds.  It might be
worth inventing another API to improve that, but that seems outside
the scope of this patch; so those callers are untouched here.

Given the fact that we are fixing some bugs, and the likelihood
that future patches might want to back-patch code that uses this
new API, back-patch to all supported branches.

Alexey Kondratov and Tom Lane

Discussion: https://postgr.es/m/3b1c053a21c07c1ed5e00be3b2b855ef@postgrespro.ru
2020-11-10 22:51:57 -05:00
..
access doc: improve description of synchronous_commit modes 2020-10-15 15:15:28 -04:00
bootstrap Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
catalog Avoid direct C access to possibly-null pg_subscription_rel.srsublsn. 2020-07-21 11:40:47 -04:00
commands Mark assorted variables PGDLLIMPORT. 2017-12-05 09:24:05 -05:00
common Move connect.h from fe_utils to src/include/common. 2020-08-10 09:22:59 -07:00
datatype Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
executor Fix failure with initplans used conditionally during EvalPlanQual rechecks. 2018-09-15 13:42:34 -04:00
fe_utils Empty search_path in Autovacuum and non-psql/pgbench clients. 2018-02-26 07:39:47 -08:00
foreign Separate reinitialization of shared parallel-scan state from ExecReScan. 2017-08-30 13:18:16 -04:00
lib Rename rbtree.c functions to use "rbt" prefix not "rb" prefix. 2018-11-06 13:25:24 -05:00
libpq Fix unportable use of getnameinfo() in pg_hba_file_rules view. 2020-11-02 21:11:50 -05:00
mb Phase 3 of pgindent updates. 2017-06-21 15:35:54 -04:00
nodes Be more careful about the shape of hashable subplan clauses. 2020-08-14 22:14:03 -04:00
optimizer Be more careful about the shape of hashable subplan clauses. 2020-08-14 22:14:03 -04:00
parser Fix handling of CREATE TABLE LIKE with inheritance. 2020-08-21 15:00:43 -04:00
port Avoid need for valgrind suppressions for pg_atomic_init_u64 on some platforms. 2020-06-08 20:03:09 -07:00
portability Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
postmaster Log when a BRIN autosummarization request fails 2018-03-14 12:00:53 -03:00
regex Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
replication Fix bogus cache-invalidation logic in logical replication worker. 2020-09-16 12:07:31 -04:00
rewrite Defend against self-referential views in relation_is_updatable(). 2019-11-21 16:21:44 -05:00
snowball Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
statistics Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
storage C comment: correct use of 64-"byte" cache line size 2020-09-04 13:27:52 -04:00
tcop Fix event triggers for partitioned tables 2018-10-06 19:17:46 -03:00
tsearch Fix serious performance problems in json(b) to_tsvector(). 2017-07-18 12:45:51 -04:00
utils Fix and simplify some usages of TimestampDifference(). 2020-11-10 22:51:57 -05:00
.gitignore Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
c.h Fix integer-overflow edge case detection in interval_mul and pgbench. 2019-11-07 11:23:02 -05:00
fmgr.h Fix minor violations of FunctionCallInvoke usage protocol. 2020-04-21 14:23:42 -04:00
funcapi.h Avoid holding a directory FD open across assorted SRF calls. 2020-03-16 21:05:55 -04:00
getaddrinfo.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
getopt_long.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
Makefile Add statistics subdirectory to Makefile. 2017-06-08 11:29:50 -04:00
miscadmin.h Add unlikely() to CHECK_FOR_INTERRUPTS() 2020-06-05 16:49:35 -04:00
pg_config.h.in Replace use of sys_siglist[] with strsignal(). 2020-07-15 22:05:12 -04:00
pg_config.h.win32 Stamp 10.15. 2020-11-09 17:29:52 -05: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 Fix default minimum value for descending sequences 2017-01-23 14:00:58 -05:00
pg_getopt.h Use our own getopt() on OpenBSD. 2019-01-18 15:06:26 -05:00
pg_trace.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
pgstat.h Add GUC variables for stat tracking and timeout as PGDLLIMPORT 2020-01-21 13:47:05 +09:00
pgtar.h Phase 3 of pgindent updates. 2017-06-21 15:35:54 -04:00
pgtime.h Mark assorted variables PGDLLIMPORT. 2017-12-05 09:24:05 -05:00
port.h In the postmaster, rely on the signal infrastructure to block signals. 2020-10-15 12:50:57 -04:00
postgres.h Phase 3 of pgindent updates. 2017-06-21 15:35:54 -04:00
postgres_ext.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
postgres_fe.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
rusagestub.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
windowapi.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00