From 4677334cedf56383fd4f472f748de8d8d9f101d0 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 25 Jun 2005 16:54:12 +0000 Subject: [PATCH] Fix ancient memory leak in index_create(): RelationInitIndexAccessInfo was being called twice in normal operation, leading to a leak of one set of relcache subsidiary info. Per report from Jeff Gold. --- src/backend/catalog/index.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c index ccf52248260..9464b9a1fad 100644 --- a/src/backend/catalog/index.c +++ b/src/backend/catalog/index.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.219 2003/09/29 00:05:24 petere Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.219.2.1 2005/06/25 16:54:12 tgl Exp $ * * * INTERFACE ROUTINES @@ -707,13 +707,21 @@ index_create(Oid heapRelationId, } /* - * Fill in the index strategy structure with information from the - * catalogs. First we must advance the command counter so that we - * will see the newly-entered index catalog tuples. + * Advance the command counter so that we can see the newly-entered + * catalog tuples for the index. */ CommandCounterIncrement(); - RelationInitIndexAccessInfo(indexRelation); + /* + * In bootstrap mode, we have to fill in the index strategy structure + * with information from the catalogs. If we aren't bootstrapping, + * then the relcache entry has already been rebuilt thanks to sinval + * update during CommandCounterIncrement. + */ + if (IsBootstrapProcessingMode()) + RelationInitIndexAccessInfo(indexRelation); + else + Assert(indexRelation->rd_indexcxt != NULL); /* * If this is bootstrap (initdb) time, then we don't actually fill in -- 2.39.5