aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/execMain.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2018-10-02 14:43:01 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2018-10-02 14:43:09 -0400
commit6e35939febf83069430fedda6f89ab1fbe0f9e10 (patch)
tree7fcafdbda90ec0a6e3e788ab5a5f7252c7ebee47 /src/backend/executor/execMain.c
parentcc2905e963e950d01cd2cb6c860638ce9506c63d (diff)
downloadpostgresql-6e35939febf83069430fedda6f89ab1fbe0f9e10.tar.gz
postgresql-6e35939febf83069430fedda6f89ab1fbe0f9e10.zip
Change rewriter/planner/executor/plancache to depend on RTE rellockmode.
Instead of recomputing the required lock levels in all these places, just use what commit fdba460a2 made the parser store in the RTE fields. This already simplifies the code measurably in these places, and follow-on changes will remove a bunch of no-longer-needed infrastructure. In a few cases, this change causes us to acquire a higher lock level than we did before. This is OK primarily because said higher lock level should've been acquired already at query parse time; thus, we're saving a useless extra trip through the shared lock manager to acquire a lesser lock alongside the original lock. The only known exception to this is that re-execution of a previously planned SELECT FOR UPDATE/SHARE query, for a table that uses ROW_MARK_REFERENCE or ROW_MARK_COPY methods, might have gotten only AccessShareLock before. Now it will get RowShareLock like the first execution did, which seems fine. While there's more to do, push it in this state anyway, to let the buildfarm help verify that nothing bad happened. Amit Langote, reviewed by David Rowley and Jesper Pedersen, and whacked around a bit more by me Discussion: https://postgr.es/m/468c85d9-540e-66a2-1dde-fec2b741e688@lab.ntt.co.jp
Diffstat (limited to 'src/backend/executor/execMain.c')
-rw-r--r--src/backend/executor/execMain.c14
1 files changed, 2 insertions, 12 deletions
diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c
index c28750e0753..c865032a80f 100644
--- a/src/backend/executor/execMain.c
+++ b/src/backend/executor/execMain.c
@@ -970,26 +970,16 @@ InitPlan(QueryDesc *queryDesc, int eflags)
/* get relation's OID (will produce InvalidOid if subquery) */
relid = getrelid(rc->rti, rangeTable);
- rellockmode = rt_fetch(rc->rti, rangeTable)->rellockmode;
- /*
- * If you change the conditions under which rel locks are acquired
- * here, be sure to adjust ExecOpenScanRelation to match.
- */
switch (rc->markType)
{
case ROW_MARK_EXCLUSIVE:
case ROW_MARK_NOKEYEXCLUSIVE:
case ROW_MARK_SHARE:
case ROW_MARK_KEYSHARE:
- Assert(rellockmode == RowShareLock);
- relation = heap_open(relid, RowShareLock);
- break;
case ROW_MARK_REFERENCE:
- /* RTE might be a query target table */
- Assert(rellockmode == AccessShareLock ||
- rellockmode == RowExclusiveLock);
- relation = heap_open(relid, AccessShareLock);
+ rellockmode = rt_fetch(rc->rti, rangeTable)->rellockmode;
+ relation = heap_open(relid, rellockmode);
break;
case ROW_MARK_COPY:
/* no physical table access is required */