62
62
#define CLOG_XACTS_PER_PAGE (BLCKSZ * CLOG_XACTS_PER_BYTE)
63
63
#define CLOG_XACT_BITMASK ((1 << CLOG_BITS_PER_XACT) - 1)
64
64
65
- #define TransactionIdToPage (xid ) ((xid) / (TransactionId) CLOG_XACTS_PER_PAGE)
65
+
66
+ /*
67
+ * Although we return an int64 the actual value can't currently exceed
68
+ * 0xFFFFFFFF/CLOG_XACTS_PER_PAGE.
69
+ */
70
+ static inline int64
71
+ TransactionIdToPage (TransactionId xid )
72
+ {
73
+ return xid / (int64 ) CLOG_XACTS_PER_PAGE ;
74
+ }
75
+
66
76
#define TransactionIdToPgIndex (xid ) ((xid) % (TransactionId) CLOG_XACTS_PER_PAGE)
67
77
#define TransactionIdToByte (xid ) (TransactionIdToPgIndex(xid) / CLOG_XACTS_PER_BYTE)
68
78
#define TransactionIdToBIndex (xid ) ((xid) % (TransactionId) CLOG_XACTS_PER_BYTE)
@@ -89,24 +99,24 @@ static SlruCtlData XactCtlData;
89
99
#define XactCtl (&XactCtlData)
90
100
91
101
92
- static int ZeroCLOGPage (int pageno , bool writeXlog );
93
- static bool CLOGPagePrecedes (int page1 , int page2 );
94
- static void WriteZeroPageXlogRec (int pageno );
95
- static void WriteTruncateXlogRec (int pageno , TransactionId oldestXact ,
102
+ static int ZeroCLOGPage (int64 pageno , bool writeXlog );
103
+ static bool CLOGPagePrecedes (int64 page1 , int64 page2 );
104
+ static void WriteZeroPageXlogRec (int64 pageno );
105
+ static void WriteTruncateXlogRec (int64 pageno , TransactionId oldestXact ,
96
106
Oid oldestXactDb );
97
107
static void TransactionIdSetPageStatus (TransactionId xid , int nsubxids ,
98
108
TransactionId * subxids , XidStatus status ,
99
- XLogRecPtr lsn , int pageno ,
109
+ XLogRecPtr lsn , int64 pageno ,
100
110
bool all_xact_same_page );
101
111
static void TransactionIdSetStatusBit (TransactionId xid , XidStatus status ,
102
112
XLogRecPtr lsn , int slotno );
103
113
static void set_status_by_pages (int nsubxids , TransactionId * subxids ,
104
114
XidStatus status , XLogRecPtr lsn );
105
115
static bool TransactionGroupUpdateXidStatus (TransactionId xid ,
106
- XidStatus status , XLogRecPtr lsn , int pageno );
116
+ XidStatus status , XLogRecPtr lsn , int64 pageno );
107
117
static void TransactionIdSetPageStatusInternal (TransactionId xid , int nsubxids ,
108
118
TransactionId * subxids , XidStatus status ,
109
- XLogRecPtr lsn , int pageno );
119
+ XLogRecPtr lsn , int64 pageno );
110
120
111
121
112
122
/*
162
172
TransactionIdSetTreeStatus (TransactionId xid , int nsubxids ,
163
173
TransactionId * subxids , XidStatus status , XLogRecPtr lsn )
164
174
{
165
- int pageno = TransactionIdToPage (xid ); /* get page of parent */
175
+ int64 pageno = TransactionIdToPage (xid ); /* get page of parent */
166
176
int i ;
167
177
168
178
Assert (status == TRANSACTION_STATUS_COMMITTED ||
@@ -236,7 +246,7 @@ static void
236
246
set_status_by_pages (int nsubxids , TransactionId * subxids ,
237
247
XidStatus status , XLogRecPtr lsn )
238
248
{
239
- int pageno = TransactionIdToPage (subxids [0 ]);
249
+ int64 pageno = TransactionIdToPage (subxids [0 ]);
240
250
int offset = 0 ;
241
251
int i = 0 ;
242
252
@@ -245,7 +255,7 @@ set_status_by_pages(int nsubxids, TransactionId *subxids,
245
255
while (i < nsubxids )
246
256
{
247
257
int num_on_page = 0 ;
248
- int nextpageno ;
258
+ int64 nextpageno ;
249
259
250
260
do
251
261
{
@@ -271,7 +281,7 @@ set_status_by_pages(int nsubxids, TransactionId *subxids,
271
281
static void
272
282
TransactionIdSetPageStatus (TransactionId xid , int nsubxids ,
273
283
TransactionId * subxids , XidStatus status ,
274
- XLogRecPtr lsn , int pageno ,
284
+ XLogRecPtr lsn , int64 pageno ,
275
285
bool all_xact_same_page )
276
286
{
277
287
/* Can't use group update when PGPROC overflows. */
@@ -337,7 +347,7 @@ TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
337
347
static void
338
348
TransactionIdSetPageStatusInternal (TransactionId xid , int nsubxids ,
339
349
TransactionId * subxids , XidStatus status ,
340
- XLogRecPtr lsn , int pageno )
350
+ XLogRecPtr lsn , int64 pageno )
341
351
{
342
352
int slotno ;
343
353
int i ;
@@ -411,7 +421,7 @@ TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
411
421
*/
412
422
static bool
413
423
TransactionGroupUpdateXidStatus (TransactionId xid , XidStatus status ,
414
- XLogRecPtr lsn , int pageno )
424
+ XLogRecPtr lsn , int64 pageno )
415
425
{
416
426
volatile PROC_HDR * procglobal = ProcGlobal ;
417
427
PGPROC * proc = MyProc ;
@@ -637,7 +647,7 @@ TransactionIdSetStatusBit(TransactionId xid, XidStatus status, XLogRecPtr lsn, i
637
647
XidStatus
638
648
TransactionIdGetStatus (TransactionId xid , XLogRecPtr * lsn )
639
649
{
640
- int pageno = TransactionIdToPage (xid );
650
+ int64 pageno = TransactionIdToPage (xid );
641
651
int byteno = TransactionIdToByte (xid );
642
652
int bshift = TransactionIdToBIndex (xid ) * CLOG_BITS_PER_XACT ;
643
653
int slotno ;
@@ -697,7 +707,7 @@ CLOGShmemInit(void)
697
707
XactCtl -> PagePrecedes = CLOGPagePrecedes ;
698
708
SimpleLruInit (XactCtl , "Xact" , CLOGShmemBuffers (), CLOG_LSNS_PER_PAGE ,
699
709
XactSLRULock , "pg_xact" , LWTRANCHE_XACT_BUFFER ,
700
- SYNC_HANDLER_CLOG );
710
+ SYNC_HANDLER_CLOG , false );
701
711
SlruPagePrecedesUnitTests (XactCtl , CLOG_XACTS_PER_PAGE );
702
712
}
703
713
@@ -734,7 +744,7 @@ BootStrapCLOG(void)
734
744
* Control lock must be held at entry, and will be held at exit.
735
745
*/
736
746
static int
737
- ZeroCLOGPage (int pageno , bool writeXlog )
747
+ ZeroCLOGPage (int64 pageno , bool writeXlog )
738
748
{
739
749
int slotno ;
740
750
754
764
StartupCLOG (void )
755
765
{
756
766
TransactionId xid = XidFromFullTransactionId (ShmemVariableCache -> nextXid );
757
- int pageno = TransactionIdToPage (xid );
767
+ int64 pageno = TransactionIdToPage (xid );
758
768
759
769
LWLockAcquire (XactSLRULock , LW_EXCLUSIVE );
760
770
773
783
TrimCLOG (void )
774
784
{
775
785
TransactionId xid = XidFromFullTransactionId (ShmemVariableCache -> nextXid );
776
- int pageno = TransactionIdToPage (xid );
786
+ int64 pageno = TransactionIdToPage (xid );
777
787
778
788
LWLockAcquire (XactSLRULock , LW_EXCLUSIVE );
779
789
@@ -838,7 +848,7 @@ CheckPointCLOG(void)
838
848
void
839
849
ExtendCLOG (TransactionId newestXact )
840
850
{
841
- int pageno ;
851
+ int64 pageno ;
842
852
843
853
/*
844
854
* No work except at first XID of a page. But beware: just after
@@ -877,7 +887,7 @@ ExtendCLOG(TransactionId newestXact)
877
887
void
878
888
TruncateCLOG (TransactionId oldestXact , Oid oldestxid_datoid )
879
889
{
880
- int cutoffPage ;
890
+ int64 cutoffPage ;
881
891
882
892
/*
883
893
* The cutoff point is the start of the segment containing oldestXact. We
@@ -930,7 +940,7 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
930
940
* don't optimize that edge case.
931
941
*/
932
942
static bool
933
- CLOGPagePrecedes (int page1 , int page2 )
943
+ CLOGPagePrecedes (int64 page1 , int64 page2 )
934
944
{
935
945
TransactionId xid1 ;
936
946
TransactionId xid2 ;
@@ -949,10 +959,10 @@ CLOGPagePrecedes(int page1, int page2)
949
959
* Write a ZEROPAGE xlog record
950
960
*/
951
961
static void
952
- WriteZeroPageXlogRec (int pageno )
962
+ WriteZeroPageXlogRec (int64 pageno )
953
963
{
954
964
XLogBeginInsert ();
955
- XLogRegisterData ((char * ) (& pageno ), sizeof (int ));
965
+ XLogRegisterData ((char * ) (& pageno ), sizeof (pageno ));
956
966
(void ) XLogInsert (RM_CLOG_ID , CLOG_ZEROPAGE );
957
967
}
958
968
@@ -963,7 +973,7 @@ WriteZeroPageXlogRec(int pageno)
963
973
* in TruncateCLOG().
964
974
*/
965
975
static void
966
- WriteTruncateXlogRec (int pageno , TransactionId oldestXact , Oid oldestXactDb )
976
+ WriteTruncateXlogRec (int64 pageno , TransactionId oldestXact , Oid oldestXactDb )
967
977
{
968
978
XLogRecPtr recptr ;
969
979
xl_clog_truncate xlrec ;
@@ -991,10 +1001,10 @@ clog_redo(XLogReaderState *record)
991
1001
992
1002
if (info == CLOG_ZEROPAGE )
993
1003
{
994
- int pageno ;
1004
+ int64 pageno ;
995
1005
int slotno ;
996
1006
997
- memcpy (& pageno , XLogRecGetData (record ), sizeof (int ));
1007
+ memcpy (& pageno , XLogRecGetData (record ), sizeof (pageno ));
998
1008
999
1009
LWLockAcquire (XactSLRULock , LW_EXCLUSIVE );
1000
1010
0 commit comments