I looked into the bug reported by Cott Lang that pg_type.typowner is
incorrect for a table's toast table after a rewriting ALTER TYPE
command.  The problem occurs because an entirely new toast table
is built during the rewrite.  The correct table owner is passed to
heap_create_with_catalog(), but it doesn't get passed down to
TypeCreate(), which instead uses the current userid.

The same problem exists in CLUSTER, since it uses the same
table-rewriting logic.  In the CLUSTER form it can be demonstrated clear
back to 7.4.  The CLUSTER form seems particularly nasty since that's
much more likely to be executed as a superuser rather than the table
owner.

Now the ownership of a table rowtype isn't usually that important;
I'm not sure if there are any bad consequences other than the one
Cott reported, ie, pg_dump starting to complain if you drop the
superuser role that did the ALTER or CLUSTER.  Still, it seems like
a must-fix issue.

The obvious fix involves adding an ownerid parameter to TypeCreate,
but I'm a tad worried about whether this will break any third-party
add-on code.  Does anyone know of non-core code that calls TypeCreate?

                        regards, tom lane

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to