Skip to content

Commit

Permalink
Use macro wrapper to access PGPROC data, which allow to improve compa… (
Browse files Browse the repository at this point in the history
#7607)

DESCRIPTION: Use macro wrapper to access PGPROC data, to improve compatibility with PostgreSQL forks.
  • Loading branch information
EvgenyNechayev authored and naisila committed Jan 12, 2025
1 parent ef946e4 commit 5eb037a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/backend/distributed/transaction/backend_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ StoreAllActiveTransactions(Tuplestorestate *tupleStore, TupleDesc tupleDescripto
bool showCurrentBackendDetails = showAllBackends;
BackendData *currentBackend =
&backendManagementShmemData->backends[backendIndex];
PGPROC *currentProc = &ProcGlobal->allProcs[backendIndex];
PGPROC *currentProc = GetPGProcByNumber(backendIndex);

/* to work on data after releasing g spinlock to protect against errors */
uint64 transactionNumber = 0;
Expand All @@ -420,7 +420,7 @@ StoreAllActiveTransactions(Tuplestorestate *tupleStore, TupleDesc tupleDescripto
}

Oid databaseId = currentBackend->databaseId;
int backendPid = ProcGlobal->allProcs[backendIndex].pid;
int backendPid = GetPGProcByNumber(backendIndex)->pid;

/*
* We prefer to use worker_query instead of distributedCommandOriginator in
Expand Down Expand Up @@ -1280,7 +1280,7 @@ ActiveDistributedTransactionNumbers(void)
/* build list of starting procs */
for (int curBackend = 0; curBackend < MaxBackends; curBackend++)
{
PGPROC *currentProc = &ProcGlobal->allProcs[curBackend];
PGPROC *currentProc = GetPGProcByNumber(curBackend);
BackendData currentBackendData;

if (currentProc->pid == 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ AssociateDistributedTransactionWithBackendProc(TransactionNode *transactionNode)

for (int backendIndex = 0; backendIndex < MaxBackends; ++backendIndex)
{
PGPROC *currentProc = &ProcGlobal->allProcs[backendIndex];
PGPROC *currentProc = GetPGProcByNumber(backendIndex);
BackendData currentBackendData;

/* we're not interested in processes that are not active or waiting on a lock */
Expand Down
2 changes: 1 addition & 1 deletion src/backend/distributed/transaction/lock_graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ BuildLocalWaitGraph(bool onlyDistributedTx)
/* build list of starting procs */
for (int curBackend = 0; curBackend < totalProcs; curBackend++)
{
PGPROC *currentProc = &ProcGlobal->allProcs[curBackend];
PGPROC *currentProc = GetPGProcByNumber(curBackend);
BackendData currentBackendData;

if (currentProc->pid == 0)
Expand Down

0 comments on commit 5eb037a

Please sign in to comment.