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

Commitdf9c8e1

Browse files
committed
Make RelationForgetRelation error out if the relcache entry has nonzero
reference count. This avoids leaving dangling pointers around, as inrecent bug report against sequences (bug# 671).
1 parent0352e3a commitdf9c8e1

File tree

1 file changed

+29
-25
lines changed

1 file changed

+29
-25
lines changed

‎src/backend/utils/cache/relcache.c

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.163 2002/04/27 21:24:34 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.164 2002/05/22 15:57:40 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1841,35 +1841,39 @@ RelationForgetRelation(Oid rid)
18411841

18421842
RelationIdCacheLookup(rid,relation);
18431843

1844-
if (PointerIsValid(relation))
1844+
if (!PointerIsValid(relation))
1845+
return;/* not in cache, nothing to do */
1846+
1847+
if (!RelationHasReferenceCountZero(relation))
1848+
elog(ERROR,"RelationForgetRelation: relation %u is still open",rid);
1849+
1850+
/* If local, remove from list */
1851+
if (relation->rd_myxactonly)
18451852
{
1846-
if (relation->rd_myxactonly)
1847-
{
1848-
List*curr;
1849-
List*prev=NIL;
1853+
List*curr;
1854+
List*prev=NIL;
18501855

1851-
foreach(curr,newlyCreatedRelns)
1852-
{
1853-
Relationreln=lfirst(curr);
1856+
foreach(curr,newlyCreatedRelns)
1857+
{
1858+
Relationreln=lfirst(curr);
18541859

1855-
Assert(reln!=NULL&&reln->rd_myxactonly);
1856-
if (RelationGetRelid(reln)==rid)
1857-
break;
1858-
prev=curr;
1859-
}
1860-
if (curr==NIL)
1861-
elog(FATAL,"Local relation %s not found in list",
1862-
RelationGetRelationName(relation));
1863-
if (prev==NIL)
1864-
newlyCreatedRelns=lnext(newlyCreatedRelns);
1865-
else
1866-
lnext(prev)=lnext(curr);
1867-
pfree(curr);
1860+
Assert(reln!=NULL&&reln->rd_myxactonly);
1861+
if (RelationGetRelid(reln)==rid)
1862+
break;
1863+
prev=curr;
18681864
}
1869-
1870-
/* Unconditionally destroy the relcache entry */
1871-
RelationClearRelation(relation, false);
1865+
if (curr==NIL)
1866+
elog(ERROR,"Local relation %s not found in list",
1867+
RelationGetRelationName(relation));
1868+
if (prev==NIL)
1869+
newlyCreatedRelns=lnext(newlyCreatedRelns);
1870+
else
1871+
lnext(prev)=lnext(curr);
1872+
pfree(curr);
18721873
}
1874+
1875+
/* Unconditionally destroy the relcache entry */
1876+
RelationClearRelation(relation, false);
18731877
}
18741878

18751879
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp