1996-08-27 23:50:29 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* relscan.h
|
2002-05-21 01:51:44 +02:00
|
|
|
* POSTGRES relation scan descriptor definitions.
|
1996-08-27 23:50:29 +02:00
|
|
|
*
|
|
|
|
*
|
2011-01-01 19:18:15 +01:00
|
|
|
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-08-27 23:50:29 +02:00
|
|
|
*
|
2010-09-20 22:08:53 +02:00
|
|
|
* src/include/access/relscan.h
|
1996-08-27 23:50:29 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
1997-09-07 07:04:48 +02:00
|
|
|
#ifndef RELSCAN_H
|
1996-08-27 23:50:29 +02:00
|
|
|
#define RELSCAN_H
|
|
|
|
|
2008-06-19 02:46:06 +02:00
|
|
|
#include "access/genam.h"
|
|
|
|
#include "access/heapam.h"
|
1996-08-27 23:50:29 +02:00
|
|
|
|
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
typedef struct HeapScanDescData
|
|
|
|
{
|
2002-05-21 01:51:44 +02:00
|
|
|
/* scan parameters */
|
|
|
|
Relation rs_rd; /* heap relation descriptor */
|
|
|
|
Snapshot rs_snapshot; /* snapshot to see */
|
|
|
|
int rs_nkeys; /* number of scan keys */
|
|
|
|
ScanKey rs_key; /* array of scan key descriptors */
|
2007-06-09 20:49:55 +02:00
|
|
|
bool rs_bitmapscan; /* true if this is really a bitmap scan */
|
2007-11-15 22:14:46 +01:00
|
|
|
bool rs_pageatatime; /* verify visibility page-at-a-time? */
|
2008-01-14 02:39:09 +01:00
|
|
|
bool rs_allow_strat; /* allow or disallow use of access strategy */
|
|
|
|
bool rs_allow_sync; /* allow or disallow use of syncscan */
|
2007-06-08 20:23:53 +02:00
|
|
|
|
|
|
|
/* state set up at initscan time */
|
2004-05-08 21:09:25 +02:00
|
|
|
BlockNumber rs_nblocks; /* number of blocks to scan */
|
2007-11-15 22:14:46 +01:00
|
|
|
BlockNumber rs_startblock; /* block # to start at */
|
2007-05-30 22:12:03 +02:00
|
|
|
BufferAccessStrategy rs_strategy; /* access strategy for reads */
|
2007-06-08 20:23:53 +02:00
|
|
|
bool rs_syncscan; /* report location to syncscan logic? */
|
2002-05-21 01:51:44 +02:00
|
|
|
|
|
|
|
/* scan current state */
|
2005-11-26 04:03:07 +01:00
|
|
|
bool rs_inited; /* false = scan not init'd yet */
|
2001-06-09 20:16:59 +02:00
|
|
|
HeapTupleData rs_ctup; /* current tuple in scan, if any */
|
2006-10-04 02:30:14 +02:00
|
|
|
BlockNumber rs_cblock; /* current block # in scan, if any */
|
2001-06-09 20:16:59 +02:00
|
|
|
Buffer rs_cbuf; /* current buffer in scan, if any */
|
|
|
|
/* NB: if rs_cbuf is not InvalidBuffer, we hold a pin on that buffer */
|
2002-05-21 01:51:44 +02:00
|
|
|
ItemPointerData rs_mctid; /* marked scan position, if any */
|
2001-06-22 21:16:24 +02:00
|
|
|
|
2007-06-09 20:49:55 +02:00
|
|
|
/* these fields only used in page-at-a-time mode and for bitmap scans */
|
2005-11-26 04:03:07 +01:00
|
|
|
int rs_cindex; /* current tuple's index in vistuples */
|
|
|
|
int rs_mindex; /* marked tuple's saved index */
|
|
|
|
int rs_ntuples; /* number of visible tuples on page */
|
|
|
|
OffsetNumber rs_vistuples[MaxHeapTuplesPerPage]; /* their offsets */
|
2011-04-10 17:42:00 +02:00
|
|
|
} HeapScanDescData;
|
1996-08-27 23:50:29 +02:00
|
|
|
|
2005-03-28 01:53:05 +02:00
|
|
|
/*
|
|
|
|
* We use the same IndexScanDescData structure for both amgettuple-based
|
2008-04-11 00:25:26 +02:00
|
|
|
* and amgetbitmap-based index scans. Some fields are only relevant in
|
2005-05-28 01:31:21 +02:00
|
|
|
* amgettuple-based scans.
|
2005-03-28 01:53:05 +02:00
|
|
|
*/
|
1997-09-07 07:04:48 +02:00
|
|
|
typedef struct IndexScanDescData
|
|
|
|
{
|
2002-05-21 01:51:44 +02:00
|
|
|
/* scan parameters */
|
|
|
|
Relation heapRelation; /* heap relation descriptor, or NULL */
|
|
|
|
Relation indexRelation; /* index relation descriptor */
|
|
|
|
Snapshot xs_snapshot; /* snapshot to see */
|
2010-12-03 02:50:48 +01:00
|
|
|
int numberOfKeys; /* number of index qualifier conditions */
|
2011-04-10 17:42:00 +02:00
|
|
|
int numberOfOrderBys; /* number of ordering operators */
|
|
|
|
ScanKey keyData; /* array of index qualifier descriptors */
|
|
|
|
ScanKey orderByData; /* array of ordering op descriptors */
|
2002-05-21 01:51:44 +02:00
|
|
|
|
2002-05-24 20:57:57 +02:00
|
|
|
/* signaling to index AM about killing index tuples */
|
|
|
|
bool kill_prior_tuple; /* last-returned tuple is dead */
|
|
|
|
bool ignore_killed_tuples; /* do not return killed entries */
|
2010-02-26 03:01:40 +01:00
|
|
|
bool xactStartedInRecovery; /* prevents killing/seeing killed
|
|
|
|
* tuples */
|
2002-05-24 20:57:57 +02:00
|
|
|
|
2006-05-07 03:21:30 +02:00
|
|
|
/* index access method's private state */
|
2001-06-09 20:16:59 +02:00
|
|
|
void *opaque; /* access-method-specific info */
|
2002-09-04 22:31:48 +02:00
|
|
|
|
2008-04-13 21:18:14 +02:00
|
|
|
/* xs_ctup/xs_cbuf/xs_recheck are valid after a successful index_getnext */
|
2002-05-21 01:51:44 +02:00
|
|
|
HeapTupleData xs_ctup; /* current heap tuple, if any */
|
|
|
|
Buffer xs_cbuf; /* current heap buffer in scan, if any */
|
|
|
|
/* NB: if xs_cbuf is not InvalidBuffer, we hold a pin on that buffer */
|
2008-04-13 21:18:14 +02:00
|
|
|
bool xs_recheck; /* T means scan keys must be rechecked */
|
2008-04-13 01:14:21 +02:00
|
|
|
|
|
|
|
/* state data for traversing HOT chains in index_getnext */
|
2011-06-27 16:27:17 +02:00
|
|
|
bool xs_continue_hot; /* T if must keep walking HOT chain */
|
2011-04-10 17:42:00 +02:00
|
|
|
} IndexScanDescData;
|
1996-08-27 23:50:29 +02:00
|
|
|
|
2008-06-19 02:46:06 +02:00
|
|
|
/* Struct for heap-or-index scans of system tables */
|
|
|
|
typedef struct SysScanDescData
|
|
|
|
{
|
|
|
|
Relation heap_rel; /* catalog being scanned */
|
|
|
|
Relation irel; /* NULL if doing heap scan */
|
|
|
|
HeapScanDesc scan; /* only valid in heap-scan case */
|
|
|
|
IndexScanDesc iscan; /* only valid in index-scan case */
|
2011-04-10 17:42:00 +02:00
|
|
|
} SysScanDescData;
|
2001-10-28 07:26:15 +01:00
|
|
|
|
2001-11-05 18:46:40 +01:00
|
|
|
#endif /* RELSCAN_H */
|