postgresql/src/include/commands
Alvaro Herrera d07afa42db Rework internals of changing a type's ownership
This is necessary so that REASSIGN OWNED does the right thing with
composite types, to wit, that it also alters ownership of the type's
pg_class entry -- previously, the pg_class entry remained owned by the
original user, which caused later other failures such as the new owner's
inability to use ALTER TYPE to rename an attribute of the affected
composite.  Also, if the original owner is later dropped, the pg_class
entry becomes owned by a non-existant user which is bogus.

To fix, create a new routine AlterTypeOwner_oid which knows whether to
pass the request to ATExecChangeOwner or deal with it directly, and use
that in shdepReassignOwner rather than calling AlterTypeOwnerInternal
directly.  AlterTypeOwnerInternal is now simpler in that it only
modifies the pg_type entry and recurses to handle a possible array type;
higher-level tasks are handled by either AlterTypeOwner directly or
AlterTypeOwner_oid.

I took the opportunity to add a few more objects to the test rig for
REASSIGN OWNED, so that more cases are exercised.  Additional ones could
be added for superuser-only-ownable objects (such as FDWs and event
triggers) but I didn't want to push my luck by adding a new superuser to
the tests on a backpatchable bug fix.

Per bug #13666 reported by Chris Pacejo.

This is a backpatch of commit 756e7b4c9d to branches 9.1 -- 9.4.
2015-12-21 19:49:15 -03:00
..
alter.h Update copyright for 2014 2014-01-07 16:05:30 -05:00
async.h Update copyright for 2014 2014-01-07 16:05:30 -05:00
cluster.h Update copyright for 2014 2014-01-07 16:05:30 -05:00
collationcmds.h Update copyright for 2014 2014-01-07 16:05:30 -05:00
comment.h pgindent run for 9.4 2014-05-06 12:12:18 -04:00
conversioncmds.h Update copyright for 2014 2014-01-07 16:05:30 -05:00
copy.h Update copyright for 2014 2014-01-07 16:05:30 -05:00
createas.h Update copyright for 2014 2014-01-07 16:05:30 -05:00
dbcommands.h Update copyright for 2014 2014-01-07 16:05:30 -05:00
defrem.h Avoid repeated name lookups during table and index DDL. 2014-02-17 09:33:31 -05:00
discard.h Update copyright for 2014 2014-01-07 16:05:30 -05:00
event_trigger.h Update copyright for 2014 2014-01-07 16:05:30 -05:00
explain.h Improve performance of EXPLAIN with large range tables. 2015-01-15 13:18:16 -05:00
extension.h Update copyright for 2014 2014-01-07 16:05:30 -05:00
lockcmds.h Update copyright for 2014 2014-01-07 16:05:30 -05:00
matview.h Update copyright for 2014 2014-01-07 16:05:30 -05:00
portalcmds.h Update copyright for 2014 2014-01-07 16:05:30 -05:00
prepare.h Update copyright for 2014 2014-01-07 16:05:30 -05:00
proclang.h pgindent run for release 9.3 2013-05-29 16:58:43 -04:00
schemacmds.h Update copyright for 2014 2014-01-07 16:05:30 -05:00
seclabel.h Update copyright for 2014 2014-01-07 16:05:30 -05:00
sequence.h Update copyright for 2014 2014-01-07 16:05:30 -05:00
tablecmds.h Rework 'MOVE ALL' to 'ALTER .. ALL IN TABLESPACE' 2014-08-21 19:12:00 -04:00
tablespace.h Rework 'MOVE ALL' to 'ALTER .. ALL IN TABLESPACE' 2014-08-21 19:12:00 -04:00
trigger.h Offer triggers on foreign tables. 2014-03-23 02:16:34 -04:00
typecmds.h Rework internals of changing a type's ownership 2015-12-21 19:49:15 -03:00
user.h ALTER TABLESPACE ... MOVE ... OWNED BY 2014-01-23 23:52:40 -05:00
vacuum.h Test IsInTransactionChain, not IsTransactionBlock, in vac_update_relstats. 2014-10-30 13:04:13 -04:00
variable.h Update copyright for 2014 2014-01-07 16:05:30 -05:00
view.h Update copyright for 2014 2014-01-07 16:05:30 -05:00