mirror of
https://github.com/postgres/postgres.git
synced 2025-04-24 10:47:04 +03:00
Slight refactor for ExecOpenScanRelation(): we can use
ExecRelationIsTargetRelation() to check if the relation is a target rel, rather than scanning through the result relation array ourselves.
This commit is contained in:
parent
dc6dc0f63a
commit
dffad02856
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/executor/execUtils.c,v 1.147 2007/02/27 01:11:25 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/executor/execUtils.c,v 1.148 2007/07/27 19:09:04 neilc Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -814,24 +814,16 @@ ExecOpenScanRelation(EState *estate, Index scanrelid)
|
|||||||
{
|
{
|
||||||
Oid reloid;
|
Oid reloid;
|
||||||
LOCKMODE lockmode;
|
LOCKMODE lockmode;
|
||||||
ResultRelInfo *resultRelInfos;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First determine the lock type we need. Scan to see if target relation
|
* Determine the lock type we need. First, scan to see if target
|
||||||
* is either a result relation or a FOR UPDATE/FOR SHARE relation.
|
* relation is a result relation.
|
||||||
*/
|
*/
|
||||||
lockmode = AccessShareLock;
|
lockmode = AccessShareLock;
|
||||||
resultRelInfos = estate->es_result_relations;
|
if (ExecRelationIsTargetRelation(estate, scanrelid))
|
||||||
for (i = 0; i < estate->es_num_result_relations; i++)
|
lockmode = NoLock;
|
||||||
{
|
|
||||||
if (resultRelInfos[i].ri_RangeTableIndex == scanrelid)
|
|
||||||
{
|
|
||||||
lockmode = NoLock;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/* If not, check if it's a FOR UPDATE/FOR SHARE relation */
|
||||||
if (lockmode == AccessShareLock)
|
if (lockmode == AccessShareLock)
|
||||||
{
|
{
|
||||||
ListCell *l;
|
ListCell *l;
|
||||||
@ -850,7 +842,6 @@ ExecOpenScanRelation(EState *estate, Index scanrelid)
|
|||||||
|
|
||||||
/* OK, open the relation and acquire lock as needed */
|
/* OK, open the relation and acquire lock as needed */
|
||||||
reloid = getrelid(scanrelid, estate->es_range_table);
|
reloid = getrelid(scanrelid, estate->es_range_table);
|
||||||
|
|
||||||
return heap_open(reloid, lockmode);
|
return heap_open(reloid, lockmode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user