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

Commitec41b8e

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 parent316186f commitec41b8e

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
@@ -1240,11 +1240,14 @@ shdepDropOwned(List *roleids, DropBehavior behavior)
12401240
sdepForm->objid);
12411241
break;
12421242
caseSHARED_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)

[8]ページ先頭

©2009-2025 Movatter.jp