]> granicus.if.org Git - postgresql/commitdiff
Don't try to use a unopened relation
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Wed, 7 Nov 2012 19:23:39 +0000 (16:23 -0300)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Wed, 7 Nov 2012 19:23:39 +0000 (16:23 -0300)
Commit 4c9d0901 mistakenly introduced a call to
TransferPredicateLocksToHeapRelation() on an index relation that had
been closed a few lines above.  Moving up an index_open() call that's
below is enough to fix the problem.

Discovered by me while testing an unrelated patch.

src/backend/catalog/index.c

index 756f6d918b00d8ec909229ae2e8b4a8cc210e2ff..d2d91c1b786e3247ba3b289830e19896e4ea6a64 100644 (file)
@@ -1475,6 +1475,8 @@ index_drop(Oid indexId, bool concurrent)
                 * conflicts with existing predicate locks, so now is the time to move
                 * them to the heap relation.
                 */
+               userHeapRelation = heap_open(heapId, ShareUpdateExclusiveLock);
+               userIndexRelation = index_open(indexId, ShareUpdateExclusiveLock);
                TransferPredicateLocksToHeapRelation(userIndexRelation);
 
                /*
@@ -1484,9 +1486,6 @@ index_drop(Oid indexId, bool concurrent)
                 */
                indexRelation = heap_open(IndexRelationId, RowExclusiveLock);
 
-               userHeapRelation = heap_open(heapId, ShareUpdateExclusiveLock);
-               userIndexRelation = index_open(indexId, ShareUpdateExclusiveLock);
-
                tuple = SearchSysCacheCopy1(INDEXRELID,
                                                                        ObjectIdGetDatum(indexId));
                if (!HeapTupleIsValid(tuple))