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-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  */
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 */
54 extern void SetSerializableTransactionSnapshot(Snapshot snapshot,
55  VirtualTransactionId *sourcevxid,
56  int sourcepid);
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);
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 */
74 
75 /* two-phase commit support */
76 extern void AtPrepare_PredicateLocks(void);
78 extern void PredicateLockTwoPhaseFinish(TransactionId xid, bool isCommit);
80  void *recdata, uint32 len);
81 
82 /* parallel query support */
85 
86 #endif /* PREDICATE_H */
bool PageIsPredicateLocked(Relation relation, BlockNumber blkno)
Definition: predicate.c:1924
void CheckForSerializableConflictIn(Relation relation, HeapTuple tuple, Buffer buffer)
Definition: predicate.c:4426
uint32 TransactionId
Definition: c.h:508
void CheckForSerializableConflictOut(bool valid, Relation relation, HeapTuple tuple, Buffer buffer, Snapshot snapshot)
Definition: predicate.c:4041
void RegisterPredicateLockingXid(TransactionId xid)
Definition: predicate.c:1875
uint32 BlockNumber
Definition: block.h:31
void PredicateLockPage(Relation relation, BlockNumber blkno, Snapshot snapshot)
Definition: predicate.c:2526
void CheckPointPredicate(void)
Definition: predicate.c:1018
Snapshot GetSerializableTransactionSnapshot(Snapshot snapshot)
Definition: predicate.c:1613
void CheckTableForSerializableConflictIn(Relation relation)
Definition: predicate.c:4510
void AttachSerializableXact(SerializableXactHandle handle)
Definition: predicate.c:5176
unsigned short uint16
Definition: c.h:358
void PredicateLockTuple(Relation relation, HeapTuple tuple, Snapshot snapshot)
Definition: predicate.c:2548
Size PredicateLockShmemSize(void)
Definition: predicate.c:1288
unsigned int uint32
Definition: c.h:359
SerializableXactHandle ShareSerializableXact(void)
Definition: predicate.c:5167
int max_predicate_locks_per_xact
Definition: predicate.c:369
void PredicateLockPageSplit(Relation relation, BlockNumber oldblkno, BlockNumber newblkno)
Definition: predicate.c:3102
int max_predicate_locks_per_relation
Definition: predicate.c:370
void PostPrepare_PredicateLocks(TransactionId xid)
Definition: predicate.c:4982
int max_predicate_locks_per_page
Definition: predicate.c:371
void PredicateLockPageCombine(Relation relation, BlockNumber oldblkno, BlockNumber newblkno)
Definition: predicate.c:3187
void SetSerializableTransactionSnapshot(Snapshot snapshot, VirtualTransactionId *sourcevxid, int sourcepid)
Definition: predicate.c:1653
void ReleasePredicateLocks(bool isCommit, bool isReadOnlySafe)
Definition: predicate.c:3267
void * SerializableXactHandle
Definition: predicate.h:37
void InitPredicateLocks(void)
Definition: predicate.c:1083
void PredicateLockTwoPhaseFinish(TransactionId xid, bool isCommit)
Definition: predicate.c:5004
void PreCommit_CheckForSerializationFailure(void)
Definition: predicate.c:4812
size_t Size
Definition: c.h:467
void TransferPredicateLocksToHeapRelation(Relation relation)
Definition: predicate.c:3081
void predicatelock_twophase_recover(TransactionId xid, uint16 info, void *recdata, uint32 len)
Definition: predicate.c:5031
void PredicateLockRelation(Relation relation, Snapshot snapshot)
Definition: predicate.c:2503
int Buffer
Definition: buf.h:23
void AtPrepare_PredicateLocks(void)
Definition: predicate.c:4906