1 /*-------------------------------------------------------------------------
4 * POSTGRES relation scan descriptor definitions.
7 * Portions Copyright (c) 1996-2003, 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.35 2004/05/08 19:09:25 tgl Exp $
12 *-------------------------------------------------------------------------
17 #include "access/skey.h"
18 #include "utils/tqual.h"
21 typedef struct HeapScanDescData
24 Relation rs_rd; /* heap relation descriptor */
25 Snapshot rs_snapshot; /* snapshot to see */
26 int rs_nkeys; /* number of scan keys */
27 ScanKey rs_key; /* array of scan key descriptors */
28 BlockNumber rs_nblocks; /* number of blocks to scan */
30 /* scan current state */
31 HeapTupleData rs_ctup; /* current tuple in scan, if any */
32 Buffer rs_cbuf; /* current buffer in scan, if any */
33 /* NB: if rs_cbuf is not InvalidBuffer, we hold a pin on that buffer */
34 ItemPointerData rs_mctid; /* marked scan position, if any */
36 PgStat_Info rs_pgstat_info; /* statistics collector hook */
39 typedef HeapScanDescData *HeapScanDesc;
42 typedef struct IndexScanDescData
45 Relation heapRelation; /* heap relation descriptor, or NULL */
46 Relation indexRelation; /* index relation descriptor */
47 Snapshot xs_snapshot; /* snapshot to see */
48 int numberOfKeys; /* number of scan keys */
49 ScanKey keyData; /* array of scan key descriptors */
51 /* signaling to index AM about killing index tuples */
52 bool kill_prior_tuple; /* last-returned tuple is dead */
53 bool ignore_killed_tuples; /* do not return killed entries */
55 /* set by index AM if scan keys satisfy index's uniqueness constraint */
58 /* scan current state */
59 bool got_tuple; /* true after successful index_getnext */
60 void *opaque; /* access-method-specific info */
61 ItemPointerData currentItemData; /* current index pointer */
62 ItemPointerData currentMarkData; /* marked position, if any */
65 * xs_ctup/xs_cbuf are valid after a successful index_getnext. After
66 * index_getnext_indexitem, xs_ctup.t_self contains the heap tuple TID
67 * from the index entry, but its other fields are not valid.
69 HeapTupleData xs_ctup; /* current heap tuple, if any */
70 Buffer xs_cbuf; /* current heap buffer in scan, if any */
71 /* NB: if xs_cbuf is not InvalidBuffer, we hold a pin on that buffer */
73 FmgrInfo fn_getnext; /* cached lookup info for AM's getnext fn */
76 * If keys_are_unique and got_tuple are both true, we stop calling the
77 * index AM; it is then necessary for index_getnext to keep track of
78 * the logical scan position for itself. It does that using
79 * unique_tuple_pos: -1 = before row, 0 = on row, +1 = after row.
81 int unique_tuple_pos; /* logical position */
82 int unique_tuple_mark; /* logical marked position */
84 PgStat_Info xs_pgstat_info; /* statistics collector hook */
87 typedef IndexScanDescData *IndexScanDesc;
91 * IndexScanDescPtr is used in the executor where we have to
92 * keep track of several index scans when using several indices
96 typedef IndexScanDesc *IndexScanDescPtr;
100 * True iff the heap scan is valid.
102 #define HeapScanIsValid(scan) PointerIsValid(scan)
106 * True iff the index scan is valid.
108 #define IndexScanIsValid(scan) PointerIsValid(scan)
110 #endif /* RELSCAN_H */