aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/execAmi.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/executor/execAmi.c')
-rw-r--r--src/backend/executor/execAmi.c232
1 files changed, 1 insertions, 231 deletions
diff --git a/src/backend/executor/execAmi.c b/src/backend/executor/execAmi.c
index af0e190d396..e7a335916bd 100644
--- a/src/backend/executor/execAmi.c
+++ b/src/backend/executor/execAmi.c
@@ -6,25 +6,12 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: execAmi.c,v 1.60 2001/10/25 05:49:27 momjian Exp $
+ * $Id: execAmi.c,v 1.61 2002/02/19 20:11:13 tgl Exp $
*
*-------------------------------------------------------------------------
*/
-/*
- * INTERFACE ROUTINES
- *
- * ExecOpenScanR \ / amopen
- * ExecBeginScan \ / ambeginscan
- * ExecCloseR \ / amclose
- * ExecInsert \ executor interface / aminsert
- * ExecReScanR / to access methods \ amrescan
- * ExecMarkPos / \ ammarkpos
- * ExecRestrPos / \ amrestpos
- */
-
#include "postgres.h"
-
#include "access/genam.h"
#include "access/heapam.h"
#include "catalog/heap.h"
@@ -50,202 +37,6 @@
#include "executor/nodeSubqueryscan.h"
#include "executor/nodeUnique.h"
-static Pointer ExecBeginScan(Relation relation, int nkeys, ScanKey skeys,
- bool isindex, ScanDirection dir, Snapshot snapshot);
-
-/* ----------------------------------------------------------------
- * ExecOpenScanR
- *
- * old comments:
- * Parameters:
- * relation -- relation to be opened and scanned.
- * nkeys -- number of keys
- * skeys -- keys to restrict scanning
- * isindex -- if this is true, the relation is the relid of
- * an index relation, else it is a heap relation.
- * Returns the relation as(relDesc scanDesc)
- * ----------------------------------------------------------------
- */
-void
-ExecOpenScanR(Oid relOid,
- int nkeys,
- ScanKey skeys,
- bool isindex,
- ScanDirection dir,
- Snapshot snapshot,
- Relation *returnRelation, /* return */
- Pointer *returnScanDesc) /* return */
-{
- Relation relation;
- Pointer scanDesc;
-
- /*
- * note: scanDesc returned by ExecBeginScan can be either a
- * HeapScanDesc or an IndexScanDesc so for now we make it a Pointer.
- * There should be a better scan abstraction someday -cim 9/9/89
- */
-
- /*
- * Open the relation with the correct call depending on whether this
- * is a heap relation or an index relation.
- *
- * For a table, acquire AccessShareLock for the duration of the query
- * execution. For indexes, acquire no lock here; the index machinery
- * does its own locks and unlocks. (We rely on having some kind of
- * lock on the parent table to ensure the index won't go away!)
- */
- if (isindex)
- relation = index_open(relOid);
- else
- relation = heap_open(relOid, AccessShareLock);
-
- scanDesc = ExecBeginScan(relation,
- nkeys,
- skeys,
- isindex,
- dir,
- snapshot);
-
- if (returnRelation != NULL)
- *returnRelation = relation;
- if (scanDesc != NULL)
- *returnScanDesc = scanDesc;
-}
-
-/* ----------------------------------------------------------------
- * ExecBeginScan
- *
- * beginscans a relation in current direction.
- *
- * XXX fix parameters to AMbeginscan (and btbeginscan)
- * currently we need to pass a flag stating whether
- * or not the scan should begin at an endpoint of
- * the relation.. Right now we always pass false
- * -cim 9/14/89
- * ----------------------------------------------------------------
- */
-static Pointer
-ExecBeginScan(Relation relation,
- int nkeys,
- ScanKey skeys,
- bool isindex,
- ScanDirection dir,
- Snapshot snapshot)
-{
- Pointer scanDesc;
-
- /*
- * open the appropriate type of scan.
- *
- * Note: ambeginscan()'s second arg is a boolean indicating that the scan
- * should be done in reverse.. That is, if you pass it true, then the
- * scan is backward.
- */
- if (isindex)
- {
- scanDesc = (Pointer) index_beginscan(relation,
- false, /* see above comment */
- nkeys,
- skeys);
- }
- else
- {
- scanDesc = (Pointer) heap_beginscan(relation,
- ScanDirectionIsBackward(dir),
- snapshot,
- nkeys,
- skeys);
- }
-
- if (scanDesc == NULL)
- elog(DEBUG, "ExecBeginScan: scanDesc = NULL, heap_beginscan failed.");
-
- return scanDesc;
-}
-
-/* ----------------------------------------------------------------
- * ExecCloseR
- *
- * closes the relation and scan descriptor for a scan node.
- * Also closes index relations and scans for index scans.
- * ----------------------------------------------------------------
- */
-void
-ExecCloseR(Plan *node)
-{
- CommonScanState *state;
- Relation relation;
- HeapScanDesc scanDesc;
-
- /*
- * get state for node and shut down the heap scan, if any
- */
- switch (nodeTag(node))
- {
- case T_SeqScan:
- state = ((SeqScan *) node)->scanstate;
- break;
-
- case T_IndexScan:
- state = ((IndexScan *) node)->scan.scanstate;
- break;
-
- case T_TidScan:
- state = ((TidScan *) node)->scan.scanstate;
- break;
-
- default:
- elog(DEBUG, "ExecCloseR: not a scan node!");
- return;
- }
-
- relation = state->css_currentRelation;
- scanDesc = state->css_currentScanDesc;
-
- if (scanDesc != NULL)
- heap_endscan(scanDesc);
-
- /*
- * if this is an index scan then we have to take care of the index
- * relations as well.
- */
- if (IsA(node, IndexScan))
- {
- IndexScan *iscan = (IndexScan *) node;
- IndexScanState *indexstate = iscan->indxstate;
- int numIndices;
- RelationPtr indexRelationDescs;
- IndexScanDescPtr indexScanDescs;
- int i;
-
- numIndices = indexstate->iss_NumIndices;
- indexRelationDescs = indexstate->iss_RelationDescs;
- indexScanDescs = indexstate->iss_ScanDescs;
-
- for (i = 0; i < numIndices; i++)
- {
- /*
- * shut down each of the index scans and close each of the
- * index relations
- */
- if (indexScanDescs[i] != NULL)
- index_endscan(indexScanDescs[i]);
-
- if (indexRelationDescs[i] != NULL)
- index_close(indexRelationDescs[i]);
- }
- }
-
- /*
- * Finally, close the heap relation.
- *
- * Currently, we do not release the AccessShareLock acquired by
- * ExecOpenScanR. This lock should be held till end of transaction.
- * (There is a faction that considers this too much locking, however.)
- */
- if (relation != NULL)
- heap_close(relation, NoLock);
-}
/* ----------------------------------------------------------------
* ExecReScan
@@ -375,27 +166,6 @@ ExecReScan(Plan *node, ExprContext *exprCtxt, Plan *parent)
}
/* ----------------------------------------------------------------
- * ExecReScanR
- *
- * XXX this does not do the right thing with indices yet.
- * ----------------------------------------------------------------
- */
-HeapScanDesc
-ExecReScanR(Relation relDesc, /* LLL relDesc unused */
- HeapScanDesc scanDesc,
- ScanDirection direction,
- int nkeys, /* LLL nkeys unused */
- ScanKey skeys)
-{
- if (scanDesc != NULL)
- heap_rescan(scanDesc, /* scan desc */
- ScanDirectionIsBackward(direction), /* backward flag */
- skeys); /* scan keys */
-
- return scanDesc;
-}
-
-/* ----------------------------------------------------------------
* ExecMarkPos
*
* Marks the current scan position.