Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc29aff9

Browse files
committed
Consistently declare timestamp variables as TimestampTz.
Twiddle the replication-related code so that its timestamp variablesare declared TimestampTz, rather than the uninformative "int64" thatwas previously used for meant-to-be-always-integer timestamps.This resolves the int64-vs-TimestampTz declaration inconsistenciesintroduced by commit7c03078, though in the opposite direction towhat was originally suggested.This required including datatype/timestamp.h in a couple more placesthan before. I decided it would be a good idea to slim down thatheader by not having it pull in <float.h> etc, as those headers areno longer at all relevant to its purpose. Unsurprisingly, a small numberof .c files turn out to have been depending on those inclusions, so addthem back in the .c files as needed.Discussion:https://postgr.es/m/26788.1487455319@sss.pgh.pa.usDiscussion:https://postgr.es/m/27694.1487456324@sss.pgh.pa.us
1 parentb9d092c commitc29aff9

File tree

22 files changed

+100
-94
lines changed

22 files changed

+100
-94
lines changed

‎contrib/auth_delay/auth_delay.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
*/
1212
#include"postgres.h"
1313

14+
#include<limits.h>
15+
1416
#include"libpq/auth.h"
1517
#include"port.h"
1618
#include"utils/guc.h"

‎contrib/btree_gist/btree_ts.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
*/
44
#include"postgres.h"
55

6+
#include<limits.h>
7+
68
#include"btree_gist.h"
79
#include"btree_utils_num.h"
810
#include"utils/builtins.h"

‎src/backend/access/common/reloptions.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
#include"postgres.h"
1717

18+
#include<float.h>
19+
1820
#include"access/gist_private.h"
1921
#include"access/hash.h"
2022
#include"access/htup_details.h"

‎src/backend/access/transam/xlog.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include"postgres.h"
1616

1717
#include<ctype.h>
18+
#include<math.h>
1819
#include<time.h>
1920
#include<fcntl.h>
2021
#include<sys/stat.h>

‎src/backend/commands/prepare.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
*/
1717
#include"postgres.h"
1818

19+
#include<limits.h>
20+
1921
#include"access/xact.h"
2022
#include"catalog/pg_type.h"
2123
#include"commands/createas.h"

‎src/backend/executor/nodeBitmapHeapscan.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
*/
3636
#include"postgres.h"
3737

38+
#include<math.h>
39+
3840
#include"access/relscan.h"
3941
#include"access/transam.h"
4042
#include"executor/execdebug.h"

‎src/backend/replication/basebackup.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ static uint64 throttling_sample;
9292
staticint64throttling_counter;
9393

9494
/* The minimum time required to transfer throttling_sample bytes. */
95-
staticint64elapsed_min_unit;
95+
staticTimeOffsetelapsed_min_unit;
9696

9797
/* The last check of the transfer rate. */
98-
staticint64throttled_last;
98+
staticTimestampTzthrottled_last;
9999

100100
/*
101101
* The contents of these directories are removed or recreated during server
@@ -254,7 +254,7 @@ perform_base_backup(basebackup_options *opt, DIR *tblspcdir)
254254
throttling_counter=0;
255255

256256
/* The 'real data' starts now (header was ignored). */
257-
throttled_last=GetCurrentIntegerTimestamp();
257+
throttled_last=GetCurrentTimestamp();
258258
}
259259
else
260260
{
@@ -1333,7 +1333,7 @@ _tarWriteDir(const char *pathbuf, int basepathlen, struct stat *statbuf,
13331333
staticvoid
13341334
throttle(size_tincrement)
13351335
{
1336-
int64elapsed,
1336+
TimeOffsetelapsed,
13371337
elapsed_min,
13381338
sleep;
13391339
intwait_result;
@@ -1346,7 +1346,7 @@ throttle(size_t increment)
13461346
return;
13471347

13481348
/* Time elapsed since the last measurement (and possible wake up). */
1349-
elapsed=GetCurrentIntegerTimestamp()-throttled_last;
1349+
elapsed=GetCurrentTimestamp()-throttled_last;
13501350
/* How much should have elapsed at minimum? */
13511351
elapsed_min=elapsed_min_unit* (throttling_counter /throttling_sample);
13521352
sleep=elapsed_min-elapsed;
@@ -1381,5 +1381,5 @@ throttle(size_t increment)
13811381
* Time interval for the remaining amount and possible next increments
13821382
* starts now.
13831383
*/
1384-
throttled_last=GetCurrentIntegerTimestamp();
1384+
throttled_last=GetCurrentTimestamp();
13851385
}

‎src/backend/replication/logical/worker.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -981,12 +981,11 @@ ApplyLoop(void)
981981
{
982982
XLogRecPtrstart_lsn;
983983
XLogRecPtrend_lsn;
984-
TimestampTzsend_time;
984+
TimestampTzsend_time;
985985

986986
start_lsn=pq_getmsgint64(&s);
987987
end_lsn=pq_getmsgint64(&s);
988-
send_time=
989-
IntegerTimestampToTimestampTz(pq_getmsgint64(&s));
988+
send_time=pq_getmsgint64(&s);
990989

991990
if (last_received<start_lsn)
992991
last_received=start_lsn;
@@ -1000,13 +999,12 @@ ApplyLoop(void)
1000999
}
10011000
elseif (c=='k')
10021001
{
1003-
XLogRecPtrendpos;
1004-
TimestampTztimestamp;
1005-
boolreply_requested;
1002+
XLogRecPtrendpos;
1003+
TimestampTztimestamp;
1004+
boolreply_requested;
10061005

10071006
endpos=pq_getmsgint64(&s);
1008-
timestamp=
1009-
IntegerTimestampToTimestampTz(pq_getmsgint64(&s));
1007+
timestamp=pq_getmsgint64(&s);
10101008
reply_requested=pq_getmsgbyte(&s);
10111009

10121010
send_feedback(endpos,reply_requested, false);

‎src/backend/replication/walreceiver.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -892,8 +892,7 @@ XLogWalRcvProcessMsg(unsigned char type, char *buf, Size len)
892892
/* read the fields */
893893
dataStart=pq_getmsgint64(&incoming_message);
894894
walEnd=pq_getmsgint64(&incoming_message);
895-
sendTime=IntegerTimestampToTimestampTz(
896-
pq_getmsgint64(&incoming_message));
895+
sendTime=pq_getmsgint64(&incoming_message);
897896
ProcessWalSndrMessage(walEnd,sendTime);
898897

899898
buf+=hdrlen;
@@ -913,8 +912,7 @@ XLogWalRcvProcessMsg(unsigned char type, char *buf, Size len)
913912

914913
/* read the fields */
915914
walEnd=pq_getmsgint64(&incoming_message);
916-
sendTime=IntegerTimestampToTimestampTz(
917-
pq_getmsgint64(&incoming_message));
915+
sendTime=pq_getmsgint64(&incoming_message);
918916
replyRequested=pq_getmsgbyte(&incoming_message);
919917

920918
ProcessWalSndrMessage(walEnd,sendTime);
@@ -1149,7 +1147,7 @@ XLogWalRcvSendReply(bool force, bool requestReply)
11491147
pq_sendint64(&reply_message,writePtr);
11501148
pq_sendint64(&reply_message,flushPtr);
11511149
pq_sendint64(&reply_message,applyPtr);
1152-
pq_sendint64(&reply_message,GetCurrentIntegerTimestamp());
1150+
pq_sendint64(&reply_message,GetCurrentTimestamp());
11531151
pq_sendbyte(&reply_message,requestReply ?1 :0);
11541152

11551153
/* Send it */
@@ -1241,7 +1239,7 @@ XLogWalRcvSendHSFeedback(bool immed)
12411239
/* Construct the message and send it. */
12421240
resetStringInfo(&reply_message);
12431241
pq_sendbyte(&reply_message,'h');
1244-
pq_sendint64(&reply_message,GetCurrentIntegerTimestamp());
1242+
pq_sendint64(&reply_message,GetCurrentTimestamp());
12451243
pq_sendint(&reply_message,xmin,4);
12461244
pq_sendint(&reply_message,nextEpoch,4);
12471245
walrcv_send(wrconn,reply_message.data,reply_message.len);

‎src/backend/replication/walsender.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -823,12 +823,13 @@ CreateReplicationSlot(CreateReplicationSlotCmd *cmd)
823823
dest=CreateDestReceiver(DestRemoteSimple);
824824
MemSet(nulls, false,sizeof(nulls));
825825

826-
/*
826+
/*----------
827827
* Need a tuple descriptor representing four columns:
828828
* - first field: the slot name
829829
* - second field: LSN at which we became consistent
830830
* - third field: exported snapshot's name
831831
* - fourth field: output plugin
832+
*----------
832833
*/
833834
tupdesc=CreateTemplateTupleDesc(4, false);
834835
TupleDescInitBuiltinEntry(tupdesc, (AttrNumber)1,"slot_name",
@@ -1014,7 +1015,7 @@ WalSndWriteData(LogicalDecodingContext *ctx, XLogRecPtr lsn, TransactionId xid,
10141015
* several releases by streaming physical replication.
10151016
*/
10161017
resetStringInfo(&tmpbuf);
1017-
pq_sendint64(&tmpbuf,GetCurrentIntegerTimestamp());
1018+
pq_sendint64(&tmpbuf,GetCurrentTimestamp());
10181019
memcpy(&ctx->out->data[1+sizeof(int64)+sizeof(int64)],
10191020
tmpbuf.data,sizeof(int64));
10201021

@@ -2334,7 +2335,7 @@ XLogSendPhysical(void)
23342335
* Fill the send timestamp last, so that it is taken as late as possible.
23352336
*/
23362337
resetStringInfo(&tmpbuf);
2337-
pq_sendint64(&tmpbuf,GetCurrentIntegerTimestamp());
2338+
pq_sendint64(&tmpbuf,GetCurrentTimestamp());
23382339
memcpy(&output_message.data[1+sizeof(int64)+sizeof(int64)],
23392340
tmpbuf.data,sizeof(int64));
23402341

@@ -2842,7 +2843,7 @@ WalSndKeepalive(bool requestReply)
28422843
resetStringInfo(&output_message);
28432844
pq_sendbyte(&output_message,'k');
28442845
pq_sendint64(&output_message,sentPtr);
2845-
pq_sendint64(&output_message,GetCurrentIntegerTimestamp());
2846+
pq_sendint64(&output_message,GetCurrentTimestamp());
28462847
pq_sendbyte(&output_message,requestReply ?1 :0);
28472848

28482849
/* ... and send it wrapped in CopyData */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp