postgresql/src/backend
Alvaro Herrera 756e7b4c9d 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
..
access Provide a way to predefine LWLock tranche IDs. 2015-12-15 11:48:19 -05:00
bootstrap
catalog Rework internals of changing a type's ownership 2015-12-17 14:25:41 -03:00
commands Rework internals of changing a type's ownership 2015-12-17 14:25:41 -03:00
executor Improve some messages 2015-12-10 22:05:27 -05:00
foreign
lib Avoid use of float arithmetic in bipartite_match.c. 2015-08-23 13:02:18 -04:00
libpq Message improvements 2015-11-16 21:39:23 -05:00
main Revoke support for strxfrm() that write past the specified array length. 2015-07-08 20:44:21 -04:00
nodes Get rid of the planner's LateralJoinInfo data structure. 2015-12-11 15:52:38 -05:00
optimizer Collect the global OR of hasRowSecurity flags for plancache 2015-12-14 20:05:43 -05:00
parser Mark CHECK constraints declared NOT VALID valid if created with table. 2015-12-16 07:43:56 -05:00
po
port On Windows, ensure shared memory handle gets closed if not being used. 2015-10-13 11:21:33 -04:00
postmaster Message improvements 2015-11-16 21:39:23 -05:00
regex Fix enforcement of restrictions inside regexp lookaround constraints. 2015-11-07 12:43:24 -05:00
replication Consistently set all fields in pg_stat_replication to null instead of 0 2015-12-13 16:53:38 +01:00
rewrite Get rid of the planner's LateralJoinInfo data structure. 2015-12-11 15:52:38 -05:00
snowball
storage Teach mdnblocks() not to create zero-length files. 2015-12-15 13:57:45 -05:00
tcop Fix problems with ParamListInfo serialization mechanism. 2015-11-02 18:11:29 -05:00
tsearch
utils Add missing CHECK_FOR_INTERRUPTS in lseg_inside_poly 2015-12-14 16:44:40 -03:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
common.mk
Makefile Revert "Have dtrace depend on object files directly, not objfiles.txt" 2015-10-15 13:16:03 -04:00
nls.mk Remove trailing slashes from directories in find command 2015-09-18 22:06:54 -04:00