pgprocno and lxid have been combined into a struct in PGPROC

Relevant PG commits:
28f3915b73f75bd1b50ba070f56b34241fe53fd1
28f3915b73

ab355e3a88de745607f6dd4c21f0119b5c68f2ad
ab355e3a88

024c521117579a6d356050ad3d78fdc95e44eefa
024c521117
pg17_kickoff
naisila 2024-07-10 17:58:16 +02:00
parent ec9beb543c
commit 140a443287
No known key found for this signature in database
GPG Key ID: A824BA9862D73E6D
3 changed files with 17 additions and 8 deletions

View File

@ -33,7 +33,7 @@
#include "storage/spin.h" #include "storage/spin.h"
#include "utils/timestamp.h" #include "utils/timestamp.h"
#include "pg_version_constants.h" #include "pg_version_compat.h"
#include "distributed/backend_data.h" #include "distributed/backend_data.h"
#include "distributed/connection_management.h" #include "distributed/connection_management.h"
@ -700,7 +700,7 @@ InitializeBackendData(const char *applicationName)
uint64 gpid = ExtractGlobalPID(applicationName); uint64 gpid = ExtractGlobalPID(applicationName);
MyBackendData = &backendManagementShmemData->backends[MyProc->pgprocno]; MyBackendData = &backendManagementShmemData->backends[getProcNo_compat(MyProc)];
Assert(MyBackendData); Assert(MyBackendData);
@ -1174,11 +1174,11 @@ CurrentDistributedTransactionNumber(void)
void void
GetBackendDataForProc(PGPROC *proc, BackendData *result) GetBackendDataForProc(PGPROC *proc, BackendData *result)
{ {
int pgprocno = proc->pgprocno; int pgprocno = getProcNo_compat(proc);
if (proc->lockGroupLeader != NULL) if (proc->lockGroupLeader != NULL)
{ {
pgprocno = proc->lockGroupLeader->pgprocno; pgprocno = getProcNo_compat(proc->lockGroupLeader);
} }
BackendData *backendData = &backendManagementShmemData->backends[pgprocno]; BackendData *backendData = &backendManagementShmemData->backends[pgprocno];
@ -1198,7 +1198,8 @@ GetBackendDataForProc(PGPROC *proc, BackendData *result)
void void
CancelTransactionDueToDeadlock(PGPROC *proc) CancelTransactionDueToDeadlock(PGPROC *proc)
{ {
BackendData *backendData = &backendManagementShmemData->backends[proc->pgprocno]; BackendData *backendData = &backendManagementShmemData->backends[getProcNo_compat(
proc)];
/* backend might not have used citus yet and thus not initialized backend data */ /* backend might not have used citus yet and thus not initialized backend data */
if (!backendData) if (!backendData)
@ -1330,7 +1331,7 @@ ActiveDistributedTransactionNumbers(void)
LocalTransactionId LocalTransactionId
GetMyProcLocalTransactionId(void) GetMyProcLocalTransactionId(void)
{ {
return MyProc->lxid; return getLxid_compat(MyProc);
} }

View File

@ -23,6 +23,8 @@
#include "utils/hsearch.h" #include "utils/hsearch.h"
#include "utils/timestamp.h" #include "utils/timestamp.h"
#include "pg_version_compat.h"
#include "distributed/backend_data.h" #include "distributed/backend_data.h"
#include "distributed/connection_management.h" #include "distributed/connection_management.h"
#include "distributed/hash_helpers.h" #include "distributed/hash_helpers.h"
@ -993,7 +995,7 @@ AllocWaitEdge(WaitGraph *waitGraph)
static void static void
AddProcToVisit(PROCStack *remaining, PGPROC *proc) AddProcToVisit(PROCStack *remaining, PGPROC *proc)
{ {
if (remaining->procAdded[proc->pgprocno]) if (remaining->procAdded[getProcNo_compat(proc)])
{ {
return; return;
} }
@ -1001,7 +1003,7 @@ AddProcToVisit(PROCStack *remaining, PGPROC *proc)
Assert(remaining->procCount < TotalProcCount()); Assert(remaining->procCount < TotalProcCount());
remaining->procs[remaining->procCount++] = proc; remaining->procs[remaining->procCount++] = proc;
remaining->procAdded[proc->pgprocno] = true; remaining->procAdded[getProcNo_compat(proc)] = true;
} }

View File

@ -108,6 +108,9 @@ getStxstattarget_compat(HeapTuple tup)
k) create_foreignscan_path(a, b, c, d, e, f, g, h, \ k) create_foreignscan_path(a, b, c, d, e, f, g, h, \
i, j, k) i, j, k)
#define getProcNo_compat(a) (a->vxid.procNumber)
#define getLxid_compat(a) (a->vxid.lxid)
#else #else
#include "access/htup_details.h" #include "access/htup_details.h"
@ -139,6 +142,9 @@ getStxstattarget_compat(HeapTuple tup)
k) create_foreignscan_path(a, b, c, d, e, f, g, h, \ k) create_foreignscan_path(a, b, c, d, e, f, g, h, \
i, k) i, k)
#define getProcNo_compat(a) (a->pgprocno)
#define getLxid_compat(a) (a->lxid)
#endif #endif
#if PG_VERSION_NUM >= PG_VERSION_16 #if PG_VERSION_NUM >= PG_VERSION_16