mirror of
https://github.com/postgres/postgres.git
synced 2025-05-20 00:03:14 -04:00
Make RelationForgetRelation error out if the relcache entry has nonzero
reference count. This avoids leaving dangling pointers around, as in recent bug report against sequences (bug# 671).
This commit is contained in:
parent
0352e3a783
commit
df9c8e1a39
14
src/backend/utils/cache/relcache.c
vendored
14
src/backend/utils/cache/relcache.c
vendored
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.163 2002/04/27 21:24:34 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.164 2002/05/22 15:57:40 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -1841,8 +1841,13 @@ RelationForgetRelation(Oid rid)
|
|||||||
|
|
||||||
RelationIdCacheLookup(rid, relation);
|
RelationIdCacheLookup(rid, relation);
|
||||||
|
|
||||||
if (PointerIsValid(relation))
|
if (!PointerIsValid(relation))
|
||||||
{
|
return; /* not in cache, nothing to do */
|
||||||
|
|
||||||
|
if (!RelationHasReferenceCountZero(relation))
|
||||||
|
elog(ERROR, "RelationForgetRelation: relation %u is still open", rid);
|
||||||
|
|
||||||
|
/* If local, remove from list */
|
||||||
if (relation->rd_myxactonly)
|
if (relation->rd_myxactonly)
|
||||||
{
|
{
|
||||||
List *curr;
|
List *curr;
|
||||||
@ -1858,7 +1863,7 @@ RelationForgetRelation(Oid rid)
|
|||||||
prev = curr;
|
prev = curr;
|
||||||
}
|
}
|
||||||
if (curr == NIL)
|
if (curr == NIL)
|
||||||
elog(FATAL, "Local relation %s not found in list",
|
elog(ERROR, "Local relation %s not found in list",
|
||||||
RelationGetRelationName(relation));
|
RelationGetRelationName(relation));
|
||||||
if (prev == NIL)
|
if (prev == NIL)
|
||||||
newlyCreatedRelns = lnext(newlyCreatedRelns);
|
newlyCreatedRelns = lnext(newlyCreatedRelns);
|
||||||
@ -1870,7 +1875,6 @@ RelationForgetRelation(Oid rid)
|
|||||||
/* Unconditionally destroy the relcache entry */
|
/* Unconditionally destroy the relcache entry */
|
||||||
RelationClearRelation(relation, false);
|
RelationClearRelation(relation, false);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* RelationIdInvalidateRelationCacheByRelationId
|
* RelationIdInvalidateRelationCacheByRelationId
|
||||||
|
Loading…
x
Reference in New Issue
Block a user