Header And Logo

PostgreSQL
| The world's most advanced open source database.

relscan.h

Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------
00002  *
00003  * relscan.h
00004  *    POSTGRES relation scan descriptor definitions.
00005  *
00006  *
00007  * Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group
00008  * Portions Copyright (c) 1994, Regents of the University of California
00009  *
00010  * src/include/access/relscan.h
00011  *
00012  *-------------------------------------------------------------------------
00013  */
00014 #ifndef RELSCAN_H
00015 #define RELSCAN_H
00016 
00017 #include "access/genam.h"
00018 #include "access/heapam.h"
00019 #include "access/htup_details.h"
00020 #include "access/itup.h"
00021 #include "access/tupdesc.h"
00022 
00023 
00024 typedef struct HeapScanDescData
00025 {
00026     /* scan parameters */
00027     Relation    rs_rd;          /* heap relation descriptor */
00028     Snapshot    rs_snapshot;    /* snapshot to see */
00029     int         rs_nkeys;       /* number of scan keys */
00030     ScanKey     rs_key;         /* array of scan key descriptors */
00031     bool        rs_bitmapscan;  /* true if this is really a bitmap scan */
00032     bool        rs_pageatatime; /* verify visibility page-at-a-time? */
00033     bool        rs_allow_strat; /* allow or disallow use of access strategy */
00034     bool        rs_allow_sync;  /* allow or disallow use of syncscan */
00035 
00036     /* state set up at initscan time */
00037     BlockNumber rs_nblocks;     /* number of blocks to scan */
00038     BlockNumber rs_startblock;  /* block # to start at */
00039     BufferAccessStrategy rs_strategy;   /* access strategy for reads */
00040     bool        rs_syncscan;    /* report location to syncscan logic? */
00041 
00042     /* scan current state */
00043     bool        rs_inited;      /* false = scan not init'd yet */
00044     HeapTupleData rs_ctup;      /* current tuple in scan, if any */
00045     BlockNumber rs_cblock;      /* current block # in scan, if any */
00046     Buffer      rs_cbuf;        /* current buffer in scan, if any */
00047     /* NB: if rs_cbuf is not InvalidBuffer, we hold a pin on that buffer */
00048     ItemPointerData rs_mctid;   /* marked scan position, if any */
00049 
00050     /* these fields only used in page-at-a-time mode and for bitmap scans */
00051     int         rs_cindex;      /* current tuple's index in vistuples */
00052     int         rs_mindex;      /* marked tuple's saved index */
00053     int         rs_ntuples;     /* number of visible tuples on page */
00054     OffsetNumber rs_vistuples[MaxHeapTuplesPerPage];    /* their offsets */
00055 }   HeapScanDescData;
00056 
00057 /*
00058  * We use the same IndexScanDescData structure for both amgettuple-based
00059  * and amgetbitmap-based index scans.  Some fields are only relevant in
00060  * amgettuple-based scans.
00061  */
00062 typedef struct IndexScanDescData
00063 {
00064     /* scan parameters */
00065     Relation    heapRelation;   /* heap relation descriptor, or NULL */
00066     Relation    indexRelation;  /* index relation descriptor */
00067     Snapshot    xs_snapshot;    /* snapshot to see */
00068     int         numberOfKeys;   /* number of index qualifier conditions */
00069     int         numberOfOrderBys;       /* number of ordering operators */
00070     ScanKey     keyData;        /* array of index qualifier descriptors */
00071     ScanKey     orderByData;    /* array of ordering op descriptors */
00072     bool        xs_want_itup;   /* caller requests index tuples */
00073 
00074     /* signaling to index AM about killing index tuples */
00075     bool        kill_prior_tuple;       /* last-returned tuple is dead */
00076     bool        ignore_killed_tuples;   /* do not return killed entries */
00077     bool        xactStartedInRecovery;  /* prevents killing/seeing killed
00078                                          * tuples */
00079 
00080     /* index access method's private state */
00081     void       *opaque;         /* access-method-specific info */
00082 
00083     /* in an index-only scan, this is valid after a successful amgettuple */
00084     IndexTuple  xs_itup;        /* index tuple returned by AM */
00085     TupleDesc   xs_itupdesc;    /* rowtype descriptor of xs_itup */
00086 
00087     /* xs_ctup/xs_cbuf/xs_recheck are valid after a successful index_getnext */
00088     HeapTupleData xs_ctup;      /* current heap tuple, if any */
00089     Buffer      xs_cbuf;        /* current heap buffer in scan, if any */
00090     /* NB: if xs_cbuf is not InvalidBuffer, we hold a pin on that buffer */
00091     bool        xs_recheck;     /* T means scan keys must be rechecked */
00092 
00093     /* state data for traversing HOT chains in index_getnext */
00094     bool        xs_continue_hot;    /* T if must keep walking HOT chain */
00095 }   IndexScanDescData;
00096 
00097 /* Struct for heap-or-index scans of system tables */
00098 typedef struct SysScanDescData
00099 {
00100     Relation    heap_rel;       /* catalog being scanned */
00101     Relation    irel;           /* NULL if doing heap scan */
00102     HeapScanDesc scan;          /* only valid in heap-scan case */
00103     IndexScanDesc iscan;        /* only valid in index-scan case */
00104 }   SysScanDescData;
00105 
00106 #endif   /* RELSCAN_H */