diff --git a/doc/src/sgml/ref/reassign_owned.sgml b/doc/src/sgml/ref/reassign_owned.sgml index 57f2e59996c..0d6b1787e29 100644 --- a/doc/src/sgml/ref/reassign_owned.sgml +++ b/doc/src/sgml/ref/reassign_owned.sgml @@ -30,7 +30,7 @@ REASSIGN OWNED BY old_role [, ...] REASSIGN OWNED 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. @@ -43,8 +43,9 @@ REASSIGN OWNED BY old_role [, ...] old_role - The name of a role. The ownership of all the objects in the - current database owned by this role will be reassigned to + The name of a role. The ownership of all the objects within the + current database, and of all shared objects (databases, tablespaces), + owned by this role will be reassigned to new_role. @@ -68,7 +69,7 @@ REASSIGN OWNED BY old_role [, ...] REASSIGN OWNED is often used to prepare for the removal of one or more roles. Because REASSIGN - OWNED only affects the objects in the current database, + OWNED does not affect objects within other databases, it is usually necessary to execute this command in each database that contains objects owned by a role that is to be removed. @@ -92,12 +93,6 @@ REASSIGN OWNED BY old_role [, ...] privileges. - - The REASSIGN OWNED command does not affect the - ownership of any databases owned by the role. Use - to reassign that ownership. - - diff --git a/src/backend/catalog/pg_shdepend.c b/src/backend/catalog/pg_shdepend.c index 4a85438ff5e..e411372fec2 100644 --- a/src/backend/catalog/pg_shdepend.c +++ b/src/backend/catalog/pg_shdepend.c @@ -1325,8 +1325,12 @@ shdepReassignOwned(List *roleids, Oid newrole) { 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; /* Unexpected because we checked for pins above */ @@ -1388,6 +1392,8 @@ shdepReassignOwned(List *roleids, Oid newrole) case OperatorFamilyRelationId: case OperatorClassRelationId: case ExtensionRelationId: + case TableSpaceRelationId: + case DatabaseRelationId: { Oid classId = sdepForm->classid; Relation catalog;