postgresql/src/include/commands
Alvaro Herrera 0c6881fd14 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.

Backpatch to 9.5.

(I would back-patch this all the way back, except that it doesn't apply
cleanly in 9.4 and earlier because 59367fdf9 wasn't backpatched.  If we
decide that we need this in earlier branches too, we should backpatch
both.)
2015-12-17 14:25:41 -03:00
..
alter.h Change many routines to return ObjectAddress rather than OID 2015-03-03 14:10:50 -03:00
async.h Introduce and use infrastructure for interrupt processing during client reads. 2015-02-03 22:25:20 +01:00
cluster.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
collationcmds.h Change many routines to return ObjectAddress rather than OID 2015-03-03 14:10:50 -03:00
comment.h Change many routines to return ObjectAddress rather than OID 2015-03-03 14:10:50 -03:00
conversioncmds.h Change many routines to return ObjectAddress rather than OID 2015-03-03 14:10:50 -03:00
copy.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
createas.h Change many routines to return ObjectAddress rather than OID 2015-03-03 14:10:50 -03:00
dbcommands.h Move WAL-related definitions from dbcommands.h to separate header file. 2015-03-09 15:50:49 +02:00
dbcommands_xlog.h Move WAL-related definitions from dbcommands.h to separate header file. 2015-03-09 15:50:49 +02:00
defrem.h Fix DDL command collection for TRANSFORM 2015-06-26 18:17:54 -03:00
discard.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
event_trigger.h pgindent run for 9.5 2015-05-23 21:35:49 -04:00
explain.h pgindent run for 9.5 2015-05-23 21:35:49 -04:00
extension.h Allow on-the-fly capture of DDL event details 2015-05-11 19:14:31 -03:00
lockcmds.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
matview.h Change many routines to return ObjectAddress rather than OID 2015-03-03 14:10:50 -03:00
policy.h Handle policies during DROP OWNED BY 2015-12-11 16:12:36 -05:00
portalcmds.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
prepare.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
proclang.h Change many routines to return ObjectAddress rather than OID 2015-03-03 14:10:50 -03:00
schemacmds.h Change many routines to return ObjectAddress rather than OID 2015-03-03 14:10:50 -03:00
seclabel.h Change many routines to return ObjectAddress rather than OID 2015-03-03 14:10:50 -03:00
sequence.h Change many routines to return ObjectAddress rather than OID 2015-03-03 14:10:50 -03:00
tablecmds.h Change many routines to return ObjectAddress rather than OID 2015-03-03 14:10:50 -03:00
tablespace.h Be more conservative about removing tablespace "symlinks". 2015-06-26 15:53:13 -04:00
trigger.h Change many routines to return ObjectAddress rather than OID 2015-03-03 14:10:50 -03:00
typecmds.h Rework internals of changing a type's ownership 2015-12-17 14:25:41 -03:00
user.h Allow CURRENT/SESSION_USER to be used in certain commands 2015-03-09 15:41:54 -03:00
vacuum.h pgindent run for 9.5 2015-05-23 21:35:49 -04:00
variable.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
view.h Change many routines to return ObjectAddress rather than OID 2015-03-03 14:10:50 -03:00