Commit 5377ccbe authored by Tom Lane's avatar Tom Lane

Update obsolete comment in index_drop(). When the comment was written,

queries frequently took no lock at all on individual indexes.  That's not
true any more, but we still need lock on the parent table to make it safe
to use cached lists of index OIDs.
parent fa88e92a
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/catalog/index.c,v 1.315 2009/03/31 22:12:46 tgl Exp $ * $PostgreSQL: pgsql/src/backend/catalog/index.c,v 1.316 2009/05/31 20:55:37 tgl Exp $
* *
* *
* INTERFACE ROUTINES * INTERFACE ROUTINES
...@@ -901,14 +901,13 @@ index_drop(Oid indexId) ...@@ -901,14 +901,13 @@ index_drop(Oid indexId)
/* /*
* To drop an index safely, we must grab exclusive lock on its parent * To drop an index safely, we must grab exclusive lock on its parent
* table; otherwise there could be other backends using the index! * table. Exclusive lock on the index alone is insufficient because
* Exclusive lock on the index alone is insufficient because another * another backend might be about to execute a query on the parent table.
* backend might be in the midst of devising a query plan that will use * If it relies on a previously cached list of index OIDs, then it could
* the index. The parser and planner take care to hold an appropriate * attempt to access the just-dropped index. We must therefore take a
* lock on the parent table while working, but having them hold locks on * table lock strong enough to prevent all queries on the table from
* all the indexes too seems overly expensive. We do grab exclusive lock * proceeding until we commit and send out a shared-cache-inval notice
* on the index too, just to be safe. Both locks must be held till end of * that will make them update their index lists.
* transaction, else other backends will still see this index in pg_index.
*/ */
heapId = IndexGetRelation(indexId); heapId = IndexGetRelation(indexId);
userHeapRelation = heap_open(heapId, AccessExclusiveLock); userHeapRelation = heap_open(heapId, AccessExclusiveLock);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment