mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +03:00
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/26788.1487455319@sss.pgh.pa.us
Discussion: https://postgr.es/m/27694.1487456324@sss.pgh.pa.us
This commit is contained in:
@@ -92,10 +92,10 @@ static uint64 throttling_sample;
|
||||
static int64 throttling_counter;
|
||||
|
||||
/* The minimum time required to transfer throttling_sample bytes. */
|
||||
static int64 elapsed_min_unit;
|
||||
static TimeOffset elapsed_min_unit;
|
||||
|
||||
/* The last check of the transfer rate. */
|
||||
static int64 throttled_last;
|
||||
static TimestampTz throttled_last;
|
||||
|
||||
/*
|
||||
* The contents of these directories are removed or recreated during server
|
||||
@@ -254,7 +254,7 @@ perform_base_backup(basebackup_options *opt, DIR *tblspcdir)
|
||||
throttling_counter = 0;
|
||||
|
||||
/* The 'real data' starts now (header was ignored). */
|
||||
throttled_last = GetCurrentIntegerTimestamp();
|
||||
throttled_last = GetCurrentTimestamp();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1333,7 +1333,7 @@ _tarWriteDir(const char *pathbuf, int basepathlen, struct stat *statbuf,
|
||||
static void
|
||||
throttle(size_t increment)
|
||||
{
|
||||
int64 elapsed,
|
||||
TimeOffset elapsed,
|
||||
elapsed_min,
|
||||
sleep;
|
||||
int wait_result;
|
||||
@@ -1346,7 +1346,7 @@ throttle(size_t increment)
|
||||
return;
|
||||
|
||||
/* Time elapsed since the last measurement (and possible wake up). */
|
||||
elapsed = GetCurrentIntegerTimestamp() - throttled_last;
|
||||
elapsed = GetCurrentTimestamp() - throttled_last;
|
||||
/* How much should have elapsed at minimum? */
|
||||
elapsed_min = elapsed_min_unit * (throttling_counter / throttling_sample);
|
||||
sleep = elapsed_min - elapsed;
|
||||
@@ -1381,5 +1381,5 @@ throttle(size_t increment)
|
||||
* Time interval for the remaining amount and possible next increments
|
||||
* starts now.
|
||||
*/
|
||||
throttled_last = GetCurrentIntegerTimestamp();
|
||||
throttled_last = GetCurrentTimestamp();
|
||||
}
|
||||
|
||||
@@ -981,12 +981,11 @@ ApplyLoop(void)
|
||||
{
|
||||
XLogRecPtr start_lsn;
|
||||
XLogRecPtr end_lsn;
|
||||
TimestampTz send_time;
|
||||
TimestampTz send_time;
|
||||
|
||||
start_lsn = pq_getmsgint64(&s);
|
||||
end_lsn = pq_getmsgint64(&s);
|
||||
send_time =
|
||||
IntegerTimestampToTimestampTz(pq_getmsgint64(&s));
|
||||
send_time = pq_getmsgint64(&s);
|
||||
|
||||
if (last_received < start_lsn)
|
||||
last_received = start_lsn;
|
||||
@@ -1000,13 +999,12 @@ ApplyLoop(void)
|
||||
}
|
||||
else if (c == 'k')
|
||||
{
|
||||
XLogRecPtr endpos;
|
||||
TimestampTz timestamp;
|
||||
bool reply_requested;
|
||||
XLogRecPtr endpos;
|
||||
TimestampTz timestamp;
|
||||
bool reply_requested;
|
||||
|
||||
endpos = pq_getmsgint64(&s);
|
||||
timestamp =
|
||||
IntegerTimestampToTimestampTz(pq_getmsgint64(&s));
|
||||
timestamp = pq_getmsgint64(&s);
|
||||
reply_requested = pq_getmsgbyte(&s);
|
||||
|
||||
send_feedback(endpos, reply_requested, false);
|
||||
|
||||
@@ -892,8 +892,7 @@ XLogWalRcvProcessMsg(unsigned char type, char *buf, Size len)
|
||||
/* read the fields */
|
||||
dataStart = pq_getmsgint64(&incoming_message);
|
||||
walEnd = pq_getmsgint64(&incoming_message);
|
||||
sendTime = IntegerTimestampToTimestampTz(
|
||||
pq_getmsgint64(&incoming_message));
|
||||
sendTime = pq_getmsgint64(&incoming_message);
|
||||
ProcessWalSndrMessage(walEnd, sendTime);
|
||||
|
||||
buf += hdrlen;
|
||||
@@ -913,8 +912,7 @@ XLogWalRcvProcessMsg(unsigned char type, char *buf, Size len)
|
||||
|
||||
/* read the fields */
|
||||
walEnd = pq_getmsgint64(&incoming_message);
|
||||
sendTime = IntegerTimestampToTimestampTz(
|
||||
pq_getmsgint64(&incoming_message));
|
||||
sendTime = pq_getmsgint64(&incoming_message);
|
||||
replyRequested = pq_getmsgbyte(&incoming_message);
|
||||
|
||||
ProcessWalSndrMessage(walEnd, sendTime);
|
||||
@@ -1149,7 +1147,7 @@ XLogWalRcvSendReply(bool force, bool requestReply)
|
||||
pq_sendint64(&reply_message, writePtr);
|
||||
pq_sendint64(&reply_message, flushPtr);
|
||||
pq_sendint64(&reply_message, applyPtr);
|
||||
pq_sendint64(&reply_message, GetCurrentIntegerTimestamp());
|
||||
pq_sendint64(&reply_message, GetCurrentTimestamp());
|
||||
pq_sendbyte(&reply_message, requestReply ? 1 : 0);
|
||||
|
||||
/* Send it */
|
||||
@@ -1241,7 +1239,7 @@ XLogWalRcvSendHSFeedback(bool immed)
|
||||
/* Construct the message and send it. */
|
||||
resetStringInfo(&reply_message);
|
||||
pq_sendbyte(&reply_message, 'h');
|
||||
pq_sendint64(&reply_message, GetCurrentIntegerTimestamp());
|
||||
pq_sendint64(&reply_message, GetCurrentTimestamp());
|
||||
pq_sendint(&reply_message, xmin, 4);
|
||||
pq_sendint(&reply_message, nextEpoch, 4);
|
||||
walrcv_send(wrconn, reply_message.data, reply_message.len);
|
||||
|
||||
@@ -823,12 +823,13 @@ CreateReplicationSlot(CreateReplicationSlotCmd *cmd)
|
||||
dest = CreateDestReceiver(DestRemoteSimple);
|
||||
MemSet(nulls, false, sizeof(nulls));
|
||||
|
||||
/*
|
||||
/*----------
|
||||
* Need a tuple descriptor representing four columns:
|
||||
* - first field: the slot name
|
||||
* - second field: LSN at which we became consistent
|
||||
* - third field: exported snapshot's name
|
||||
* - fourth field: output plugin
|
||||
*----------
|
||||
*/
|
||||
tupdesc = CreateTemplateTupleDesc(4, false);
|
||||
TupleDescInitBuiltinEntry(tupdesc, (AttrNumber) 1, "slot_name",
|
||||
@@ -1014,7 +1015,7 @@ WalSndWriteData(LogicalDecodingContext *ctx, XLogRecPtr lsn, TransactionId xid,
|
||||
* several releases by streaming physical replication.
|
||||
*/
|
||||
resetStringInfo(&tmpbuf);
|
||||
pq_sendint64(&tmpbuf, GetCurrentIntegerTimestamp());
|
||||
pq_sendint64(&tmpbuf, GetCurrentTimestamp());
|
||||
memcpy(&ctx->out->data[1 + sizeof(int64) + sizeof(int64)],
|
||||
tmpbuf.data, sizeof(int64));
|
||||
|
||||
@@ -2334,7 +2335,7 @@ XLogSendPhysical(void)
|
||||
* Fill the send timestamp last, so that it is taken as late as possible.
|
||||
*/
|
||||
resetStringInfo(&tmpbuf);
|
||||
pq_sendint64(&tmpbuf, GetCurrentIntegerTimestamp());
|
||||
pq_sendint64(&tmpbuf, GetCurrentTimestamp());
|
||||
memcpy(&output_message.data[1 + sizeof(int64) + sizeof(int64)],
|
||||
tmpbuf.data, sizeof(int64));
|
||||
|
||||
@@ -2842,7 +2843,7 @@ WalSndKeepalive(bool requestReply)
|
||||
resetStringInfo(&output_message);
|
||||
pq_sendbyte(&output_message, 'k');
|
||||
pq_sendint64(&output_message, sentPtr);
|
||||
pq_sendint64(&output_message, GetCurrentIntegerTimestamp());
|
||||
pq_sendint64(&output_message, GetCurrentTimestamp());
|
||||
pq_sendbyte(&output_message, requestReply ? 1 : 0);
|
||||
|
||||
/* ... and send it wrapped in CopyData */
|
||||
|
||||
Reference in New Issue
Block a user