1 /*-------------------------------------------------------------------------
4 * POSTGRES relation scan descriptor definitions.
7 * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
10 * $PostgreSQL: pgsql/src/include/access/relscan.h,v 1.51 2007/01/05 22:19:51 momjian Exp $
12 *-------------------------------------------------------------------------
17 #include "access/skey.h"
18 #include "storage/bufpage.h"
19 #include "utils/tqual.h"
22 typedef struct HeapScanDescData
25 Relation rs_rd; /* heap relation descriptor */
26 Snapshot rs_snapshot; /* snapshot to see */
27 int rs_nkeys; /* number of scan keys */
28 ScanKey rs_key; /* array of scan key descriptors */
29 BlockNumber rs_nblocks; /* number of blocks to scan */
30 bool rs_pageatatime; /* verify visibility page-at-a-time? */
32 /* scan current state */
33 bool rs_inited; /* false = scan not init'd yet */
34 HeapTupleData rs_ctup; /* current tuple in scan, if any */
35 BlockNumber rs_cblock; /* current block # in scan, if any */
36 Buffer rs_cbuf; /* current buffer in scan, if any */
37 /* NB: if rs_cbuf is not InvalidBuffer, we hold a pin on that buffer */
38 ItemPointerData rs_mctid; /* marked scan position, if any */
40 PgStat_Info rs_pgstat_info; /* statistics collector hook */
42 /* these fields only used in page-at-a-time mode */
43 int rs_cindex; /* current tuple's index in vistuples */
44 int rs_mindex; /* marked tuple's saved index */
45 int rs_ntuples; /* number of visible tuples on page */
46 OffsetNumber rs_vistuples[MaxHeapTuplesPerPage]; /* their offsets */
49 typedef HeapScanDescData *HeapScanDesc;
52 * We use the same IndexScanDescData structure for both amgettuple-based
53 * and amgetmulti-based index scans. Some fields are only relevant in
54 * amgettuple-based scans.
56 typedef struct IndexScanDescData
59 Relation heapRelation; /* heap relation descriptor, or NULL */
60 Relation indexRelation; /* index relation descriptor */
61 Snapshot xs_snapshot; /* snapshot to see */
62 int numberOfKeys; /* number of scan keys */
63 ScanKey keyData; /* array of scan key descriptors */
64 bool is_multiscan; /* TRUE = using amgetmulti */
66 /* signaling to index AM about killing index tuples */
67 bool kill_prior_tuple; /* last-returned tuple is dead */
68 bool ignore_killed_tuples; /* do not return killed entries */
70 /* index access method's private state */
71 void *opaque; /* access-method-specific info */
72 /* these fields are used by some but not all AMs: */
73 ItemPointerData currentItemData; /* current index pointer */
74 ItemPointerData currentMarkData; /* marked position, if any */
77 * xs_ctup/xs_cbuf are valid after a successful index_getnext. After
78 * index_getnext_indexitem, xs_ctup.t_self contains the heap tuple TID
79 * from the index entry, but its other fields are not valid.
81 HeapTupleData xs_ctup; /* current heap tuple, if any */
82 Buffer xs_cbuf; /* current heap buffer in scan, if any */
83 /* NB: if xs_cbuf is not InvalidBuffer, we hold a pin on that buffer */
85 PgStat_Info xs_pgstat_info; /* statistics collector hook */
88 typedef IndexScanDescData *IndexScanDesc;
93 * True iff the heap scan is valid.
95 #define HeapScanIsValid(scan) PointerIsValid(scan)
99 * True iff the index scan is valid.
101 #define IndexScanIsValid(scan) PointerIsValid(scan)
103 #endif /* RELSCAN_H */