PostgreSQL Source Code  git master
predicate.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * predicate.h
4  * POSTGRES public predicate locking definitions.
5  *
6  *
7  * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * src/include/storage/predicate.h
11  *
12  *-------------------------------------------------------------------------
13  */
14 #ifndef PREDICATE_H
15 #define PREDICATE_H
16 
17 #include "storage/itemptr.h"
18 #include "storage/lock.h"
19 #include "utils/relcache.h"
20 #include "utils/snapshot.h"
21 
22 
23 /*
24  * GUC variables
25  */
29 
30 /*
31  * A handle used for sharing SERIALIZABLEXACT objects between the participants
32  * in a parallel query.
33  */
34 typedef void *SerializableXactHandle;
35 
36 /*
37  * function prototypes
38  */
39 
40 /* housekeeping for shared memory predicate lock structures */
41 extern void PredicateLockShmemInit(void);
42 extern Size PredicateLockShmemSize(void);
43 
44 extern void CheckPointPredicate(void);
45 
46 /* predicate lock reporting */
47 extern bool PageIsPredicateLocked(Relation relation, BlockNumber blkno);
48 
49 /* predicate lock maintenance */
51 extern void SetSerializableTransactionSnapshot(Snapshot snapshot,
52  VirtualTransactionId *sourcevxid,
53  int sourcepid);
55 extern void PredicateLockRelation(Relation relation, Snapshot snapshot);
56 extern void PredicateLockPage(Relation relation, BlockNumber blkno, Snapshot snapshot);
57 extern void PredicateLockTID(Relation relation, ItemPointer tid, Snapshot snapshot,
58  TransactionId tuple_xid);
59 extern void PredicateLockPageSplit(Relation relation, BlockNumber oldblkno, BlockNumber newblkno);
60 extern void PredicateLockPageCombine(Relation relation, BlockNumber oldblkno, BlockNumber newblkno);
62 extern void ReleasePredicateLocks(bool isCommit, bool isReadOnlySafe);
63 
64 /* conflict detection (may also trigger rollback) */
65 extern bool CheckForSerializableConflictOutNeeded(Relation relation, Snapshot snapshot);
66 extern void CheckForSerializableConflictOut(Relation relation, TransactionId xid, Snapshot snapshot);
67 extern void CheckForSerializableConflictIn(Relation relation, ItemPointer tid, BlockNumber blkno);
68 extern void CheckTableForSerializableConflictIn(Relation relation);
69 
70 /* final rollback checking */
72 
73 /* two-phase commit support */
74 extern void AtPrepare_PredicateLocks(void);
76 extern void PredicateLockTwoPhaseFinish(TransactionId xid, bool isCommit);
78  void *recdata, uint32 len);
79 
80 /* parallel query support */
83 
84 #endif /* PREDICATE_H */
uint32 BlockNumber
Definition: block.h:31
#define PGDLLIMPORT
Definition: c.h:1274
uint16_t uint16
Definition: c.h:484
uint32_t uint32
Definition: c.h:485
uint32 TransactionId
Definition: c.h:606
size_t Size
Definition: c.h:559
const void size_t len
PGDLLIMPORT int max_predicate_locks_per_page
Definition: predicate.c:373
void CheckPointPredicate(void)
Definition: predicate.c:1041
void PredicateLockPageSplit(Relation relation, BlockNumber oldblkno, BlockNumber newblkno)
Definition: predicate.c:3134
void PredicateLockTwoPhaseFinish(TransactionId xid, bool isCommit)
Definition: predicate.c:4872
void SetSerializableTransactionSnapshot(Snapshot snapshot, VirtualTransactionId *sourcevxid, int sourcepid)
Definition: predicate.c:1712
void PredicateLockPage(Relation relation, BlockNumber blkno, Snapshot snapshot)
Definition: predicate.c:2589
void CheckForSerializableConflictOut(Relation relation, TransactionId xid, Snapshot snapshot)
Definition: predicate.c:4013
bool PageIsPredicateLocked(Relation relation, BlockNumber blkno)
Definition: predicate.c:1998
void * SerializableXactHandle
Definition: predicate.h:34
void CheckForSerializableConflictIn(Relation relation, ItemPointer tid, BlockNumber blkno)
Definition: predicate.c:4326
void CheckTableForSerializableConflictIn(Relation relation)
Definition: predicate.c:4409
void PredicateLockTID(Relation relation, ItemPointer tid, Snapshot snapshot, TransactionId tuple_xid)
Definition: predicate.c:2611
void AttachSerializableXact(SerializableXactHandle handle)
Definition: predicate.c:5045
SerializableXactHandle ShareSerializableXact(void)
Definition: predicate.c:5036
void PredicateLockPageCombine(Relation relation, BlockNumber oldblkno, BlockNumber newblkno)
Definition: predicate.c:3219
void PreCommit_CheckForSerializationFailure(void)
Definition: predicate.c:4693
void ReleasePredicateLocks(bool isCommit, bool isReadOnlySafe)
Definition: predicate.c:3302
void PredicateLockRelation(Relation relation, Snapshot snapshot)
Definition: predicate.c:2566
void PredicateLockShmemInit(void)
Definition: predicate.c:1145
void predicatelock_twophase_recover(TransactionId xid, uint16 info, void *recdata, uint32 len)
Definition: predicate.c:4899
Size PredicateLockShmemSize(void)
Definition: predicate.c:1347
PGDLLIMPORT int max_predicate_locks_per_relation
Definition: predicate.c:372
PGDLLIMPORT int max_predicate_locks_per_xact
Definition: predicate.c:371
void AtPrepare_PredicateLocks(void)
Definition: predicate.c:4780
void RegisterPredicateLockingXid(TransactionId xid)
Definition: predicate.c:1949
bool CheckForSerializableConflictOutNeeded(Relation relation, Snapshot snapshot)
Definition: predicate.c:3981
void TransferPredicateLocksToHeapRelation(Relation relation)
Definition: predicate.c:3113
void PostPrepare_PredicateLocks(TransactionId xid)
Definition: predicate.c:4849
Snapshot GetSerializableTransactionSnapshot(Snapshot snapshot)
Definition: predicate.c:1672