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

Commit40055db

Browse files
committed
Repair relation refcount leakage caused by SELECT FOR UPDATE.
1 parent31a8996 commit40055db

File tree

1 file changed

+26
-15
lines changed

1 file changed

+26
-15
lines changed

‎src/backend/executor/execMain.c

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
*
2828
*
2929
* IDENTIFICATION
30-
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.107 2000/01/26 05:56:21 momjian Exp $
30+
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.108 2000/02/03 00:02:58 tgl Exp $
3131
*
3232
*-------------------------------------------------------------------------
3333
*/
@@ -596,19 +596,19 @@ InitPlan(CmdType operation, Query *parseTree, Plan *plan, EState *estate)
596596
estate->es_rowMark=NULL;
597597
if (parseTree->rowMark!=NULL)
598598
{
599-
Relationrelation;
600-
Oidrelid;
601-
RowMark*rm;
602599
List*l;
603-
execRowMark*erm;
604600

605601
foreach(l,parseTree->rowMark)
606602
{
607-
rm=lfirst(l);
608-
relid=rt_fetch(rm->rti,rangeTable)->relid;
609-
relation=heap_open(relid,RowShareLock);
603+
RowMark*rm=lfirst(l);
604+
Oidrelid;
605+
Relationrelation;
606+
execRowMark*erm;
607+
610608
if (!(rm->info&ROW_MARK_FOR_UPDATE))
611609
continue;
610+
relid=rt_fetch(rm->rti,rangeTable)->relid;
611+
relation=heap_open(relid,RowShareLock);
612612
erm= (execRowMark*)palloc(sizeof(execRowMark));
613613
erm->relation=relation;
614614
erm->rti=rm->rti;
@@ -756,6 +756,7 @@ EndPlan(Plan *plan, EState *estate)
756756
{
757757
RelationInfo*resultRelationInfo;
758758
RelationintoRelationDesc;
759+
List*l;
759760

760761
/*
761762
* get information from state
@@ -796,10 +797,20 @@ EndPlan(Plan *plan, EState *estate)
796797
}
797798

798799
/*
799-
* close the "into" relation if necessary
800+
* close the "into" relation if necessary, again keeping lock
800801
*/
801802
if (intoRelationDesc!=NULL)
802803
heap_close(intoRelationDesc,NoLock);
804+
805+
/*
806+
* close any relations selected FOR UPDATE, again keeping locks
807+
*/
808+
foreach(l,estate->es_rowMark)
809+
{
810+
execRowMark*erm=lfirst(l);
811+
812+
heap_close(erm->relation,NoLock);
813+
}
803814
}
804815

805816
/* ----------------------------------------------------------------
@@ -926,16 +937,16 @@ lnext:;
926937
elseif (estate->es_rowMark!=NULL)
927938
{
928939
List*l;
929-
execRowMark*erm;
930-
Bufferbuffer;
931-
HeapTupleDatatuple;
932-
TupleTableSlot*newSlot;
933-
inttest;
934940

935941
lmark:;
936942
foreach(l,estate->es_rowMark)
937943
{
938-
erm=lfirst(l);
944+
execRowMark*erm=lfirst(l);
945+
Bufferbuffer;
946+
HeapTupleDatatuple;
947+
TupleTableSlot*newSlot;
948+
inttest;
949+
939950
if (!ExecGetJunkAttribute(junkfilter,
940951
slot,
941952
erm->resname,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp