mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
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
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user