Improve lock level choices in pg_shdepend.c. Noticed by Tom Lane.
This commit is contained in:
parent
6a7a63d3a3
commit
8984c8bbe2
|
@ -8,7 +8,7 @@
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/catalog/pg_shdepend.c,v 1.22 2008/01/01 19:45:48 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/catalog/pg_shdepend.c,v 1.23 2008/01/23 15:36:38 alvherre Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -1110,7 +1110,12 @@ shdepDropOwned(List *roleids, DropBehavior behavior)
|
||||||
|
|
||||||
deleteobjs = new_object_addresses();
|
deleteobjs = new_object_addresses();
|
||||||
|
|
||||||
sdepRel = heap_open(SharedDependRelationId, AccessExclusiveLock);
|
/*
|
||||||
|
* We don't need this strong a lock here, but we'll call routines that
|
||||||
|
* acquire RowExclusiveLock. Better get that right now to avoid potential
|
||||||
|
* deadlock failures.
|
||||||
|
*/
|
||||||
|
sdepRel = heap_open(SharedDependRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* For each role, find the dependent objects and drop them using the
|
* For each role, find the dependent objects and drop them using the
|
||||||
|
@ -1224,7 +1229,7 @@ shdepDropOwned(List *roleids, DropBehavior behavior)
|
||||||
/* the dependency mechanism does the actual work */
|
/* the dependency mechanism does the actual work */
|
||||||
performMultipleDeletions(deleteobjs, behavior);
|
performMultipleDeletions(deleteobjs, behavior);
|
||||||
|
|
||||||
heap_close(sdepRel, AccessExclusiveLock);
|
heap_close(sdepRel, RowExclusiveLock);
|
||||||
|
|
||||||
free_object_addresses(deleteobjs);
|
free_object_addresses(deleteobjs);
|
||||||
}
|
}
|
||||||
|
@ -1241,7 +1246,12 @@ shdepReassignOwned(List *roleids, Oid newrole)
|
||||||
Relation sdepRel;
|
Relation sdepRel;
|
||||||
ListCell *cell;
|
ListCell *cell;
|
||||||
|
|
||||||
sdepRel = heap_open(SharedDependRelationId, AccessShareLock);
|
/*
|
||||||
|
* We don't need this strong a lock here, but we'll call routines that
|
||||||
|
* acquire RowExclusiveLock. Better get that right now to avoid potential
|
||||||
|
* deadlock problems.
|
||||||
|
*/
|
||||||
|
sdepRel = heap_open(SharedDependRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
foreach(cell, roleids)
|
foreach(cell, roleids)
|
||||||
{
|
{
|
||||||
|
@ -1343,5 +1353,5 @@ shdepReassignOwned(List *roleids, Oid newrole)
|
||||||
systable_endscan(scan);
|
systable_endscan(scan);
|
||||||
}
|
}
|
||||||
|
|
||||||
heap_close(sdepRel, AccessShareLock);
|
heap_close(sdepRel, RowExclusiveLock);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue