mirror of
https://github.com/postgres/postgres.git
synced 2025-04-27 22:56:53 +03:00
REASSIGN OWNED: handle shared objects, too
Give away ownership of shared objects (databases, tablespaces) along with local objects, per original code intention. Try to make the documentation clearer, too. Per discussion about DROP OWNED's brokenness, in bug #7748. This is not backpatched because it'd require some refactoring of the ALTER/SET OWNER code for databases and tablespaces.
This commit is contained in:
parent
ec41b8edc1
commit
ee22c55f5a
@ -30,7 +30,7 @@ REASSIGN OWNED BY <replaceable class="PARAMETER">old_role</replaceable> [, ...]
|
|||||||
|
|
||||||
<para>
|
<para>
|
||||||
<command>REASSIGN OWNED</command> instructs the system to change
|
<command>REASSIGN OWNED</command> instructs the system to change
|
||||||
the ownership of the database objects owned by one of the
|
the ownership of database objects owned by one of the
|
||||||
old_roles, to new_role.
|
old_roles, to new_role.
|
||||||
</para>
|
</para>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
@ -43,8 +43,9 @@ REASSIGN OWNED BY <replaceable class="PARAMETER">old_role</replaceable> [, ...]
|
|||||||
<term><replaceable class="PARAMETER">old_role</replaceable></term>
|
<term><replaceable class="PARAMETER">old_role</replaceable></term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
The name of a role. The ownership of all the objects in the
|
The name of a role. The ownership of all the objects within the
|
||||||
current database owned by this role will be reassigned to
|
current database, and of all shared objects (databases, tablespaces),
|
||||||
|
owned by this role will be reassigned to
|
||||||
<replaceable class="PARAMETER">new_role</replaceable>.
|
<replaceable class="PARAMETER">new_role</replaceable>.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
@ -68,7 +69,7 @@ REASSIGN OWNED BY <replaceable class="PARAMETER">old_role</replaceable> [, ...]
|
|||||||
<para>
|
<para>
|
||||||
<command>REASSIGN OWNED</command> is often used to prepare for the
|
<command>REASSIGN OWNED</command> is often used to prepare for the
|
||||||
removal of one or more roles. Because <command>REASSIGN
|
removal of one or more roles. Because <command>REASSIGN
|
||||||
OWNED</command> only affects the objects in the current database,
|
OWNED</command> does not affect objects within other databases,
|
||||||
it is usually necessary to execute this command in each database
|
it is usually necessary to execute this command in each database
|
||||||
that contains objects owned by a role that is to be removed.
|
that contains objects owned by a role that is to be removed.
|
||||||
</para>
|
</para>
|
||||||
@ -92,12 +93,6 @@ REASSIGN OWNED BY <replaceable class="PARAMETER">old_role</replaceable> [, ...]
|
|||||||
privileges.
|
privileges.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
|
||||||
The <command>REASSIGN OWNED</command> command does not affect the
|
|
||||||
ownership of any databases owned by the role. Use
|
|
||||||
<xref linkend="sql-alterdatabase"> to reassign that ownership.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
||||||
<refsect1>
|
<refsect1>
|
||||||
|
@ -1325,8 +1325,12 @@ shdepReassignOwned(List *roleids, Oid newrole)
|
|||||||
{
|
{
|
||||||
Form_pg_shdepend sdepForm = (Form_pg_shdepend) GETSTRUCT(tuple);
|
Form_pg_shdepend sdepForm = (Form_pg_shdepend) GETSTRUCT(tuple);
|
||||||
|
|
||||||
/* We only operate on objects in the current database */
|
/*
|
||||||
if (sdepForm->dbid != MyDatabaseId)
|
* We only operate on shared objects and objects in the current
|
||||||
|
* database
|
||||||
|
*/
|
||||||
|
if (sdepForm->dbid != MyDatabaseId &&
|
||||||
|
sdepForm->dbid != InvalidOid)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Unexpected because we checked for pins above */
|
/* Unexpected because we checked for pins above */
|
||||||
@ -1388,6 +1392,8 @@ shdepReassignOwned(List *roleids, Oid newrole)
|
|||||||
case OperatorFamilyRelationId:
|
case OperatorFamilyRelationId:
|
||||||
case OperatorClassRelationId:
|
case OperatorClassRelationId:
|
||||||
case ExtensionRelationId:
|
case ExtensionRelationId:
|
||||||
|
case TableSpaceRelationId:
|
||||||
|
case DatabaseRelationId:
|
||||||
{
|
{
|
||||||
Oid classId = sdepForm->classid;
|
Oid classId = sdepForm->classid;
|
||||||
Relation catalog;
|
Relation catalog;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user