1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-03 01:21:48 +03:00

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/20240626002747.dc.nmisch@google.com
Backpatch-through: 17
This commit is contained in:
Michael Paquier 2024-07-23 17:59:20 +09:00
parent 3b279d89cb
commit 165ea79a60
3 changed files with 16 additions and 16 deletions

View File

@ -445,7 +445,7 @@ TransactionGroupUpdateXidStatus(TransactionId xid, XidStatus status,
PGPROC *proc = MyProc; PGPROC *proc = MyProc;
uint32 nextidx; uint32 nextidx;
uint32 wakeidx; uint32 wakeidx;
int prevpageno; int64 prevpageno;
LWLock *prevlock = NULL; LWLock *prevlock = NULL;
/* We should definitely have an XID whose status needs to be updated. */ /* 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) while (nextidx != INVALID_PROC_NUMBER)
{ {
PGPROC *nextproc = &ProcGlobal->allProcs[nextidx]; 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 * If the page to update belongs to a different bank than the previous

View File

@ -283,7 +283,7 @@ typedef struct AsyncQueueControl
QueuePosition head; /* head points to the next free location */ QueuePosition head; /* head points to the next free location */
QueuePosition tail; /* tail must be <= the queue position of every QueuePosition tail; /* tail must be <= the queue position of every
* listening backend */ * listening backend */
int stopPage; /* oldest unrecycled page; must be <= int64 stopPage; /* oldest unrecycled page; must be <=
* tail.page */ * tail.page */
ProcNumber firstListener; /* id of first listener, or ProcNumber firstListener; /* id of first listener, or
* INVALID_PROC_NUMBER */ * INVALID_PROC_NUMBER */
@ -1271,9 +1271,9 @@ asyncQueueUnregister(void)
static bool static bool
asyncQueueIsFull(void) asyncQueueIsFull(void)
{ {
int headPage = QUEUE_POS_PAGE(QUEUE_HEAD); int64 headPage = QUEUE_POS_PAGE(QUEUE_HEAD);
int tailPage = QUEUE_POS_PAGE(QUEUE_TAIL); int64 tailPage = QUEUE_POS_PAGE(QUEUE_TAIL);
int occupied = headPage - tailPage; int64 occupied = headPage - tailPage;
return occupied >= max_notify_queue_pages; return occupied >= max_notify_queue_pages;
} }
@ -1505,9 +1505,9 @@ pg_notification_queue_usage(PG_FUNCTION_ARGS)
static double static double
asyncQueueUsage(void) asyncQueueUsage(void)
{ {
int headPage = QUEUE_POS_PAGE(QUEUE_HEAD); int64 headPage = QUEUE_POS_PAGE(QUEUE_HEAD);
int tailPage = QUEUE_POS_PAGE(QUEUE_TAIL); int64 tailPage = QUEUE_POS_PAGE(QUEUE_TAIL);
int occupied = headPage - tailPage; int64 occupied = headPage - tailPage;
if (occupied == 0) if (occupied == 0)
return (double) 0; /* fast exit for common case */ return (double) 0; /* fast exit for common case */
@ -1932,7 +1932,7 @@ asyncQueueReadAllNotifications(void)
do do
{ {
int curpage = QUEUE_POS_PAGE(pos); int64 curpage = QUEUE_POS_PAGE(pos);
int curoffset = QUEUE_POS_OFFSET(pos); int curoffset = QUEUE_POS_OFFSET(pos);
int slotno; int slotno;
int copysize; int copysize;
@ -2108,9 +2108,9 @@ static void
asyncQueueAdvanceTail(void) asyncQueueAdvanceTail(void)
{ {
QueuePosition min; QueuePosition min;
int oldtailpage; int64 oldtailpage;
int newtailpage; int64 newtailpage;
int boundary; int64 boundary;
/* Restrict task to one backend per cluster; see SimpleLruTruncate(). */ /* Restrict task to one backend per cluster; see SimpleLruTruncate(). */
LWLockAcquire(NotifyQueueTailLock, LW_EXCLUSIVE); LWLockAcquire(NotifyQueueTailLock, LW_EXCLUSIVE);

View File

@ -344,7 +344,7 @@ static SlruCtlData SerialSlruCtlData;
typedef struct SerialControlData typedef struct SerialControlData
{ {
int headPage; /* newest initialized page */ int64 headPage; /* newest initialized page */
TransactionId headXid; /* newest valid Xid in the SLRU */ TransactionId headXid; /* newest valid Xid in the SLRU */
TransactionId tailXid; /* oldest xmin we might be interested in */ TransactionId tailXid; /* oldest xmin we might be interested in */
} SerialControlData; } SerialControlData;
@ -1035,7 +1035,7 @@ SerialSetActiveSerXmin(TransactionId xid)
void void
CheckPointPredicate(void) CheckPointPredicate(void)
{ {
int truncateCutoffPage; int64 truncateCutoffPage;
LWLockAcquire(SerialControlLock, LW_EXCLUSIVE); LWLockAcquire(SerialControlLock, LW_EXCLUSIVE);
@ -1048,7 +1048,7 @@ CheckPointPredicate(void)
if (TransactionIdIsValid(serialControl->tailXid)) if (TransactionIdIsValid(serialControl->tailXid))
{ {
int tailPage; int64 tailPage;
tailPage = SerialPage(serialControl->tailXid); tailPage = SerialPage(serialControl->tailXid);