1 /*-------------------------------------------------------------------------
4 * POSTGRES relation scan descriptor definitions.
7 * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
12 *-------------------------------------------------------------------------
17 #include "access/htup.h"
18 #include "access/skey.h"
19 #include "storage/bufpage.h"
20 #include "utils/snapshot.h"
23 typedef struct HeapScanDescData
26 Relation rs_rd
; /* heap relation descriptor */
27 Snapshot rs_snapshot
; /* snapshot to see */
28 int rs_nkeys
; /* number of scan keys */
29 ScanKey rs_key
; /* array of scan key descriptors */
30 bool rs_bitmapscan
; /* true if this is really a bitmap scan */
31 bool rs_pageatatime
; /* verify visibility page-at-a-time? */
32 bool rs_allow_strat
; /* allow or disallow use of access strategy */
33 bool rs_allow_sync
; /* allow or disallow use of syncscan */
35 /* state set up at initscan time */
36 BlockNumber rs_nblocks
; /* number of blocks to scan */
37 BlockNumber rs_startblock
; /* block # to start at */
38 BufferAccessStrategy rs_strategy
; /* access strategy for reads */
39 bool rs_syncscan
; /* report location to syncscan logic? */
41 /* scan current state */
42 bool rs_inited
; /* false = scan not init'd yet */
43 HeapTupleData rs_ctup
; /* current tuple in scan, if any */
44 BlockNumber rs_cblock
; /* current block # in scan, if any */
45 Buffer rs_cbuf
; /* current buffer in scan, if any */
46 /* NB: if rs_cbuf is not InvalidBuffer, we hold a pin on that buffer */
47 ItemPointerData rs_mctid
; /* marked scan position, if any */
49 /* these fields only used in page-at-a-time mode and for bitmap scans */
50 int rs_cindex
; /* current tuple's index in vistuples */
51 int rs_mindex
; /* marked tuple's saved index */
52 int rs_ntuples
; /* number of visible tuples on page */
53 OffsetNumber rs_vistuples
[MaxHeapTuplesPerPage
]; /* their offsets */
56 typedef HeapScanDescData
*HeapScanDesc
;
59 * We use the same IndexScanDescData structure for both amgettuple-based
60 * and amgetmulti-based index scans. Some fields are only relevant in
61 * amgettuple-based scans.
63 typedef struct IndexScanDescData
66 Relation heapRelation
; /* heap relation descriptor, or NULL */
67 Relation indexRelation
; /* index relation descriptor */
68 Snapshot xs_snapshot
; /* snapshot to see */
69 int numberOfKeys
; /* number of scan keys */
70 ScanKey keyData
; /* array of scan key descriptors */
71 bool is_multiscan
; /* TRUE = using amgetmulti */
73 /* signaling to index AM about killing index tuples */
74 bool kill_prior_tuple
; /* last-returned tuple is dead */
75 bool ignore_killed_tuples
; /* do not return killed entries */
77 /* index access method's private state */
78 void *opaque
; /* access-method-specific info */
81 * xs_ctup/xs_cbuf are valid after a successful index_getnext. After
82 * index_getnext_indexitem, xs_ctup.t_self contains the heap tuple TID
83 * from the index entry, but its other fields are not valid.
85 HeapTupleData xs_ctup
; /* current heap tuple, if any */
86 Buffer xs_cbuf
; /* current heap buffer in scan, if any */
87 /* NB: if xs_cbuf is not InvalidBuffer, we hold a pin on that buffer */
88 TransactionId xs_prev_xmax
; /* previous HOT chain member's XMAX, if any */
89 OffsetNumber xs_next_hot
; /* next member of HOT chain, if any */
90 bool xs_hot_dead
; /* T if all members of HOT chain are dead */
93 typedef IndexScanDescData
*IndexScanDesc
;
98 * True iff the heap scan is valid.
100 #define HeapScanIsValid(scan) PointerIsValid(scan)
104 * True iff the index scan is valid.
106 #define IndexScanIsValid(scan) PointerIsValid(scan)
108 #endif /* RELSCAN_H */