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
|
|
|
*
|
|
|
|
*
|
2007-01-05 23:20:05 +01:00
|
|
|
* Portions Copyright (c) 1996-2007, 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
|
|
|
*
|
2007-09-20 19:56:33 +02:00
|
|
|
* $PostgreSQL: pgsql/src/include/access/relscan.h,v 1.57 2007/09/20 17:56:32 tgl Exp $
|
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
|
|
|
|
|
2003-11-09 22:30:38 +01:00
|
|
|
#include "access/skey.h"
|
2006-07-13 19:47:02 +02:00
|
|
|
#include "storage/bufpage.h"
|
1999-07-16 01:04:24 +02:00
|
|
|
#include "utils/tqual.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 */
|
|
|
|
bool rs_pageatatime; /* verify visibility page-at-a-time? */
|
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-06-08 20:23:53 +02: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 */
|
1997-09-08 23:56:23 +02:00
|
|
|
} HeapScanDescData;
|
1996-08-27 23:50:29 +02:00
|
|
|
|
|
|
|
typedef HeapScanDescData *HeapScanDesc;
|
|
|
|
|
2005-03-28 01:53:05 +02:00
|
|
|
/*
|
|
|
|
* We use the same IndexScanDescData structure for both amgettuple-based
|
2005-05-28 01:31:21 +02:00
|
|
|
* and amgetmulti-based index scans. Some fields are only relevant in
|
|
|
|
* 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 */
|
|
|
|
int numberOfKeys; /* number of scan keys */
|
|
|
|
ScanKey keyData; /* array of scan key descriptors */
|
2005-05-28 01:31:21 +02:00
|
|
|
bool is_multiscan; /* TRUE = using amgetmulti */
|
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 */
|
|
|
|
|
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
|
|
|
|
2002-05-21 01:51:44 +02:00
|
|
|
/*
|
2002-09-04 22:31:48 +02:00
|
|
|
* xs_ctup/xs_cbuf are valid after a successful index_getnext. After
|
|
|
|
* index_getnext_indexitem, xs_ctup.t_self contains the heap tuple TID
|
|
|
|
* from the index entry, but its other fields are not valid.
|
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 */
|
2007-09-20 19:56:33 +02:00
|
|
|
TransactionId xs_prev_xmax; /* previous HOT chain member's XMAX, if any */
|
|
|
|
OffsetNumber xs_next_hot; /* next member of HOT chain, if any */
|
|
|
|
bool xs_hot_dead; /* T if all members of HOT chain are dead */
|
1997-09-08 23:56:23 +02:00
|
|
|
} IndexScanDescData;
|
1996-08-27 23:50:29 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
typedef IndexScanDescData *IndexScanDesc;
|
1996-08-27 23:50:29 +02:00
|
|
|
|
2001-06-09 20:16:59 +02:00
|
|
|
|
1996-08-27 23:50:29 +02:00
|
|
|
/*
|
1999-05-25 18:15:34 +02:00
|
|
|
* HeapScanIsValid
|
1997-09-07 07:04:48 +02:00
|
|
|
* True iff the heap scan is valid.
|
1996-08-27 23:50:29 +02:00
|
|
|
*/
|
1997-09-07 07:04:48 +02:00
|
|
|
#define HeapScanIsValid(scan) PointerIsValid(scan)
|
1996-08-27 23:50:29 +02:00
|
|
|
|
|
|
|
/*
|
1999-05-25 18:15:34 +02:00
|
|
|
* IndexScanIsValid
|
1997-09-07 07:04:48 +02:00
|
|
|
* True iff the index scan is valid.
|
1996-08-27 23:50:29 +02:00
|
|
|
*/
|
|
|
|
#define IndexScanIsValid(scan) PointerIsValid(scan)
|
2001-10-28 07:26:15 +01:00
|
|
|
|
2001-11-05 18:46:40 +01:00
|
|
|
#endif /* RELSCAN_H */
|