@@ -80,13 +80,12 @@ static SlruCtlData ClogCtlData;
80
80
#define ClogCtl (&ClogCtlData)
81
81
82
82
83
- static int ZeroCLOGPage (int pageno , bool writeXlog );
84
- static bool CLOGPagePrecedes (int page1 , int page2 );
85
- static void WriteZeroPageXlogRec (int pageno );
86
- static void WriteTruncateXlogRec (int pageno );
83
+ static int ZeroCLOGPage (int64 pageno , bool writeXlog );
84
+ static void WriteZeroPageXlogRec (int64 pageno );
85
+ static void WriteTruncateXlogRec (int64 pageno );
87
86
static void TransactionIdSetPageStatus (TransactionId xid , int nsubxids ,
88
87
TransactionId * subxids , XidStatus status ,
89
- XLogRecPtr lsn , int pageno );
88
+ XLogRecPtr lsn , int64 pageno );
90
89
static void TransactionIdSetStatusBit (TransactionId xid , XidStatus status ,
91
90
XLogRecPtr lsn , int slotno );
92
91
static void set_status_by_pages (int nsubxids , TransactionId * subxids ,
148
147
TransactionIdSetTreeStatus (TransactionId xid , int nsubxids ,
149
148
TransactionId * subxids , XidStatus status , XLogRecPtr lsn )
150
149
{
151
- int pageno = TransactionIdToPage (xid ); /* get page of parent */
150
+ int64 pageno = TransactionIdToPage (xid ); /* get page of parent */
152
151
int i ;
153
152
154
153
Assert (status == TRANSACTION_STATUS_COMMITTED ||
@@ -222,7 +221,7 @@ static void
222
221
set_status_by_pages (int nsubxids , TransactionId * subxids ,
223
222
XidStatus status , XLogRecPtr lsn )
224
223
{
225
- int pageno = TransactionIdToPage (subxids [0 ]);
224
+ int64 pageno = TransactionIdToPage (subxids [0 ]);
226
225
int offset = 0 ;
227
226
int i = 0 ;
228
227
@@ -253,7 +252,7 @@ set_status_by_pages(int nsubxids, TransactionId *subxids,
253
252
static void
254
253
TransactionIdSetPageStatus (TransactionId xid , int nsubxids ,
255
254
TransactionId * subxids , XidStatus status ,
256
- XLogRecPtr lsn , int pageno )
255
+ XLogRecPtr lsn , int64 pageno )
257
256
{
258
257
int slotno ;
259
258
int i ;
@@ -391,7 +390,7 @@ TransactionIdSetStatusBit(TransactionId xid, XidStatus status, XLogRecPtr lsn, i
391
390
XidStatus
392
391
TransactionIdGetStatus (TransactionId xid , XLogRecPtr * lsn )
393
392
{
394
- int pageno = TransactionIdToPage (xid );
393
+ int64 pageno = TransactionIdToPage (xid );
395
394
int byteno = TransactionIdToByte (xid );
396
395
int bshift = TransactionIdToBIndex (xid ) * CLOG_BITS_PER_XACT ;
397
396
int slotno ;
@@ -448,7 +447,6 @@ CLOGShmemSize(void)
448
447
void
449
448
CLOGShmemInit (void )
450
449
{
451
- ClogCtl -> PagePrecedes = CLOGPagePrecedes ;
452
450
SimpleLruInit (ClogCtl , "clog" , CLOGShmemBuffers (), CLOG_LSNS_PER_PAGE ,
453
451
CLogControlLock , "pg_clog" , LWTRANCHE_CLOG_BUFFERS );
454
452
}
@@ -486,7 +484,7 @@ BootStrapCLOG(void)
486
484
* Control lock must be held at entry, and will be held at exit.
487
485
*/
488
486
static int
489
- ZeroCLOGPage (int pageno , bool writeXlog )
487
+ ZeroCLOGPage (int64 pageno , bool writeXlog )
490
488
{
491
489
int slotno ;
492
490
506
504
StartupCLOG (void )
507
505
{
508
506
TransactionId xid = ShmemVariableCache -> nextXid ;
509
- int pageno = TransactionIdToPage (xid );
507
+ int64 pageno = TransactionIdToPage (xid );
510
508
511
509
LWLockAcquire (CLogControlLock , LW_EXCLUSIVE );
512
510
525
523
TrimCLOG (void )
526
524
{
527
525
TransactionId xid = ShmemVariableCache -> nextXid ;
528
- int pageno = TransactionIdToPage (xid );
526
+ int64 pageno = TransactionIdToPage (xid );
529
527
530
528
LWLockAcquire (CLogControlLock , LW_EXCLUSIVE );
531
529
@@ -603,7 +601,7 @@ CheckPointCLOG(void)
603
601
void
604
602
ExtendCLOG (TransactionId newestXact )
605
603
{
606
- int pageno ;
604
+ int64 pageno ;
607
605
608
606
/*
609
607
* No work except at first XID of a page. But beware: just after
@@ -642,7 +640,7 @@ ExtendCLOG(TransactionId newestXact)
642
640
void
643
641
TruncateCLOG (TransactionId oldestXact )
644
642
{
645
- int cutoffPage ;
643
+ int64 cutoffPage ;
646
644
647
645
/*
648
646
* The cutoff point is the start of the segment containing oldestXact. We
@@ -661,39 +659,14 @@ TruncateCLOG(TransactionId oldestXact)
661
659
SimpleLruTruncate (ClogCtl , cutoffPage );
662
660
}
663
661
664
-
665
- /*
666
- * Decide which of two CLOG page numbers is "older" for truncation purposes.
667
- *
668
- * We need to use comparison of TransactionIds here in order to do the right
669
- * thing with wraparound XID arithmetic. However, if we are asked about
670
- * page number zero, we don't want to hand InvalidTransactionId to
671
- * TransactionIdPrecedes: it'll get weird about permanent xact IDs. So,
672
- * offset both xids by FirstNormalTransactionId to avoid that.
673
- */
674
- static bool
675
- CLOGPagePrecedes (int page1 , int page2 )
676
- {
677
- TransactionId xid1 ;
678
- TransactionId xid2 ;
679
-
680
- xid1 = ((TransactionId ) page1 ) * CLOG_XACTS_PER_PAGE ;
681
- xid1 += FirstNormalTransactionId ;
682
- xid2 = ((TransactionId ) page2 ) * CLOG_XACTS_PER_PAGE ;
683
- xid2 += FirstNormalTransactionId ;
684
-
685
- return TransactionIdPrecedes (xid1 , xid2 );
686
- }
687
-
688
-
689
662
/*
690
663
* Write a ZEROPAGE xlog record
691
664
*/
692
665
static void
693
- WriteZeroPageXlogRec (int pageno )
666
+ WriteZeroPageXlogRec (int64 pageno )
694
667
{
695
668
XLogBeginInsert ();
696
- XLogRegisterData ((char * ) (& pageno ), sizeof (int ));
669
+ XLogRegisterData ((char * ) (& pageno ), sizeof (int64 ));
697
670
(void ) XLogInsert (RM_CLOG_ID , CLOG_ZEROPAGE );
698
671
}
699
672
@@ -704,12 +677,12 @@ WriteZeroPageXlogRec(int pageno)
704
677
* in TruncateCLOG().
705
678
*/
706
679
static void
707
- WriteTruncateXlogRec (int pageno )
680
+ WriteTruncateXlogRec (int64 pageno )
708
681
{
709
682
XLogRecPtr recptr ;
710
683
711
684
XLogBeginInsert ();
712
- XLogRegisterData ((char * ) (& pageno ), sizeof (int ));
685
+ XLogRegisterData ((char * ) (& pageno ), sizeof (int64 ));
713
686
recptr = XLogInsert (RM_CLOG_ID , CLOG_TRUNCATE );
714
687
XLogFlush (recptr );
715
688
}
@@ -727,10 +700,10 @@ clog_redo(XLogReaderState *record)
727
700
728
701
if (info == CLOG_ZEROPAGE )
729
702
{
730
- int pageno ;
703
+ int64 pageno ;
731
704
int slotno ;
732
705
733
- memcpy (& pageno , XLogRecGetData (record ), sizeof (int ));
706
+ memcpy (& pageno , XLogRecGetData (record ), sizeof (int64 ));
734
707
735
708
LWLockAcquire (CLogControlLock , LW_EXCLUSIVE );
736
709
@@ -742,9 +715,9 @@ clog_redo(XLogReaderState *record)
742
715
}
743
716
else if (info == CLOG_TRUNCATE )
744
717
{
745
- int pageno ;
718
+ int64 pageno ;
746
719
747
- memcpy (& pageno , XLogRecGetData (record ), sizeof (int ));
720
+ memcpy (& pageno , XLogRecGetData (record ), sizeof (int64 ));
748
721
749
722
/*
750
723
* During XLOG replay, latest_page_number isn't set up yet; insert a
0 commit comments