Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8879c35

Browse files
committed
DROP OWNED: don't try to drop tablespaces/databases
My "fix" for bugs #7578 and #6116 on DROP OWNED atfe3b5eb not onlymisstated 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 thecase of owned shared objects. Thus I created a new bug, reported byThomas Kellerer as #7748, which would cause DROP OWNED to fail with anot-for-user-consumption error message. The code would attempt to dropthe database, which not only fails to work because the underlying codedoes not support that, but is a pretty dangerous and undesirable thingto be doing as well.This patch fixes that bug by having DROP OWNED only attempt to processshared objects when grants on them are found, ignoring ownership.Backpatch to 8.3, which is as far as the previous bug was backpatched.
1 parent2dde675 commit8879c35

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

‎doc/src/sgml/ref/drop_owned.sgml

Lines changed: 4 additions & 3 deletions
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 objectsin the current
32+
<command>DROP OWNED</command> drops all the objectswithin 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+
Databasesand tablespacesowned by the role(s) will not be removed.
9798
</para>
9899
</refsect1>
99100

‎src/backend/catalog/pg_shdepend.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,11 +1231,14 @@ shdepDropOwned(List *roleids, DropBehavior behavior)
12311231
sdepForm->objid);
12321232
break;
12331233
caseSHARED_DEPENDENCY_OWNER:
1234-
/* Save it for deletion below */
1235-
obj.classId=sdepForm->classid;
1236-
obj.objectId=sdepForm->objid;
1237-
obj.objectSubId=sdepForm->objsubid;
1238-
add_exact_object_address(&obj,deleteobjs);
1234+
/* If a local object, save it for deletion below */
1235+
if (sdepForm->dbid==MyDatabaseId)
1236+
{
1237+
obj.classId=sdepForm->classid;
1238+
obj.objectId=sdepForm->objid;
1239+
obj.objectSubId=sdepForm->objsubid;
1240+
add_exact_object_address(&obj,deleteobjs);
1241+
}
12391242
break;
12401243
}
12411244
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp