I discovered the following confusing issue in CVS HEAD:

CREATE TABLE test(id SERIAL NOT NULL);
ALTER TABLE TEST OWNER TO testuser;

SELECT typname, typowner, relname, relowner from pg_type c JOIN pg_class d ON (d.reltype = c.oid) WHERE typname = 'test';

typname | typowner | relname | relowner
---------+----------+---------+----------
test    |       10 | test    |    16419


SELECT typname, typowner, relname, relowner from pg_type c JOIN pg_class d ON (d.reltype = c.oid) WHERE typname = 'test_id_seq';
  typname   | typowner |   relname   | relowner
-------------+----------+-------------+----------
test_id_seq |       10 | test_id_seq |    16419
(1 row)

As you can see, the owner of the sequence and table row type isn't changed as well. I have done a small patch that adresses this issue for discussion. Please note that it breaks the dependency regression test at least:

 ALTER TABLE deptest OWNER TO regression_user3;
 DROP USER regression_user3;
ERROR: role "regression_user3" cannot be dropped because some objects depend on it
! DETAIL:  owner of table deptest
 -- if we drop the object, we can drop the user too
 DROP TABLE deptest;
 DROP USER regression_user3;
--- 33,40 ----
 ALTER TABLE deptest OWNER TO regression_user3;
 DROP USER regression_user3;
ERROR: role "regression_user3" cannot be dropped because some objects depend on it
! DETAIL:  owner of type deptest
! owner of table deptest
 -- if we drop the object, we can drop the user too
 DROP TABLE deptest;
 DROP USER regression_user3;

Any opinions?

--
 Bernd

Attachment: alter_owner.patch
Description: Binary data

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Reply via email to