postgresql/src/include/commands
Alvaro Herrera f9643d0d6d 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 Fix ALTER EXTENSION / SET SCHEMA 2012-10-31 10:48:41 -03:00
async.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
cluster.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
collationcmds.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
comment.h Remove tabs after spaces in C comments 2014-05-06 11:26:27 -04:00
conversioncmds.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
copy.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
createas.h Run pgindent on 9.2 source tree in preparation for first 9.3 2012-06-10 15:20:04 -04:00
dbcommands.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
defrem.h Fix REASSIGN OWNED for text search objects 2014-07-15 13:24:07 -04:00
discard.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
explain.h Run pgindent on 9.2 source tree in preparation for first 9.3 2012-06-10 15:20:04 -04:00
extension.h Have REASSIGN OWNED work on extensions, too 2012-07-03 15:18:40 -04:00
lockcmds.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
portalcmds.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
prepare.h Restructure SELECT INTO's parsetree representation into CreateTableAsStmt. 2012-03-19 21:38:12 -04:00
proclang.h Further consolidation of DROP statement handling. 2011-11-17 21:32:34 -05:00
schemacmds.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
seclabel.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
sequence.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
tablecmds.h Avoid repeated name lookups during table and index DDL. 2014-02-17 09:33:33 -05:00
tablespace.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
trigger.h Avoid repeated name lookups during table and index DDL. 2014-02-17 09:33:33 -05:00
typecmds.h Rework internals of changing a type's ownership 2015-12-21 19:49:15 -03:00
user.h Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00
vacuum.h Test IsInTransactionChain, not IsTransactionBlock, in vac_update_relstats. 2014-10-30 13:03:31 -04:00
variable.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
view.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00