Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit ec41b8e

Browse files
committed
DROP OWNED: don't try to drop tablespaces/databases
My "fix" for bugs #7578 and #6116 on DROP OWNED at fe3b5eb not only misstated that it applied to REASSIGN OWNED (which it did not affect), but it also failed to fix the problems fully, because I didn't test the case of owned shared objects. Thus I created a new bug, reported by Thomas Kellerer as #7748, which would cause DROP OWNED to fail with a not-for-user-consumption error message. The code would attempt to drop the database, which not only fails to work because the underlying code does not support that, but is a pretty dangerous and undesirable thing to be doing as well. This patch fixes that bug by having DROP OWNED only attempt to process shared objects when grants on them are found, ignoring ownership. Backpatch to 8.3, which is as far as the previous bug was backpatched.
1 parent 316186f commit ec41b8e

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

doc/src/sgml/ref/drop_owned.sgml

+4-3
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ DROP OWNED BY <replaceable class="PARAMETER">name</replaceable> [, ...] [ CASCAD
2929
<title>Description</title>
3030

3131
<para>
32-
<command>DROP OWNED</command> drops all the objects in the current
32+
<command>DROP OWNED</command> drops all the objects within the current
3333
database that are owned by one of the specified roles. Any
3434
privileges granted to the given roles on objects in the current
35-
database will also be revoked.
35+
database and on shared objects (databases, tablespaces) will also be
36+
revoked.
3637
</para>
3738
</refsect1>
3839

@@ -93,7 +94,7 @@ DROP OWNED BY <replaceable class="PARAMETER">name</replaceable> [, ...] [ CASCAD
9394
</para>
9495

9596
<para>
96-
Databases owned by the role(s) will not be removed.
97+
Databases and tablespaces owned by the role(s) will not be removed.
9798
</para>
9899
</refsect1>
99100

src/backend/catalog/pg_shdepend.c

+8-5
Original file line numberDiff line numberDiff line change
@@ -1240,11 +1240,14 @@ shdepDropOwned(List *roleids, DropBehavior behavior)
12401240
sdepForm->objid);
12411241
break;
12421242
case SHARED_DEPENDENCY_OWNER:
1243-
/* Save it for deletion below */
1244-
obj.classId = sdepForm->classid;
1245-
obj.objectId = sdepForm->objid;
1246-
obj.objectSubId = sdepForm->objsubid;
1247-
add_exact_object_address(&obj, deleteobjs);
1243+
/* If a local object, save it for deletion below */
1244+
if (sdepForm->dbid == MyDatabaseId)
1245+
{
1246+
obj.classId = sdepForm->classid;
1247+
obj.objectId = sdepForm->objid;
1248+
obj.objectSubId = sdepForm->objsubid;
1249+
add_exact_object_address(&obj, deleteobjs);
1250+
}
12481251
break;
12491252
}
12501253
}

0 commit comments

Comments
 (0)