8
8
*
9
9
*
10
10
* IDENTIFICATION
11
- * $PostgreSQL: pgsql/src/backend/catalog/pg_shdepend.c,v 1.22 2008/01/01 19:45:48 momjian Exp $
11
+ * $PostgreSQL: pgsql/src/backend/catalog/pg_shdepend.c,v 1.23 2008/01/23 15:36:38 alvherre Exp $
12
12
*
13
13
*-------------------------------------------------------------------------
14
14
*/
@@ -1110,7 +1110,12 @@ shdepDropOwned(List *roleids, DropBehavior behavior)
1110
1110
1111
1111
deleteobjs = new_object_addresses ();
1112
1112
1113
- sdepRel = heap_open (SharedDependRelationId , AccessExclusiveLock );
1113
+ /*
1114
+ * We don't need this strong a lock here, but we'll call routines that
1115
+ * acquire RowExclusiveLock. Better get that right now to avoid potential
1116
+ * deadlock failures.
1117
+ */
1118
+ sdepRel = heap_open (SharedDependRelationId , RowExclusiveLock );
1114
1119
1115
1120
/*
1116
1121
* For each role, find the dependent objects and drop them using the
@@ -1224,7 +1229,7 @@ shdepDropOwned(List *roleids, DropBehavior behavior)
1224
1229
/* the dependency mechanism does the actual work */
1225
1230
performMultipleDeletions (deleteobjs , behavior );
1226
1231
1227
- heap_close (sdepRel , AccessExclusiveLock );
1232
+ heap_close (sdepRel , RowExclusiveLock );
1228
1233
1229
1234
free_object_addresses (deleteobjs );
1230
1235
}
@@ -1241,7 +1246,12 @@ shdepReassignOwned(List *roleids, Oid newrole)
1241
1246
Relation sdepRel ;
1242
1247
ListCell * cell ;
1243
1248
1244
- sdepRel = heap_open (SharedDependRelationId , AccessShareLock );
1249
+ /*
1250
+ * We don't need this strong a lock here, but we'll call routines that
1251
+ * acquire RowExclusiveLock. Better get that right now to avoid potential
1252
+ * deadlock problems.
1253
+ */
1254
+ sdepRel = heap_open (SharedDependRelationId , RowExclusiveLock );
1245
1255
1246
1256
foreach (cell , roleids )
1247
1257
{
@@ -1343,5 +1353,5 @@ shdepReassignOwned(List *roleids, Oid newrole)
1343
1353
systable_endscan (scan );
1344
1354
}
1345
1355
1346
- heap_close (sdepRel , AccessShareLock );
1356
+ heap_close (sdepRel , RowExclusiveLock );
1347
1357
}
0 commit comments