]> granicus.if.org Git - postgresql/blob - src/include/access/relscan.h
Get rid of rd_nblocks field in relcache entries. Turns out this was
[postgresql] / src / include / access / relscan.h
1 /*-------------------------------------------------------------------------
2  *
3  * relscan.h
4  *        POSTGRES relation scan descriptor definitions.
5  *
6  *
7  * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * $PostgreSQL: pgsql/src/include/access/relscan.h,v 1.35 2004/05/08 19:09:25 tgl Exp $
11  *
12  *-------------------------------------------------------------------------
13  */
14 #ifndef RELSCAN_H
15 #define RELSCAN_H
16
17 #include "access/skey.h"
18 #include "utils/tqual.h"
19
20
21 typedef struct HeapScanDescData
22 {
23         /* scan parameters */
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 */
29
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 */
35
36         PgStat_Info rs_pgstat_info; /* statistics collector hook */
37 } HeapScanDescData;
38
39 typedef HeapScanDescData *HeapScanDesc;
40
41
42 typedef struct IndexScanDescData
43 {
44         /* scan parameters */
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 */
50
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 */
54
55         /* set by index AM if scan keys satisfy index's uniqueness constraint */
56         bool            keys_are_unique;
57
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 */
63
64         /*
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.
68          */
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 */
72
73         FmgrInfo        fn_getnext;             /* cached lookup info for AM's getnext fn */
74
75         /*
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.
80          */
81         int                     unique_tuple_pos;               /* logical position */
82         int                     unique_tuple_mark;              /* logical marked position */
83
84         PgStat_Info xs_pgstat_info; /* statistics collector hook */
85 } IndexScanDescData;
86
87 typedef IndexScanDescData *IndexScanDesc;
88
89
90 /* ----------------
91  *              IndexScanDescPtr is used in the executor where we have to
92  *              keep track of several index scans when using several indices
93  *              - cim 9/10/89
94  * ----------------
95  */
96 typedef IndexScanDesc *IndexScanDescPtr;
97
98 /*
99  * HeapScanIsValid
100  *              True iff the heap scan is valid.
101  */
102 #define HeapScanIsValid(scan) PointerIsValid(scan)
103
104 /*
105  * IndexScanIsValid
106  *              True iff the index scan is valid.
107  */
108 #define IndexScanIsValid(scan) PointerIsValid(scan)
109
110 #endif   /* RELSCAN_H */