1 /*-------------------------------------------------------------------------
4 * POSTGRES "time" qualification definitions.
6 * Should be moved/renamed... - vadim 07/28/98
8 * Copyright (c) 1994, Regents of the University of California
10 * $Id: tqual.h,v 1.21 1999/05/25 16:14:58 momjian Exp $
12 *-------------------------------------------------------------------------
17 #include <access/htup.h>
19 typedef struct SnapshotData
21 TransactionId xmin; /* XID < xmin are visible to me */
22 TransactionId xmax; /* XID >= xmax are invisible to me */
23 uint32 xcnt; /* # of xact below */
24 TransactionId *xip; /* array of xacts in progress */
25 ItemPointerData tid; /* required for Dirty snapshot -:( */
28 typedef SnapshotData *Snapshot;
30 #define SnapshotNow ((Snapshot) 0x0)
31 #define SnapshotSelf ((Snapshot) 0x1)
33 extern Snapshot SnapshotDirty;
34 extern Snapshot QuerySnapshot;
35 extern Snapshot SerializableSnapshot;
37 #define IsSnapshotNow(snapshot) ((Snapshot) snapshot == SnapshotNow)
38 #define IsSnapshotSelf(snapshot) ((Snapshot) snapshot == SnapshotSelf)
39 #define IsSnapshotDirty(snapshot) ((Snapshot) snapshot == SnapshotDirty)
41 extern TransactionId HeapSpecialTransactionId;
42 extern CommandId HeapSpecialCommandId;
45 * HeapTupleSatisfiesVisibility
46 * True iff heap tuple satsifies a time qual.
49 * Assumes heap tuple is valid.
51 #define HeapTupleSatisfiesVisibility(tuple, snapshot) \
53 TransactionIdEquals((tuple)->t_data->t_xmax, AmiTransactionId) ? \
57 (IsSnapshotSelf(snapshot) || heapisoverride()) ? \
58 HeapTupleSatisfiesItself((tuple)->t_data) \
60 ((IsSnapshotDirty(snapshot)) ? \
61 HeapTupleSatisfiesDirty((tuple)->t_data) \
63 ((IsSnapshotNow(snapshot)) ? \
64 HeapTupleSatisfiesNow((tuple)->t_data) \
66 HeapTupleSatisfiesSnapshot((tuple)->t_data, snapshot) \
72 #define heapisoverride() \
74 (!TransactionIdIsValid(HeapSpecialTransactionId)) ? \
78 (!TransactionIdEquals(GetCurrentTransactionId(), \
79 HeapSpecialTransactionId) || \
80 GetCurrentCommandId() != HeapSpecialCommandId) ? \
82 HeapSpecialTransactionId = InvalidTransactionId, \
90 #define HeapTupleMayBeUpdated 0
91 #define HeapTupleInvisible 1
92 #define HeapTupleSelfUpdated 2
93 #define HeapTupleUpdated 3
94 #define HeapTupleBeingUpdated 4
96 extern bool HeapTupleSatisfiesItself(HeapTupleHeader tuple);
97 extern bool HeapTupleSatisfiesNow(HeapTupleHeader tuple);
98 extern bool HeapTupleSatisfiesDirty(HeapTupleHeader tuple);
99 extern bool HeapTupleSatisfiesSnapshot(HeapTupleHeader tuple, Snapshot snapshot);
100 extern int HeapTupleSatisfiesUpdate(HeapTuple tuple);
102 extern void setheapoverride(bool on);
104 extern Snapshot GetSnapshotData(bool serializable);
105 extern void SetQuerySnapshot(void);
106 extern void FreeXactSnapshot(void);