Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfeeb526

Browse files
committed
Fix ExecOpenScanRelation to take a lock on a ROW_MARK_COPY relation.
ExecOpenScanRelation assumed that any relation listed in the ExecRowMarklist has been locked by InitPlan; but this is not true if the rel'smarkType 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 reallyproblematic because the parser, planner, or plancache would have taken theappropriate lock already. In principle though it might leave us vulnerableto working with a relation that we hold no lock on, and in any case if theexecutor isn't depending on previously-taken locks otherwise then it shouldnot do so for ROW_MARK_COPY relations.Noted by Etsuro Fujita. Back-patch to all active versions, since theinconsistency has been there a long time. (It's almost certainlyirrelevant in 9.0, since that predates foreign tables, but the code'sstill wrong on its own terms.)
1 parente5f455f commitfeeb526

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

‎src/backend/executor/execMain.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,10 @@ InitPlan(QueryDesc *queryDesc, int eflags)
817817
/* get relation's OID (will produce InvalidOid if subquery) */
818818
relid=getrelid(rc->rti,rangeTable);
819819

820+
/*
821+
* If you change the conditions under which rel locks are acquired
822+
* here, be sure to adjust ExecOpenScanRelation to match.
823+
*/
820824
switch (rc->markType)
821825
{
822826
caseROW_MARK_EXCLUSIVE:

‎src/backend/executor/execUtils.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,9 @@ ExecOpenScanRelation(EState *estate, Index scanrelid, int eflags)
820820
{
821821
ExecRowMark*erm=lfirst(l);
822822

823-
if (erm->rti==scanrelid)
823+
/* Keep this check in sync with InitPlan! */
824+
if (erm->rti==scanrelid&&
825+
erm->relation!=NULL)
824826
{
825827
lockmode=NoLock;
826828
break;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp