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-2020, 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 Serial SLRU */
31 #define NUM_SERIAL_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 PredicateLockTID(Relation relation, ItemPointer tid, Snapshot snapshot,
61  TransactionId insert_xid);
62 extern void PredicateLockPageSplit(Relation relation, BlockNumber oldblkno, BlockNumber newblkno);
63 extern void PredicateLockPageCombine(Relation relation, BlockNumber oldblkno, BlockNumber newblkno);
65 extern void ReleasePredicateLocks(bool isCommit, bool isReadOnlySafe);
66 
67 /* conflict detection (may also trigger rollback) */
68 extern bool CheckForSerializableConflictOutNeeded(Relation relation, Snapshot snapshot);
69 extern void CheckForSerializableConflictOut(Relation relation, TransactionId xid, Snapshot snapshot);
70 extern void CheckForSerializableConflictIn(Relation relation, ItemPointer tid, BlockNumber blkno);
71 extern void CheckTableForSerializableConflictIn(Relation relation);
72 
73 /* final rollback checking */
75 
76 /* two-phase commit support */
77 extern void AtPrepare_PredicateLocks(void);
79 extern void PredicateLockTwoPhaseFinish(TransactionId xid, bool isCommit);
81  void *recdata, uint32 len);
82 
83 /* parallel query support */
86 
87 #endif /* PREDICATE_H */
bool PageIsPredicateLocked(Relation relation, BlockNumber blkno)
Definition: predicate.c:1921
void CheckForSerializableConflictIn(Relation relation, ItemPointer tid, BlockNumber blkno)
Definition: predicate.c:4377
uint32 TransactionId
Definition: c.h:520
void RegisterPredicateLockingXid(TransactionId xid)
Definition: predicate.c:1872
uint32 BlockNumber
Definition: block.h:31
void PredicateLockPage(Relation relation, BlockNumber blkno, Snapshot snapshot)
Definition: predicate.c:2523
void CheckPointPredicate(void)
Definition: predicate.c:1015
Snapshot GetSerializableTransactionSnapshot(Snapshot snapshot)
Definition: predicate.c:1610
void CheckTableForSerializableConflictIn(Relation relation)
Definition: predicate.c:4460
void AttachSerializableXact(SerializableXactHandle handle)
Definition: predicate.c:5126
unsigned short uint16
Definition: c.h:373
Size PredicateLockShmemSize(void)
Definition: predicate.c:1285
unsigned int uint32
Definition: c.h:374
void PredicateLockTID(Relation relation, ItemPointer tid, Snapshot snapshot, TransactionId insert_xid)
Definition: predicate.c:2545
SerializableXactHandle ShareSerializableXact(void)
Definition: predicate.c:5117
int max_predicate_locks_per_xact
Definition: predicate.c:366
void PredicateLockPageSplit(Relation relation, BlockNumber oldblkno, BlockNumber newblkno)
Definition: predicate.c:3098
int max_predicate_locks_per_relation
Definition: predicate.c:367
void PostPrepare_PredicateLocks(TransactionId xid)
Definition: predicate.c:4932
int max_predicate_locks_per_page
Definition: predicate.c:368
void PredicateLockPageCombine(Relation relation, BlockNumber oldblkno, BlockNumber newblkno)
Definition: predicate.c:3183
void SetSerializableTransactionSnapshot(Snapshot snapshot, VirtualTransactionId *sourcevxid, int sourcepid)
Definition: predicate.c:1650
void ReleasePredicateLocks(bool isCommit, bool isReadOnlySafe)
Definition: predicate.c:3263
void * SerializableXactHandle
Definition: predicate.h:37
void InitPredicateLocks(void)
Definition: predicate.c:1080
void PredicateLockTwoPhaseFinish(TransactionId xid, bool isCommit)
Definition: predicate.c:4954
bool CheckForSerializableConflictOutNeeded(Relation relation, Snapshot snapshot)
Definition: predicate.c:4020
void PreCommit_CheckForSerializationFailure(void)
Definition: predicate.c:4762
size_t Size
Definition: c.h:473
void TransferPredicateLocksToHeapRelation(Relation relation)
Definition: predicate.c:3077
void CheckForSerializableConflictOut(Relation relation, TransactionId xid, Snapshot snapshot)
Definition: predicate.c:4052
void predicatelock_twophase_recover(TransactionId xid, uint16 info, void *recdata, uint32 len)
Definition: predicate.c:4981
void PredicateLockRelation(Relation relation, Snapshot snapshot)
Definition: predicate.c:2500
void AtPrepare_PredicateLocks(void)
Definition: predicate.c:4856