Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit ed845c7

Browse files
committed
Fix relcache refcount leakage when inv_drop is applied
to a non-LO relation.
1 parent f0a2fc3 commit ed845c7

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/backend/storage/large_object/inv_api.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.65 2000/01/26 05:56:59 momjian Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.66 2000/04/08 04:37:07 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -278,10 +278,20 @@ inv_drop(Oid lobjId)
278278
{
279279
Relation r;
280280

281-
r = (Relation) RelationIdGetRelation(lobjId);
282-
if (!RelationIsValid(r) || r->rd_rel->relkind != RELKIND_LOBJECT)
281+
r = RelationIdGetRelation(lobjId);
282+
if (!RelationIsValid(r))
283283
return -1;
284284

285+
if (r->rd_rel->relkind != RELKIND_LOBJECT)
286+
{
287+
/* drop relcache refcount from RelationIdGetRelation */
288+
RelationDecrementReferenceCount(r);
289+
return -1;
290+
}
291+
292+
/* Since heap_drop_with_catalog will destroy the relcache entry,
293+
* there's no need to drop the refcount in this path.
294+
*/
285295
heap_drop_with_catalog(RelationGetRelationName(r));
286296
return 1;
287297
}

0 commit comments

Comments
 (0)