diff options
author | Michael Paquier | 2024-07-23 08:59:05 +0000 |
---|---|---|
committer | Michael Paquier | 2024-07-23 08:59:05 +0000 |
commit | 3937cadfd4383fd32f3fd8d8dc5efc32b3d12664 (patch) | |
tree | aadde6d73c160bc4bb992a05f8dd8bfbc5e2b0c2 | |
parent | f68d85bf69233ef842a08707bbd1204ef8216549 (diff) |
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 4ed8f0913bfd, 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/[email protected]
Backpatch-through: 17
-rw-r--r-- | src/backend/access/transam/clog.c | 4 | ||||
-rw-r--r-- | src/backend/commands/async.c | 22 | ||||
-rw-r--r-- | src/backend/storage/lmgr/predicate.c | 6 |
3 files changed, 16 insertions, 16 deletions
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c index 44c253246b9..e6f79320e94 100644 --- a/src/backend/access/transam/clog.c +++ b/src/backend/access/transam/clog.c @@ -445,7 +445,7 @@ TransactionGroupUpdateXidStatus(TransactionId xid, XidStatus status, PGPROC *proc = MyProc; uint32 nextidx; uint32 wakeidx; - int prevpageno; + int64 prevpageno; LWLock *prevlock = NULL; /* We should definitely have an XID whose status needs to be updated. */ @@ -577,7 +577,7 @@ TransactionGroupUpdateXidStatus(TransactionId xid, XidStatus status, while (nextidx != INVALID_PROC_NUMBER) { PGPROC *nextproc = &ProcGlobal->allProcs[nextidx]; - int thispageno = nextproc->clogGroupMemberPage; + int64 thispageno = nextproc->clogGroupMemberPage; /* * If the page to update belongs to a different bank than the previous diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c index ab4c72762d8..8ed503e1c1b 100644 --- a/src/backend/commands/async.c +++ b/src/backend/commands/async.c @@ -283,7 +283,7 @@ typedef struct AsyncQueueControl QueuePosition head; /* head points to the next free location */ QueuePosition tail; /* tail must be <= the queue position of every * listening backend */ - int stopPage; /* oldest unrecycled page; must be <= + int64 stopPage; /* oldest unrecycled page; must be <= * tail.page */ ProcNumber firstListener; /* id of first listener, or * INVALID_PROC_NUMBER */ @@ -1271,9 +1271,9 @@ asyncQueueUnregister(void) static bool asyncQueueIsFull(void) { - int headPage = QUEUE_POS_PAGE(QUEUE_HEAD); - int tailPage = QUEUE_POS_PAGE(QUEUE_TAIL); - int occupied = headPage - tailPage; + int64 headPage = QUEUE_POS_PAGE(QUEUE_HEAD); + int64 tailPage = QUEUE_POS_PAGE(QUEUE_TAIL); + int64 occupied = headPage - tailPage; return occupied >= max_notify_queue_pages; } @@ -1505,9 +1505,9 @@ pg_notification_queue_usage(PG_FUNCTION_ARGS) static double asyncQueueUsage(void) { - int headPage = QUEUE_POS_PAGE(QUEUE_HEAD); - int tailPage = QUEUE_POS_PAGE(QUEUE_TAIL); - int occupied = headPage - tailPage; + int64 headPage = QUEUE_POS_PAGE(QUEUE_HEAD); + int64 tailPage = QUEUE_POS_PAGE(QUEUE_TAIL); + int64 occupied = headPage - tailPage; if (occupied == 0) return (double) 0; /* fast exit for common case */ @@ -1932,7 +1932,7 @@ asyncQueueReadAllNotifications(void) do { - int curpage = QUEUE_POS_PAGE(pos); + int64 curpage = QUEUE_POS_PAGE(pos); int curoffset = QUEUE_POS_OFFSET(pos); int slotno; int copysize; @@ -2108,9 +2108,9 @@ static void asyncQueueAdvanceTail(void) { QueuePosition min; - int oldtailpage; - int newtailpage; - int boundary; + int64 oldtailpage; + int64 newtailpage; + int64 boundary; /* Restrict task to one backend per cluster; see SimpleLruTruncate(). */ LWLockAcquire(NotifyQueueTailLock, LW_EXCLUSIVE); diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c index 93841654db3..b455b78f9f7 100644 --- a/src/backend/storage/lmgr/predicate.c +++ b/src/backend/storage/lmgr/predicate.c @@ -344,7 +344,7 @@ static SlruCtlData SerialSlruCtlData; typedef struct SerialControlData { - int headPage; /* newest initialized page */ + int64 headPage; /* newest initialized page */ TransactionId headXid; /* newest valid Xid in the SLRU */ TransactionId tailXid; /* oldest xmin we might be interested in */ } SerialControlData; @@ -1035,7 +1035,7 @@ SerialSetActiveSerXmin(TransactionId xid) void CheckPointPredicate(void) { - int truncateCutoffPage; + int64 truncateCutoffPage; LWLockAcquire(SerialControlLock, LW_EXCLUSIVE); @@ -1048,7 +1048,7 @@ CheckPointPredicate(void) if (TransactionIdIsValid(serialControl->tailXid)) { - int tailPage; + int64 tailPage; tailPage = SerialPage(serialControl->tailXid); |