diff options
author | Tom Lane | 2017-02-23 20:57:08 +0000 |
---|---|---|
committer | Tom Lane | 2017-02-23 20:57:08 +0000 |
commit | c29aff959dc64f7321062e7f33d8c6ec23db53d3 (patch) | |
tree | 4c3efa167e01805b2e4fcd6eead2e1a320a2c420 /src/bin/pg_basebackup/streamutil.c | |
parent | b9d092c962ea3262930e3c31a8c3d79b66ce9d43 (diff) |
Consistently declare timestamp variables as TimestampTz.
Twiddle the replication-related code so that its timestamp variables
are declared TimestampTz, rather than the uninformative "int64" that
was previously used for meant-to-be-always-integer timestamps.
This resolves the int64-vs-TimestampTz declaration inconsistencies
introduced by commit 7c030783a, though in the opposite direction to
what was originally suggested.
This required including datatype/timestamp.h in a couple more places
than before. I decided it would be a good idea to slim down that
header by not having it pull in <float.h> etc, as those headers are
no longer at all relevant to its purpose. Unsurprisingly, a small number
of .c files turn out to have been depending on those inclusions, so add
them back in the .c files as needed.
Discussion: https://postgr.es/m/[email protected]
Discussion: https://postgr.es/m/[email protected]
Diffstat (limited to 'src/bin/pg_basebackup/streamutil.c')
-rw-r--r-- | src/bin/pg_basebackup/streamutil.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/bin/pg_basebackup/streamutil.c b/src/bin/pg_basebackup/streamutil.c index 35143f5de76..90d93cbed16 100644 --- a/src/bin/pg_basebackup/streamutil.c +++ b/src/bin/pg_basebackup/streamutil.c @@ -433,20 +433,18 @@ DropReplicationSlot(PGconn *conn, const char *slot_name) /* * Frontend version of GetCurrentTimestamp(), since we are not linked with - * backend code. The replication protocol always uses integer timestamps, - * regardless of the server setting. + * backend code. */ -int64 +TimestampTz feGetCurrentTimestamp(void) { - int64 result; + TimestampTz result; struct timeval tp; gettimeofday(&tp, NULL); - result = (int64) tp.tv_sec - + result = (TimestampTz) tp.tv_sec - ((POSTGRES_EPOCH_JDATE - UNIX_EPOCH_JDATE) * SECS_PER_DAY); - result = (result * USECS_PER_SEC) + tp.tv_usec; return result; @@ -457,10 +455,10 @@ feGetCurrentTimestamp(void) * backend code. */ void -feTimestampDifference(int64 start_time, int64 stop_time, +feTimestampDifference(TimestampTz start_time, TimestampTz stop_time, long *secs, int *microsecs) { - int64 diff = stop_time - start_time; + TimestampTz diff = stop_time - start_time; if (diff <= 0) { @@ -479,11 +477,11 @@ feTimestampDifference(int64 start_time, int64 stop_time, * linked with backend code. */ bool -feTimestampDifferenceExceeds(int64 start_time, - int64 stop_time, +feTimestampDifferenceExceeds(TimestampTz start_time, + TimestampTz stop_time, int msec) { - int64 diff = stop_time - start_time; + TimestampTz diff = stop_time - start_time; return (diff >= msec * INT64CONST(1000)); } |