fix-drop-index-concurrently.patch

text/plain

Filename: fix-drop-index-concurrently.patch
Type: text/plain
Part: 0
Message: crash in DROP INDEX CONCURRENTLY

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: unified
File+
src/backend/catalog/index.c 2 3
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index 756f6d9..d2d91c1 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -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))