]> granicus.if.org Git - postgresql/blob - src/include/access/relscan.h
Fix for bug #866. 7.3 contains new logic for avoiding redundant calls to
[postgresql] / src / include / access / relscan.h
1 /*-------------------------------------------------------------------------
2  *
3  * relscan.h
4  *        POSTGRES relation scan descriptor definitions.
5  *
6  *
7  * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * $Id: relscan.h,v 1.30 2003/01/08 19:41:40 tgl Exp $
11  *
12  *-------------------------------------------------------------------------
13  */
14 #ifndef RELSCAN_H
15 #define RELSCAN_H
16
17 #include "utils/tqual.h"
18
19
20 typedef struct HeapScanDescData
21 {
22         /* scan parameters */
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 */
27
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 */
33
34         PgStat_Info rs_pgstat_info; /* statistics collector hook */
35 } HeapScanDescData;
36
37 typedef HeapScanDescData *HeapScanDesc;
38
39
40 typedef struct IndexScanDescData
41 {
42         /* scan parameters */
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 */
48
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 */
52
53         /* set by index AM if scan keys satisfy index's uniqueness constraint */
54         bool            keys_are_unique;
55
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 */
61
62         /*
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.
66          */
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 */
70
71         FmgrInfo        fn_getnext;             /* cached lookup info for AM's getnext fn */
72
73         /*
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.
78          */
79         int                     unique_tuple_pos; /* logical position */
80         int                     unique_tuple_mark; /* logical marked position */
81
82         PgStat_Info xs_pgstat_info; /* statistics collector hook */
83 } IndexScanDescData;
84
85 typedef IndexScanDescData *IndexScanDesc;
86
87
88 /* ----------------
89  *              IndexScanDescPtr is used in the executor where we have to
90  *              keep track of several index scans when using several indices
91  *              - cim 9/10/89
92  * ----------------
93  */
94 typedef IndexScanDesc *IndexScanDescPtr;
95
96 /*
97  * HeapScanIsValid
98  *              True iff the heap scan is valid.
99  */
100 #define HeapScanIsValid(scan) PointerIsValid(scan)
101
102 /*
103  * IndexScanIsValid
104  *              True iff the index scan is valid.
105  */
106 #define IndexScanIsValid(scan) PointerIsValid(scan)
107
108 #endif   /* RELSCAN_H */