1 | /*------------------------------------------------------------------------- |
2 | * |
3 | * predicate.h |
4 | * POSTGRES public predicate locking definitions. |
5 | * |
6 | * |
7 | * Portions Copyright (c) 1996-2019, 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/lock.h" |
18 | #include "utils/relcache.h" |
19 | #include "utils/snapshot.h" |
20 | |
21 | |
22 | /* |
23 | * GUC variables |
24 | */ |
25 | extern int max_predicate_locks_per_xact; |
26 | extern int max_predicate_locks_per_relation; |
27 | extern int max_predicate_locks_per_page; |
28 | |
29 | |
30 | /* Number of SLRU buffers to use for predicate locking */ |
31 | #define NUM_OLDSERXID_BUFFERS 16 |
32 | |
33 | /* |
34 | * A handle used for sharing SERIALIZABLEXACT objects between the participants |
35 | * in a parallel query. |
36 | */ |
37 | typedef void *SerializableXactHandle; |
38 | |
39 | /* |
40 | * function prototypes |
41 | */ |
42 | |
43 | /* housekeeping for shared memory predicate lock structures */ |
44 | extern void InitPredicateLocks(void); |
45 | extern Size PredicateLockShmemSize(void); |
46 | |
47 | extern void CheckPointPredicate(void); |
48 | |
49 | /* predicate lock reporting */ |
50 | extern bool PageIsPredicateLocked(Relation relation, BlockNumber blkno); |
51 | |
52 | /* predicate lock maintenance */ |
53 | extern Snapshot GetSerializableTransactionSnapshot(Snapshot snapshot); |
54 | extern void SetSerializableTransactionSnapshot(Snapshot snapshot, |
55 | VirtualTransactionId *sourcevxid, |
56 | int sourcepid); |
57 | extern void RegisterPredicateLockingXid(TransactionId xid); |
58 | extern void PredicateLockRelation(Relation relation, Snapshot snapshot); |
59 | extern void PredicateLockPage(Relation relation, BlockNumber blkno, Snapshot snapshot); |
60 | extern void PredicateLockTuple(Relation relation, HeapTuple tuple, Snapshot snapshot); |
61 | extern void PredicateLockPageSplit(Relation relation, BlockNumber oldblkno, BlockNumber newblkno); |
62 | extern void PredicateLockPageCombine(Relation relation, BlockNumber oldblkno, BlockNumber newblkno); |
63 | extern void TransferPredicateLocksToHeapRelation(Relation relation); |
64 | extern void ReleasePredicateLocks(bool isCommit, bool isReadOnlySafe); |
65 | |
66 | /* conflict detection (may also trigger rollback) */ |
67 | extern void CheckForSerializableConflictOut(bool valid, Relation relation, HeapTuple tuple, |
68 | Buffer buffer, Snapshot snapshot); |
69 | extern void CheckForSerializableConflictIn(Relation relation, HeapTuple tuple, Buffer buffer); |
70 | extern void CheckTableForSerializableConflictIn(Relation relation); |
71 | |
72 | /* final rollback checking */ |
73 | extern void PreCommit_CheckForSerializationFailure(void); |
74 | |
75 | /* two-phase commit support */ |
76 | extern void AtPrepare_PredicateLocks(void); |
77 | extern void PostPrepare_PredicateLocks(TransactionId xid); |
78 | extern void PredicateLockTwoPhaseFinish(TransactionId xid, bool isCommit); |
79 | extern void predicatelock_twophase_recover(TransactionId xid, uint16 info, |
80 | void *recdata, uint32 len); |
81 | |
82 | /* parallel query support */ |
83 | extern SerializableXactHandle ShareSerializableXact(void); |
84 | extern void AttachSerializableXact(SerializableXactHandle handle); |
85 | |
86 | #endif /* PREDICATE_H */ |
87 | |