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

Commit85abf1d

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 parentde51042 commit85abf1d

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ DROP OWNED BY <replaceable class="PARAMETER">name</replaceable> [, ...] [ CASCAD
2828
<title>Description</title>
2929

3030
<para>
31-
<command>DROP OWNED</command> drops all the objectsin the current
31+
<command>DROP OWNED</command> drops all the objectswithin the current
3232
database that are owned by one of the specified roles. Any
3333
privileges granted to the given roles on objects in the current
34-
database will also be revoked.
34+
database and on shared objects (databases, tablespaces) will also be
35+
revoked.
3536
</para>
3637
</refsect1>
3738

@@ -91,6 +92,10 @@ DROP OWNED BY <replaceable class="PARAMETER">name</replaceable> [, ...] [ CASCAD
9192
reassigns the ownership of all the database objects owned by one or
9293
more roles.
9394
</para>
95+
96+
<para>
97+
Databases and tablespaces owned by the role(s) will not be removed.
98+
</para>
9499
</refsect1>
95100

96101
<refsect1>

‎src/backend/catalog/pg_shdepend.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,11 +1221,14 @@ shdepDropOwned(List *roleids, DropBehavior behavior)
12211221
ExecGrantStmt_oids(&istmt);
12221222
break;
12231223
caseSHARED_DEPENDENCY_OWNER:
1224-
/* Save it for deletion below */
1225-
obj.classId=sdepForm->classid;
1226-
obj.objectId=sdepForm->objid;
1227-
obj.objectSubId=0;
1228-
add_exact_object_address(&obj,deleteobjs);
1224+
/* If a local object, save it for deletion below */
1225+
if (sdepForm->dbid==MyDatabaseId)
1226+
{
1227+
obj.classId=sdepForm->classid;
1228+
obj.objectId=sdepForm->objid;
1229+
obj.objectSubId=0;
1230+
add_exact_object_address(&obj,deleteobjs);
1231+
}
12291232
break;
12301233
}
12311234
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp