diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 5f54f66f591..87dec1909d8 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/indexcmds.c,v 1.149 2006/10/04 00:29:51 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/commands/indexcmds.c,v 1.149.2.1 2007/08/25 19:08:25 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -423,8 +423,6 @@ DefineIndex(RangeVar *heapRelation, relationId, accessMethodName, accessMethodId, isconstraint); - heap_close(rel, NoLock); - /* * Report index creation if appropriate (delay this till after most of the * error checks) @@ -436,6 +434,10 @@ DefineIndex(RangeVar *heapRelation, primary ? "PRIMARY KEY" : "UNIQUE", indexRelationName, RelationGetRelationName(rel)))); + /* save lockrelid for below, then close rel */ + heaprelid = rel->rd_lockInfo.lockRelId; + heap_close(rel, NoLock); + indexRelationId = index_create(relationId, indexRelationName, indexRelationId, indexInfo, accessMethodId, tablespaceId, classObjectId, @@ -463,7 +465,6 @@ DefineIndex(RangeVar *heapRelation, * because there are no operations that could change its state while we * hold lock on the parent table. This might need to change later. */ - heaprelid = rel->rd_lockInfo.lockRelId; LockRelationIdForSession(&heaprelid, ShareUpdateExclusiveLock); CommitTransactionCommand();