summaryrefslogtreecommitdiff
path: root/src/backend/storage/ipc
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2024-02-22 01:21:34 +0200
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2024-02-22 01:21:34 +0200
commit28f3915b73f75bd1b50ba070f56b34241fe53fd1 (patch)
tree10d305f3f98af6cfae7d683ce9b13c449d8e8796 /src/backend/storage/ipc
parent4989ce72644b9d636b9b23c7a1719a405e62670b (diff)
Remove superfluous 'pgprocno' field from PGPROC
It was always just the index of the PGPROC entry from the beginning of the proc array. Introduce a macro to compute it from the pointer instead. Reviewed-by: Andres Freund Discussion: https://www.postgresql.org/message-id/8171f1aa-496f-46a6-afc3-c46fe7a9b407@iki.fi
Diffstat (limited to 'src/backend/storage/ipc')
-rw-r--r--src/backend/storage/ipc/procarray.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c
index ee2d7f8585a..dd329a86ef4 100644
--- a/src/backend/storage/ipc/procarray.c
+++ b/src/backend/storage/ipc/procarray.c
@@ -468,6 +468,7 @@ CreateSharedProcArray(void)
void
ProcArrayAdd(PGPROC *proc)
{
+ int pgprocno = GetNumberFromPGProc(proc);
ProcArrayStruct *arrayP = procArray;
int index;
int movecount;
@@ -499,13 +500,13 @@ ProcArrayAdd(PGPROC *proc)
*/
for (index = 0; index < arrayP->numProcs; index++)
{
- int procno PG_USED_FOR_ASSERTS_ONLY = arrayP->pgprocnos[index];
+ int this_procno = arrayP->pgprocnos[index];
- Assert(procno >= 0 && procno < (arrayP->maxProcs + NUM_AUXILIARY_PROCS));
- Assert(allProcs[procno].pgxactoff == index);
+ Assert(this_procno >= 0 && this_procno < (arrayP->maxProcs + NUM_AUXILIARY_PROCS));
+ Assert(allProcs[this_procno].pgxactoff == index);
/* If we have found our right position in the array, break */
- if (arrayP->pgprocnos[index] > proc->pgprocno)
+ if (this_procno > pgprocno)
break;
}
@@ -523,7 +524,7 @@ ProcArrayAdd(PGPROC *proc)
&ProcGlobal->statusFlags[index],
movecount * sizeof(*ProcGlobal->statusFlags));
- arrayP->pgprocnos[index] = proc->pgprocno;
+ arrayP->pgprocnos[index] = GetNumberFromPGProc(proc);
proc->pgxactoff = index;
ProcGlobal->xids[index] = proc->xid;
ProcGlobal->subxidStates[index] = proc->subxidStatus;
@@ -791,6 +792,7 @@ ProcArrayEndTransactionInternal(PGPROC *proc, TransactionId latestXid)
static void
ProcArrayGroupClearXid(PGPROC *proc, TransactionId latestXid)
{
+ int pgprocno = GetNumberFromPGProc(proc);
PROC_HDR *procglobal = ProcGlobal;
uint32 nextidx;
uint32 wakeidx;
@@ -808,7 +810,7 @@ ProcArrayGroupClearXid(PGPROC *proc, TransactionId latestXid)
if (pg_atomic_compare_exchange_u32(&procglobal->procArrayGroupFirst,
&nextidx,
- (uint32) proc->pgprocno))
+ (uint32) pgprocno))
break;
}