diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2015-03-24 15:53:06 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2015-03-24 15:53:06 -0400 |
commit | feeb526cfe33657b8aa8b0cdd45b2ef0d9898877 (patch) | |
tree | 390ae233486a9b35a49c8991abb7ebe8ec092abc /src/backend/executor/execMain.c | |
parent | e5f455f59fed0632371cddacddd79895b148dc07 (diff) | |
download | postgresql-feeb526cfe33657b8aa8b0cdd45b2ef0d9898877.tar.gz postgresql-feeb526cfe33657b8aa8b0cdd45b2ef0d9898877.zip |
Fix ExecOpenScanRelation to take a lock on a ROW_MARK_COPY relation.
ExecOpenScanRelation assumed that any relation listed in the ExecRowMark
list has been locked by InitPlan; but this is not true if the rel's
markType is ROW_MARK_COPY, which is possible if it's a foreign table.
In most (possibly all) cases, failure to acquire a lock here isn't really
problematic because the parser, planner, or plancache would have taken the
appropriate lock already. In principle though it might leave us vulnerable
to working with a relation that we hold no lock on, and in any case if the
executor isn't depending on previously-taken locks otherwise then it should
not do so for ROW_MARK_COPY relations.
Noted by Etsuro Fujita. Back-patch to all active versions, since the
inconsistency has been there a long time. (It's almost certainly
irrelevant in 9.0, since that predates foreign tables, but the code's
still wrong on its own terms.)
Diffstat (limited to 'src/backend/executor/execMain.c')
-rw-r--r-- | src/backend/executor/execMain.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c index ad7e2072908..90d37b566ae 100644 --- a/src/backend/executor/execMain.c +++ b/src/backend/executor/execMain.c @@ -817,6 +817,10 @@ InitPlan(QueryDesc *queryDesc, int eflags) /* get relation's OID (will produce InvalidOid if subquery) */ relid = getrelid(rc->rti, rangeTable); + /* + * 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: |