diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 11370c65906..1faaaf625d9 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -896,13 +896,11 @@ DefineIndex(Oid relationId, memcpy(part_oids, partdesc->oids, sizeof(Oid) * nparts); - parentDesc = CreateTupleDescCopy(RelationGetDescr(rel)); + parentDesc = RelationGetDescr(rel); opfamOids = palloc(sizeof(Oid) * numberOfKeyAttributes); for (i = 0; i < numberOfKeyAttributes; i++) opfamOids[i] = get_opclass_family(classObjectId[i]); - heap_close(rel, NoLock); - /* * For each partition, scan all existing indexes; if one matches * our index definition and is not already attached to some other @@ -1100,13 +1098,12 @@ DefineIndex(Oid relationId, heap_freetuple(newtup); } } - else - heap_close(rel, NoLock); /* * Indexes on partitioned tables are not themselves built, so we're * done here. */ + heap_close(rel, NoLock); return address; }