OSDN Git Service

Fix bug introduced by recent SSI patch to merge ROLLED_BACK and
[pg-rex/syncrep.git] / src / include / utils / snapshot.h
1 /*-------------------------------------------------------------------------
2  *
3  * snapshot.h
4  *        POSTGRES snapshot definition
5  *
6  * Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
7  * Portions Copyright (c) 1994, Regents of the University of California
8  *
9  * src/include/utils/snapshot.h
10  *
11  *-------------------------------------------------------------------------
12  */
13 #ifndef SNAPSHOT_H
14 #define SNAPSHOT_H
15
16 #include "access/htup.h"
17 #include "storage/buf.h"
18
19
20 typedef struct SnapshotData *Snapshot;
21
22 #define InvalidSnapshot         ((Snapshot) NULL)
23
24 /*
25  * We use SnapshotData structures to represent both "regular" (MVCC)
26  * snapshots and "special" snapshots that have non-MVCC semantics.
27  * The specific semantics of a snapshot are encoded by the "satisfies"
28  * function.
29  */
30 typedef bool (*SnapshotSatisfiesFunc) (HeapTupleHeader tuple,
31                                                                                    Snapshot snapshot, Buffer buffer);
32
33 typedef struct SnapshotData
34 {
35         SnapshotSatisfiesFunc satisfies;        /* tuple test function */
36
37         /*
38          * The remaining fields are used only for MVCC snapshots, and are normally
39          * just zeroes in special snapshots.  (But xmin and xmax are used
40          * specially by HeapTupleSatisfiesDirty.)
41          *
42          * An MVCC snapshot can never see the effects of XIDs >= xmax. It can see
43          * the effects of all older XIDs except those listed in the snapshot. xmin
44          * is stored as an optimization to avoid needing to search the XID arrays
45          * for most tuples.
46          */
47         TransactionId xmin;                     /* all XID < xmin are visible to me */
48         TransactionId xmax;                     /* all XID >= xmax are invisible to me */
49         uint32          xcnt;                   /* # of xact ids in xip[] */
50         TransactionId *xip;                     /* array of xact IDs in progress */
51         /* note: all ids in xip[] satisfy xmin <= xip[i] < xmax */
52         int32           subxcnt;                /* # of xact ids in subxip[] */
53         TransactionId *subxip;          /* array of subxact IDs in progress */
54         bool            suboverflowed;  /* has the subxip array overflowed? */
55         bool            takenDuringRecovery;    /* recovery-shaped snapshot? */
56
57         /*
58          * note: all ids in subxip[] are >= xmin, but we don't bother filtering
59          * out any that are >= xmax
60          */
61         CommandId       curcid;                 /* in my xact, CID < curcid are visible */
62         uint32          active_count;   /* refcount on ActiveSnapshot stack */
63         uint32          regd_count;             /* refcount on RegisteredSnapshotList */
64         bool            copied;                 /* false if it's a static snapshot */
65 } SnapshotData;
66
67 /*
68  * Result codes for HeapTupleSatisfiesUpdate.  This should really be in
69  * tqual.h, but we want to avoid including that file elsewhere.
70  */
71 typedef enum
72 {
73         HeapTupleMayBeUpdated,
74         HeapTupleInvisible,
75         HeapTupleSelfUpdated,
76         HeapTupleUpdated,
77         HeapTupleBeingUpdated
78 } HTSU_Result;
79
80 #endif   /* SNAPSHOT_H */