1 /*-------------------------------------------------------------------------
4 * POSTGRES process array definitions.
7 * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
10 * src/include/storage/procarray.h
12 *-------------------------------------------------------------------------
17 #include "storage/lock.h"
18 #include "storage/standby.h"
19 #include "utils/relcache.h"
20 #include "utils/snapshot.h"
23 extern Size
ProcArrayShmemSize(void);
24 extern void ProcArrayShmemInit(void);
25 extern void ProcArrayAdd(PGPROC
*proc
);
26 extern void ProcArrayRemove(PGPROC
*proc
, TransactionId latestXid
);
28 extern void ProcArrayEndTransaction(PGPROC
*proc
, TransactionId latestXid
);
29 extern void ProcArrayClearTransaction(PGPROC
*proc
);
31 extern void ProcArrayInitRecovery(TransactionId initializedUptoXID
);
32 extern void ProcArrayApplyRecoveryInfo(RunningTransactions running
);
33 extern void ProcArrayApplyXidAssignment(TransactionId topxid
,
34 int nsubxids
, TransactionId
*subxids
);
36 extern void RecordKnownAssignedTransactionIds(TransactionId xid
);
37 extern void ExpireTreeKnownAssignedTransactionIds(TransactionId xid
,
38 int nsubxids
, TransactionId
*subxids
,
39 TransactionId max_xid
);
40 extern void ExpireAllKnownAssignedTransactionIds(void);
41 extern void ExpireOldKnownAssignedTransactionIds(TransactionId xid
);
42 extern void KnownAssignedTransactionIdsIdleMaintenance(void);
44 extern int GetMaxSnapshotXidCount(void);
45 extern int GetMaxSnapshotSubxidCount(void);
47 extern Snapshot
GetSnapshotData(Snapshot snapshot
);
49 extern bool ProcArrayInstallImportedXmin(TransactionId xmin
,
50 VirtualTransactionId
*sourcevxid
);
51 extern bool ProcArrayInstallRestoredXmin(TransactionId xmin
, PGPROC
*proc
);
53 extern RunningTransactions
GetRunningTransactionData(void);
55 extern bool TransactionIdIsInProgress(TransactionId xid
);
56 extern bool TransactionIdIsActive(TransactionId xid
);
57 extern TransactionId
GetOldestNonRemovableTransactionId(Relation rel
);
58 extern TransactionId
GetOldestTransactionIdConsideredRunning(void);
59 extern TransactionId
GetOldestActiveTransactionId(void);
60 extern TransactionId
GetOldestSafeDecodingTransactionId(bool catalogOnly
);
61 extern void GetReplicationHorizons(TransactionId
*xmin
, TransactionId
*catalog_xmin
);
63 extern VirtualTransactionId
*GetVirtualXIDsDelayingChkpt(int *nvxids
, int type
);
64 extern bool HaveVirtualXIDsDelayingChkpt(VirtualTransactionId
*vxids
,
65 int nvxids
, int type
);
67 extern PGPROC
*ProcNumberGetProc(int procNumber
);
68 extern void ProcNumberGetTransactionIds(int procNumber
, TransactionId
*xid
,
69 TransactionId
*xmin
, int *nsubxid
,
71 extern PGPROC
*BackendPidGetProc(int pid
);
72 extern PGPROC
*BackendPidGetProcWithLock(int pid
);
73 extern int BackendXidGetPid(TransactionId xid
);
74 extern bool IsBackendPid(int pid
);
76 extern VirtualTransactionId
*GetCurrentVirtualXIDs(TransactionId limitXmin
,
77 bool excludeXmin0
, bool allDbs
, int excludeVacuum
,
79 extern VirtualTransactionId
*GetConflictingVirtualXIDs(TransactionId limitXmin
, Oid dbOid
);
80 extern pid_t
CancelVirtualTransaction(VirtualTransactionId vxid
, ProcSignalReason sigmode
);
81 extern pid_t
SignalVirtualTransaction(VirtualTransactionId vxid
, ProcSignalReason sigmode
,
82 bool conflictPending
);
84 extern bool MinimumActiveBackends(int min
);
85 extern int CountDBBackends(Oid databaseid
);
86 extern int CountDBConnections(Oid databaseid
);
87 extern void CancelDBBackends(Oid databaseid
, ProcSignalReason sigmode
, bool conflictPending
);
88 extern int CountUserBackends(Oid roleid
);
89 extern bool CountOtherDBBackends(Oid databaseId
,
90 int *nbackends
, int *nprepared
);
91 extern void TerminateOtherDBBackends(Oid databaseId
);
93 extern void XidCacheRemoveRunningXids(TransactionId xid
,
94 int nxids
, const TransactionId
*xids
,
95 TransactionId latestXid
);
97 extern void ProcArraySetReplicationSlotXmin(TransactionId xmin
,
98 TransactionId catalog_xmin
, bool already_locked
);
100 extern void ProcArrayGetReplicationSlotXmin(TransactionId
*xmin
,
101 TransactionId
*catalog_xmin
);
103 #endif /* PROCARRAY_H */