1 /*-------------------------------------------------------------------------
4 * POSTGRES relation scan descriptor definitions.
7 * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
10 * $Id: relscan.h,v 1.30 2003/01/08 19:41:40 tgl Exp $
12 *-------------------------------------------------------------------------
17 #include "utils/tqual.h"
20 typedef struct HeapScanDescData
23 Relation rs_rd; /* heap relation descriptor */
24 Snapshot rs_snapshot; /* snapshot to see */
25 int rs_nkeys; /* number of scan keys */
26 ScanKey rs_key; /* array of scan key descriptors */
28 /* scan current state */
29 HeapTupleData rs_ctup; /* current tuple in scan, if any */
30 Buffer rs_cbuf; /* current buffer in scan, if any */
31 /* NB: if rs_cbuf is not InvalidBuffer, we hold a pin on that buffer */
32 ItemPointerData rs_mctid; /* marked scan position, if any */
34 PgStat_Info rs_pgstat_info; /* statistics collector hook */
37 typedef HeapScanDescData *HeapScanDesc;
40 typedef struct IndexScanDescData
43 Relation heapRelation; /* heap relation descriptor, or NULL */
44 Relation indexRelation; /* index relation descriptor */
45 Snapshot xs_snapshot; /* snapshot to see */
46 int numberOfKeys; /* number of scan keys */
47 ScanKey keyData; /* array of scan key descriptors */
49 /* signaling to index AM about killing index tuples */
50 bool kill_prior_tuple; /* last-returned tuple is dead */
51 bool ignore_killed_tuples; /* do not return killed entries */
53 /* set by index AM if scan keys satisfy index's uniqueness constraint */
56 /* scan current state */
57 bool got_tuple; /* true after successful index_getnext */
58 void *opaque; /* access-method-specific info */
59 ItemPointerData currentItemData; /* current index pointer */
60 ItemPointerData currentMarkData; /* marked position, if any */
63 * xs_ctup/xs_cbuf are valid after a successful index_getnext. After
64 * index_getnext_indexitem, xs_ctup.t_self contains the heap tuple TID
65 * from the index entry, but its other fields are not valid.
67 HeapTupleData xs_ctup; /* current heap tuple, if any */
68 Buffer xs_cbuf; /* current heap buffer in scan, if any */
69 /* NB: if xs_cbuf is not InvalidBuffer, we hold a pin on that buffer */
71 FmgrInfo fn_getnext; /* cached lookup info for AM's getnext fn */
74 * If keys_are_unique and got_tuple are both true, we stop calling the
75 * index AM; it is then necessary for index_getnext to keep track of
76 * the logical scan position for itself. It does that using
77 * unique_tuple_pos: -1 = before row, 0 = on row, +1 = after row.
79 int unique_tuple_pos; /* logical position */
80 int unique_tuple_mark; /* logical marked position */
82 PgStat_Info xs_pgstat_info; /* statistics collector hook */
85 typedef IndexScanDescData *IndexScanDesc;
89 * IndexScanDescPtr is used in the executor where we have to
90 * keep track of several index scans when using several indices
94 typedef IndexScanDesc *IndexScanDescPtr;
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 */