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
|
|
|
*
|
|
|
|
*
|
2002-06-20 22:29:54 +02:00
|
|
|
* Portions Copyright (c) 1996-2002, 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
|
|
|
*
|
2003-01-08 20:41:40 +01:00
|
|
|
* $Id: relscan.h,v 1.30 2003/01/08 19:41:40 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
|
|
|
|
|
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 */
|
|
|
|
|
|
|
|
/* scan current state */
|
2001-06-09 20:16:59 +02:00
|
|
|
HeapTupleData rs_ctup; /* current tuple in scan, if any */
|
|
|
|
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
|
|
|
|
2001-10-25 07:50:21 +02:00
|
|
|
PgStat_Info rs_pgstat_info; /* statistics collector hook */
|
1997-09-08 23:56:23 +02:00
|
|
|
} HeapScanDescData;
|
1996-08-27 23:50:29 +02:00
|
|
|
|
|
|
|
typedef HeapScanDescData *HeapScanDesc;
|
|
|
|
|
2002-05-21 01:51:44 +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 */
|
|
|
|
|
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 */
|
|
|
|
|
|
|
|
/* set by index AM if scan keys satisfy index's uniqueness constraint */
|
|
|
|
bool keys_are_unique;
|
|
|
|
|
2002-05-21 01:51:44 +02:00
|
|
|
/* scan current state */
|
2002-05-24 20:57:57 +02:00
|
|
|
bool got_tuple; /* true after successful index_getnext */
|
2001-06-09 20:16:59 +02:00
|
|
|
void *opaque; /* access-method-specific info */
|
1997-09-07 07:04:48 +02:00
|
|
|
ItemPointerData currentItemData; /* current index pointer */
|
2002-05-21 01:51:44 +02:00
|
|
|
ItemPointerData currentMarkData; /* marked position, if any */
|
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 */
|
|
|
|
|
|
|
|
FmgrInfo fn_getnext; /* cached lookup info for AM's getnext fn */
|
2001-06-22 21:16:24 +02:00
|
|
|
|
2003-01-08 20:41:40 +01:00
|
|
|
/*
|
|
|
|
* If keys_are_unique and got_tuple are both true, we stop calling the
|
|
|
|
* index AM; it is then necessary for index_getnext to keep track of
|
|
|
|
* the logical scan position for itself. It does that using
|
|
|
|
* unique_tuple_pos: -1 = before row, 0 = on row, +1 = after row.
|
|
|
|
*/
|
|
|
|
int unique_tuple_pos; /* logical position */
|
|
|
|
int unique_tuple_mark; /* logical marked position */
|
|
|
|
|
2001-10-25 07:50:21 +02:00
|
|
|
PgStat_Info xs_pgstat_info; /* statistics collector hook */
|
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
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* IndexScanDescPtr is used in the executor where we have to
|
|
|
|
* keep track of several index scans when using several indices
|
|
|
|
* - cim 9/10/89
|
1996-08-27 23:50:29 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
1997-09-07 07:04:48 +02:00
|
|
|
typedef IndexScanDesc *IndexScanDescPtr;
|
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 */
|