Skip to content

Commit 3937cad

Browse files
committed
Use more consistently int64 for page numbers in SLRU-related code
clog.c, async.c and predicate.c included some SLRU page numbers still handled as 4-byte integers, while int64 should be used for this purpose. These holes have been introduced in 4ed8f09, that has introduced the use of 8-byte integers for SLRU page numbers, still forgot about the code paths updated by this commit. Reported-by: Noah Misch Author: Aleksander Alekseev, Michael Paquier Discussion: https://postgr.es/m/20240626002747.dc.nmisch@google.com Backpatch-through: 17
1 parent f68d85b commit 3937cad

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

src/backend/access/transam/clog.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ TransactionGroupUpdateXidStatus(TransactionId xid, XidStatus status,
445445
PGPROC *proc = MyProc;
446446
uint32 nextidx;
447447
uint32 wakeidx;
448-
int prevpageno;
448+
int64 prevpageno;
449449
LWLock *prevlock = NULL;
450450

451451
/* We should definitely have an XID whose status needs to be updated. */
@@ -577,7 +577,7 @@ TransactionGroupUpdateXidStatus(TransactionId xid, XidStatus status,
577577
while (nextidx != INVALID_PROC_NUMBER)
578578
{
579579
PGPROC *nextproc = &ProcGlobal->allProcs[nextidx];
580-
int thispageno = nextproc->clogGroupMemberPage;
580+
int64 thispageno = nextproc->clogGroupMemberPage;
581581

582582
/*
583583
* If the page to update belongs to a different bank than the previous

src/backend/commands/async.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ typedef struct AsyncQueueControl
283283
QueuePosition head; /* head points to the next free location */
284284
QueuePosition tail; /* tail must be <= the queue position of every
285285
* listening backend */
286-
int stopPage; /* oldest unrecycled page; must be <=
286+
int64 stopPage; /* oldest unrecycled page; must be <=
287287
* tail.page */
288288
ProcNumber firstListener; /* id of first listener, or
289289
* INVALID_PROC_NUMBER */
@@ -1271,9 +1271,9 @@ asyncQueueUnregister(void)
12711271
static bool
12721272
asyncQueueIsFull(void)
12731273
{
1274-
int headPage = QUEUE_POS_PAGE(QUEUE_HEAD);
1275-
int tailPage = QUEUE_POS_PAGE(QUEUE_TAIL);
1276-
int occupied = headPage - tailPage;
1274+
int64 headPage = QUEUE_POS_PAGE(QUEUE_HEAD);
1275+
int64 tailPage = QUEUE_POS_PAGE(QUEUE_TAIL);
1276+
int64 occupied = headPage - tailPage;
12771277

12781278
return occupied >= max_notify_queue_pages;
12791279
}
@@ -1505,9 +1505,9 @@ pg_notification_queue_usage(PG_FUNCTION_ARGS)
15051505
static double
15061506
asyncQueueUsage(void)
15071507
{
1508-
int headPage = QUEUE_POS_PAGE(QUEUE_HEAD);
1509-
int tailPage = QUEUE_POS_PAGE(QUEUE_TAIL);
1510-
int occupied = headPage - tailPage;
1508+
int64 headPage = QUEUE_POS_PAGE(QUEUE_HEAD);
1509+
int64 tailPage = QUEUE_POS_PAGE(QUEUE_TAIL);
1510+
int64 occupied = headPage - tailPage;
15111511

15121512
if (occupied == 0)
15131513
return (double) 0; /* fast exit for common case */
@@ -1932,7 +1932,7 @@ asyncQueueReadAllNotifications(void)
19321932

19331933
do
19341934
{
1935-
int curpage = QUEUE_POS_PAGE(pos);
1935+
int64 curpage = QUEUE_POS_PAGE(pos);
19361936
int curoffset = QUEUE_POS_OFFSET(pos);
19371937
int slotno;
19381938
int copysize;
@@ -2108,9 +2108,9 @@ static void
21082108
asyncQueueAdvanceTail(void)
21092109
{
21102110
QueuePosition min;
2111-
int oldtailpage;
2112-
int newtailpage;
2113-
int boundary;
2111+
int64 oldtailpage;
2112+
int64 newtailpage;
2113+
int64 boundary;
21142114

21152115
/* Restrict task to one backend per cluster; see SimpleLruTruncate(). */
21162116
LWLockAcquire(NotifyQueueTailLock, LW_EXCLUSIVE);

src/backend/storage/lmgr/predicate.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ static SlruCtlData SerialSlruCtlData;
344344

345345
typedef struct SerialControlData
346346
{
347-
int headPage; /* newest initialized page */
347+
int64 headPage; /* newest initialized page */
348348
TransactionId headXid; /* newest valid Xid in the SLRU */
349349
TransactionId tailXid; /* oldest xmin we might be interested in */
350350
} SerialControlData;
@@ -1035,7 +1035,7 @@ SerialSetActiveSerXmin(TransactionId xid)
10351035
void
10361036
CheckPointPredicate(void)
10371037
{
1038-
int truncateCutoffPage;
1038+
int64 truncateCutoffPage;
10391039

10401040
LWLockAcquire(SerialControlLock, LW_EXCLUSIVE);
10411041

@@ -1048,7 +1048,7 @@ CheckPointPredicate(void)
10481048

10491049
if (TransactionIdIsValid(serialControl->tailXid))
10501050
{
1051-
int tailPage;
1051+
int64 tailPage;
10521052

10531053
tailPage = SerialPage(serialControl->tailXid);
10541054

0 commit comments

Comments
 (0)