Unmark gen_random_uuid() function leakproof.
[pgsql.git] / src / include / storage / lmgr.h
blobce15125ac3bc0d0acd77ccce4a7fee5fadd3226d
1 /*-------------------------------------------------------------------------
3 * lmgr.h
4 * POSTGRES lock manager 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/lmgr.h
12 *-------------------------------------------------------------------------
14 #ifndef LMGR_H
15 #define LMGR_H
17 #include "lib/stringinfo.h"
18 #include "storage/itemptr.h"
19 #include "storage/lock.h"
20 #include "utils/rel.h"
23 /* XactLockTableWait operations */
24 typedef enum XLTW_Oper
26 XLTW_None,
27 XLTW_Update,
28 XLTW_Delete,
29 XLTW_Lock,
30 XLTW_LockUpdated,
31 XLTW_InsertIndex,
32 XLTW_InsertIndexUnique,
33 XLTW_FetchUpdated,
34 XLTW_RecheckExclusionConstr,
35 } XLTW_Oper;
37 extern void RelationInitLockInfo(Relation relation);
39 /* Lock a relation */
40 extern void LockRelationOid(Oid relid, LOCKMODE lockmode);
41 extern void LockRelationId(LockRelId *relid, LOCKMODE lockmode);
42 extern bool ConditionalLockRelationOid(Oid relid, LOCKMODE lockmode);
43 extern void UnlockRelationId(LockRelId *relid, LOCKMODE lockmode);
44 extern void UnlockRelationOid(Oid relid, LOCKMODE lockmode);
46 extern void LockRelation(Relation relation, LOCKMODE lockmode);
47 extern bool ConditionalLockRelation(Relation relation, LOCKMODE lockmode);
48 extern void UnlockRelation(Relation relation, LOCKMODE lockmode);
49 extern bool CheckRelationLockedByMe(Relation relation, LOCKMODE lockmode,
50 bool orstronger);
51 extern bool CheckRelationOidLockedByMe(Oid relid, LOCKMODE lockmode,
52 bool orstronger);
53 extern bool LockHasWaitersRelation(Relation relation, LOCKMODE lockmode);
55 extern void LockRelationIdForSession(LockRelId *relid, LOCKMODE lockmode);
56 extern void UnlockRelationIdForSession(LockRelId *relid, LOCKMODE lockmode);
58 /* Lock a relation for extension */
59 extern void LockRelationForExtension(Relation relation, LOCKMODE lockmode);
60 extern void UnlockRelationForExtension(Relation relation, LOCKMODE lockmode);
61 extern bool ConditionalLockRelationForExtension(Relation relation,
62 LOCKMODE lockmode);
63 extern int RelationExtensionLockWaiterCount(Relation relation);
65 /* Lock to recompute pg_database.datfrozenxid in the current database */
66 extern void LockDatabaseFrozenIds(LOCKMODE lockmode);
68 /* Lock a page (currently only used within indexes) */
69 extern void LockPage(Relation relation, BlockNumber blkno, LOCKMODE lockmode);
70 extern bool ConditionalLockPage(Relation relation, BlockNumber blkno, LOCKMODE lockmode);
71 extern void UnlockPage(Relation relation, BlockNumber blkno, LOCKMODE lockmode);
73 /* Lock a tuple (see heap_lock_tuple before assuming you understand this) */
74 extern void LockTuple(Relation relation, ItemPointer tid, LOCKMODE lockmode);
75 extern bool ConditionalLockTuple(Relation relation, ItemPointer tid,
76 LOCKMODE lockmode);
77 extern void UnlockTuple(Relation relation, ItemPointer tid, LOCKMODE lockmode);
79 /* Lock an XID (used to wait for a transaction to finish) */
80 extern void XactLockTableInsert(TransactionId xid);
81 extern void XactLockTableDelete(TransactionId xid);
82 extern void XactLockTableWait(TransactionId xid, Relation rel,
83 ItemPointer ctid, XLTW_Oper oper);
84 extern bool ConditionalXactLockTableWait(TransactionId xid);
86 /* Lock VXIDs, specified by conflicting locktags */
87 extern void WaitForLockers(LOCKTAG heaplocktag, LOCKMODE lockmode, bool progress);
88 extern void WaitForLockersMultiple(List *locktags, LOCKMODE lockmode, bool progress);
90 /* Lock an XID for tuple insertion (used to wait for an insertion to finish) */
91 extern uint32 SpeculativeInsertionLockAcquire(TransactionId xid);
92 extern void SpeculativeInsertionLockRelease(TransactionId xid);
93 extern void SpeculativeInsertionWait(TransactionId xid, uint32 token);
95 /* Lock a general object (other than a relation) of the current database */
96 extern void LockDatabaseObject(Oid classid, Oid objid, uint16 objsubid,
97 LOCKMODE lockmode);
98 extern bool ConditionalLockDatabaseObject(Oid classid, Oid objid,
99 uint16 objsubid, LOCKMODE lockmode);
100 extern void UnlockDatabaseObject(Oid classid, Oid objid, uint16 objsubid,
101 LOCKMODE lockmode);
103 /* Lock a shared-across-databases object (other than a relation) */
104 extern void LockSharedObject(Oid classid, Oid objid, uint16 objsubid,
105 LOCKMODE lockmode);
106 extern bool ConditionalLockSharedObject(Oid classid, Oid objid, uint16 objsubid,
107 LOCKMODE lockmode);
108 extern void UnlockSharedObject(Oid classid, Oid objid, uint16 objsubid,
109 LOCKMODE lockmode);
111 extern void LockSharedObjectForSession(Oid classid, Oid objid, uint16 objsubid,
112 LOCKMODE lockmode);
113 extern void UnlockSharedObjectForSession(Oid classid, Oid objid, uint16 objsubid,
114 LOCKMODE lockmode);
116 extern void LockApplyTransactionForSession(Oid suboid, TransactionId xid, uint16 objid,
117 LOCKMODE lockmode);
118 extern void UnlockApplyTransactionForSession(Oid suboid, TransactionId xid, uint16 objid,
119 LOCKMODE lockmode);
121 /* Describe a locktag for error messages */
122 extern void DescribeLockTag(StringInfo buf, const LOCKTAG *tag);
124 extern const char *GetLockNameFromTagType(uint16 locktag_type);
126 #endif /* LMGR_H */