1 /*-------------------------------------------------------------------------
4 * POSTGRES public predicate locking definitions.
7 * Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
10 * src/include/storage/predicate.h
12 *-------------------------------------------------------------------------
17 #include "storage/lock.h"
18 #include "utils/relcache.h"
19 #include "utils/snapshot.h"
25 extern int max_predicate_locks_per_xact
;
26 extern int max_predicate_locks_per_relation
;
27 extern int max_predicate_locks_per_page
;
30 /* Number of SLRU buffers to use for Serial SLRU */
31 #define NUM_SERIAL_BUFFERS 16
34 * A handle used for sharing SERIALIZABLEXACT objects between the participants
35 * in a parallel query.
37 typedef void *SerializableXactHandle
;
43 /* housekeeping for shared memory predicate lock structures */
44 extern void InitPredicateLocks(void);
45 extern Size
PredicateLockShmemSize(void);
47 extern void CheckPointPredicate(void);
49 /* predicate lock reporting */
50 extern bool PageIsPredicateLocked(Relation relation
, BlockNumber blkno
);
52 /* predicate lock maintenance */
53 extern Snapshot
GetSerializableTransactionSnapshot(Snapshot snapshot
);
54 extern void SetSerializableTransactionSnapshot(Snapshot snapshot
,
55 VirtualTransactionId
*sourcevxid
,
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 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
);
64 extern void TransferPredicateLocksToHeapRelation(Relation relation
);
65 extern void ReleasePredicateLocks(bool isCommit
, bool isReadOnlySafe
);
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
);
73 /* final rollback checking */
74 extern void PreCommit_CheckForSerializationFailure(void);
76 /* two-phase commit support */
77 extern void AtPrepare_PredicateLocks(void);
78 extern void PostPrepare_PredicateLocks(TransactionId xid
);
79 extern void PredicateLockTwoPhaseFinish(TransactionId xid
, bool isCommit
);
80 extern void predicatelock_twophase_recover(TransactionId xid
, uint16 info
,
81 void *recdata
, uint32 len
);
83 /* parallel query support */
84 extern SerializableXactHandle
ShareSerializableXact(void);
85 extern void AttachSerializableXact(SerializableXactHandle handle
);
87 #endif /* PREDICATE_H */