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.c60
1 files changed, 25 insertions, 35 deletions
diff --git a/src/backend/executor/execAmi.c b/src/backend/executor/execAmi.c
index 40a94fd02c8..9c1b7b8bb41 100644
--- a/src/backend/executor/execAmi.c
+++ b/src/backend/executor/execAmi.c
@@ -1,11 +1,11 @@
/*-------------------------------------------------------------------------
*
* execAmi.c
- * miscellanious executor access method routines
+ * miscellaneous executor access method routines
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: execAmi.c,v 1.41 1999/07/17 20:16:56 momjian Exp $
+ * $Id: execAmi.c,v 1.42 1999/09/18 19:06:47 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -52,7 +52,6 @@
static Pointer ExecBeginScan(Relation relation, int nkeys, ScanKey skeys,
bool isindex, ScanDirection dir, Snapshot snapshot);
-static Relation ExecOpenR(Oid relationOid, bool isindex);
/* ----------------------------------------------------------------
* ExecOpenScanR
@@ -90,47 +89,33 @@ ExecOpenScanR(Oid relOid,
* abstraction someday -cim 9/9/89
* ----------------
*/
- relation = ExecOpenR(relOid, isindex);
- scanDesc = ExecBeginScan(relation,
- nkeys,
- skeys,
- isindex,
- dir,
- snapshot);
-
- if (returnRelation != NULL)
- *returnRelation = relation;
- if (scanDesc != NULL)
- *returnScanDesc = scanDesc;
-}
-
-/* ----------------------------------------------------------------
- * ExecOpenR
- *
- * returns a relation descriptor given an object id.
- * ----------------------------------------------------------------
- */
-static Relation
-ExecOpenR(Oid relationOid, bool isindex)
-{
- Relation relation;
-
- relation = (Relation) NULL;
/* ----------------
* open the relation with the correct call depending
* on whether this is a heap relation or an index relation.
+ *
+ * Do not lock the rel here; beginscan will acquire AccessShareLock.
* ----------------
*/
if (isindex)
- relation = index_open(relationOid);
+ relation = index_open(relOid);
else
- relation = heap_open(relationOid);
+ relation = heap_open(relOid, NoLock);
if (relation == NULL)
- elog(DEBUG, "ExecOpenR: relation == NULL, heap_open failed.");
+ elog(ERROR, "ExecOpenScanR: failed to open relation %u", relOid);
+
+ scanDesc = ExecBeginScan(relation,
+ nkeys,
+ skeys,
+ isindex,
+ dir,
+ snapshot);
- return relation;
+ if (returnRelation != NULL)
+ *returnRelation = relation;
+ if (scanDesc != NULL)
+ *returnScanDesc = scanDesc;
}
/* ----------------------------------------------------------------
@@ -243,15 +228,20 @@ ExecCloseR(Plan *node)
if (scanDesc != NULL)
heap_endscan(scanDesc);
+ /*
+ * endscan released AccessShareLock acquired by beginscan. If we are
+ * holding any stronger locks on the rel, they should be held till end of
+ * xact. Therefore, we need only close the rel and not release locks.
+ */
if (relation != NULL)
- heap_close(relation);
+ heap_close(relation, NoLock);
/* ----------------
* if this is an index scan then we have to take care
* of the index relations as well..
* ----------------
*/
- if (nodeTag(node) == T_IndexScan)
+ if (IsA(node, IndexScan))
{
IndexScan *iscan = (IndexScan *) node;
IndexScanState *indexstate;