1 /*-------------------------------------------------------------------------
4 * POSTGRES process array definitions.
7 * Portions Copyright (c) 1996-2021, 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 CreateSharedProcArray(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
);
43 extern int GetMaxSnapshotXidCount(void);
44 extern int GetMaxSnapshotSubxidCount(void);
46 extern Snapshot
GetSnapshotData(Snapshot snapshot
);
48 extern bool ProcArrayInstallImportedXmin(TransactionId xmin
,
49 VirtualTransactionId
*sourcevxid
);
50 extern bool ProcArrayInstallRestoredXmin(TransactionId xmin
, PGPROC
*proc
);
52 extern RunningTransactions
GetRunningTransactionData(void);
54 extern bool TransactionIdIsInProgress(TransactionId xid
);
55 extern bool TransactionIdIsActive(TransactionId xid
);
56 extern TransactionId
GetOldestNonRemovableTransactionId(Relation rel
);
57 extern TransactionId
GetOldestTransactionIdConsideredRunning(void);
58 extern TransactionId
GetOldestActiveTransactionId(void);
59 extern TransactionId
GetOldestSafeDecodingTransactionId(bool catalogOnly
);
60 extern void GetReplicationHorizons(TransactionId
*slot_xmin
, TransactionId
*catalog_xmin
);
62 extern VirtualTransactionId
*GetVirtualXIDsDelayingChkpt(int *nvxids
);
63 extern bool HaveVirtualXIDsDelayingChkpt(VirtualTransactionId
*vxids
, int nvxids
);
65 extern PGPROC
*BackendPidGetProc(int pid
);
66 extern PGPROC
*BackendPidGetProcWithLock(int pid
);
67 extern int BackendXidGetPid(TransactionId xid
);
68 extern bool IsBackendPid(int pid
);
70 extern VirtualTransactionId
*GetCurrentVirtualXIDs(TransactionId limitXmin
,
71 bool excludeXmin0
, bool allDbs
, int excludeVacuum
,
73 extern VirtualTransactionId
*GetConflictingVirtualXIDs(TransactionId limitXmin
, Oid dbOid
);
74 extern pid_t
CancelVirtualTransaction(VirtualTransactionId vxid
, ProcSignalReason sigmode
);
75 extern pid_t
SignalVirtualTransaction(VirtualTransactionId vxid
, ProcSignalReason sigmode
,
76 bool conflictPending
);
78 extern bool MinimumActiveBackends(int min
);
79 extern int CountDBBackends(Oid databaseid
);
80 extern int CountDBConnections(Oid databaseid
);
81 extern void CancelDBBackends(Oid databaseid
, ProcSignalReason sigmode
, bool conflictPending
);
82 extern int CountUserBackends(Oid roleid
);
83 extern bool CountOtherDBBackends(Oid databaseId
,
84 int *nbackends
, int *nprepared
);
85 extern void TerminateOtherDBBackends(Oid databaseId
);
87 extern void XidCacheRemoveRunningXids(TransactionId xid
,
88 int nxids
, const TransactionId
*xids
,
89 TransactionId latestXid
);
91 extern void ProcArraySetReplicationSlotXmin(TransactionId xmin
,
92 TransactionId catalog_xmin
, bool already_locked
);
94 extern void ProcArrayGetReplicationSlotXmin(TransactionId
*xmin
,
95 TransactionId
*catalog_xmin
);
97 #endif /* PROCARRAY_H */