1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-30 21:42:05 +03:00

Adjust scan plan nodes to avoid getting an extra AccessShareLock on a

relation if it's already been locked by execMain.c as either a result
relation or a FOR UPDATE/SHARE relation.  This avoids an extra trip to
the shared lock manager state.  Per my suggestion yesterday.
This commit is contained in:
Tom Lane
2005-12-02 20:03:42 +00:00
parent 5ab2598875
commit d780f07ac1
9 changed files with 135 additions and 92 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/nodeSeqscan.c,v 1.55 2005/11/25 04:24:48 tgl Exp $
* $PostgreSQL: pgsql/src/backend/executor/nodeSeqscan.c,v 1.56 2005/12/02 20:03:40 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -141,25 +141,15 @@ ExecSeqScan(SeqScanState *node)
static void
InitScanRelation(SeqScanState *node, EState *estate)
{
Index relid;
List *rangeTable;
RangeTblEntry *rtentry;
Oid reloid;
Relation currentRelation;
HeapScanDesc currentScanDesc;
/*
* get the relation object id from the relid'th entry in the range table,
* open that relation and initialize the scan state.
*
* We acquire AccessShareLock for the duration of the scan.
* open that relation and acquire appropriate lock on it.
*/
relid = ((SeqScan *) node->ps.plan)->scanrelid;
rangeTable = estate->es_range_table;
rtentry = rt_fetch(relid, rangeTable);
reloid = rtentry->relid;
currentRelation = heap_open(reloid, AccessShareLock);
currentRelation = ExecOpenScanRelation(estate,
((SeqScan *) node->ps.plan)->scanrelid);
currentScanDesc = heap_beginscan(currentRelation,
estate->es_snapshot,
@ -281,12 +271,8 @@ ExecEndSeqScan(SeqScanState *node)
/*
* close the heap relation.
*
* Currently, we do not release the AccessShareLock acquired by
* InitScanRelation. This lock should be held till end of transaction.
* (There is a faction that considers this too much locking, however.)
*/
heap_close(relation, NoLock);
ExecCloseScanRelation(relation);
}
/* ----------------------------------------------------------------