closing heap relation
| От | Zhihong Yu | 
|---|---|
| Тема | closing heap relation | 
| Дата | |
| Msg-id | CALNJ-vT3V90Dk9XrTuDVsCgXKaoaBABKbfw9hhxzW717xpHz1Q@mail.gmail.com обсуждение исходный текст | 
| Ответы | Re: closing heap relation | 
| Список | pgsql-hackers | 
Hi,
		
	I was looking at index_drop() in PG 11 branch.
In if (concurrent)block, the heap and index relations are overwritten since they were opened a few lines above the concurrent check.
Shouldn't the two relations be closed first ?
thanks
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index 9d8f873944..625b72ae85 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -1641,6 +1641,9 @@ index_drop(Oid indexId, bool concurrent)
* conflicts with existing predicate locks, so now is the time to move
* them to the heap relation.
*/
+ heap_close(userHeapRelation, NoLock);
+ index_close(userIndexRelation, NoLock);
+
userHeapRelation = heap_open(heapId, ShareUpdateExclusiveLock);
userIndexRelation = index_open(indexId, ShareUpdateExclusiveLock);
TransferPredicateLocksToHeapRelation(userIndexRelation);
index 9d8f873944..625b72ae85 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -1641,6 +1641,9 @@ index_drop(Oid indexId, bool concurrent)
* conflicts with existing predicate locks, so now is the time to move
* them to the heap relation.
*/
+ heap_close(userHeapRelation, NoLock);
+ index_close(userIndexRelation, NoLock);
+
userHeapRelation = heap_open(heapId, ShareUpdateExclusiveLock);
userIndexRelation = index_open(indexId, ShareUpdateExclusiveLock);
TransferPredicateLocksToHeapRelation(userIndexRelation);
В списке pgsql-hackers по дате отправления: