mirror of
https://github.com/postgres/postgres.git
synced 2025-12-19 17:02:53 +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:
@@ -425,6 +425,7 @@ TransactionGroupUpdateXidStatus(TransactionId xid, XidStatus status,
|
||||
{
|
||||
volatile PROC_HDR *procglobal = ProcGlobal;
|
||||
PGPROC *proc = MyProc;
|
||||
int pgprocno = MyProcNumber;
|
||||
uint32 nextidx;
|
||||
uint32 wakeidx;
|
||||
|
||||
@@ -458,7 +459,7 @@ TransactionGroupUpdateXidStatus(TransactionId xid, XidStatus status,
|
||||
* less efficiently.
|
||||
*/
|
||||
if (nextidx != INVALID_PGPROCNO &&
|
||||
ProcGlobal->allProcs[nextidx].clogGroupMemberPage != proc->clogGroupMemberPage)
|
||||
GetPGProcByNumber(nextidx)->clogGroupMemberPage != proc->clogGroupMemberPage)
|
||||
{
|
||||
/*
|
||||
* Ensure that this proc is not a member of any clog group that
|
||||
@@ -473,7 +474,7 @@ TransactionGroupUpdateXidStatus(TransactionId xid, XidStatus status,
|
||||
|
||||
if (pg_atomic_compare_exchange_u32(&procglobal->clogGroupFirst,
|
||||
&nextidx,
|
||||
(uint32) proc->pgprocno))
|
||||
(uint32) pgprocno))
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -284,7 +284,7 @@ TwoPhaseShmemInit(void)
|
||||
TwoPhaseState->freeGXacts = &gxacts[i];
|
||||
|
||||
/* associate it with a PGPROC assigned by InitProcGlobal */
|
||||
gxacts[i].pgprocno = PreparedXactProcs[i].pgprocno;
|
||||
gxacts[i].pgprocno = GetNumberFromPGProc(&PreparedXactProcs[i]);
|
||||
|
||||
/*
|
||||
* Assign a unique ID for each dummy proc, so that the range of
|
||||
@@ -461,7 +461,6 @@ MarkAsPreparingGuts(GlobalTransaction gxact, TransactionId xid, const char *gid,
|
||||
|
||||
/* Initialize the PGPROC entry */
|
||||
MemSet(proc, 0, sizeof(PGPROC));
|
||||
proc->pgprocno = gxact->pgprocno;
|
||||
dlist_node_init(&proc->links);
|
||||
proc->waitStatus = PROC_WAIT_STATUS_OK;
|
||||
if (LocalTransactionIdIsValid(MyProc->lxid))
|
||||
@@ -780,7 +779,7 @@ pg_prepared_xact(PG_FUNCTION_ARGS)
|
||||
while (status->array != NULL && status->currIdx < status->ngxacts)
|
||||
{
|
||||
GlobalTransaction gxact = &status->array[status->currIdx++];
|
||||
PGPROC *proc = &ProcGlobal->allProcs[gxact->pgprocno];
|
||||
PGPROC *proc = GetPGProcByNumber(gxact->pgprocno);
|
||||
Datum values[5] = {0};
|
||||
bool nulls[5] = {0};
|
||||
HeapTuple tuple;
|
||||
@@ -935,7 +934,7 @@ TwoPhaseGetDummyProc(TransactionId xid, bool lock_held)
|
||||
{
|
||||
GlobalTransaction gxact = TwoPhaseGetGXact(xid, lock_held);
|
||||
|
||||
return &ProcGlobal->allProcs[gxact->pgprocno];
|
||||
return GetPGProcByNumber(gxact->pgprocno);
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
@@ -1080,7 +1079,7 @@ save_state_data(const void *data, uint32 len)
|
||||
void
|
||||
StartPrepare(GlobalTransaction gxact)
|
||||
{
|
||||
PGPROC *proc = &ProcGlobal->allProcs[gxact->pgprocno];
|
||||
PGPROC *proc = GetPGProcByNumber(gxact->pgprocno);
|
||||
TransactionId xid = gxact->xid;
|
||||
TwoPhaseFileHeader hdr;
|
||||
TransactionId *children;
|
||||
@@ -1539,7 +1538,7 @@ FinishPreparedTransaction(const char *gid, bool isCommit)
|
||||
* try to commit the same GID at once.
|
||||
*/
|
||||
gxact = LockGXact(gid, GetUserId());
|
||||
proc = &ProcGlobal->allProcs[gxact->pgprocno];
|
||||
proc = GetPGProcByNumber(gxact->pgprocno);
|
||||
xid = gxact->xid;
|
||||
|
||||
/*
|
||||
|
||||
@@ -1379,7 +1379,7 @@ WALInsertLockAcquire(void)
|
||||
static int lockToTry = -1;
|
||||
|
||||
if (lockToTry == -1)
|
||||
lockToTry = MyProc->pgprocno % NUM_XLOGINSERT_LOCKS;
|
||||
lockToTry = MyProcNumber % NUM_XLOGINSERT_LOCKS;
|
||||
MyLockNo = lockToTry;
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user