Bug in ALTER TABLE/SEQUENCE OWNER TO

From: Bernd Helmle <mailings(at)oopsware(dot)de>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Bug in ALTER TABLE/SEQUENCE OWNER TO
Date: 2005-08-03 23:40:30
Message-ID: 000E1A2523D2CD4F83B16FE3@sparkey.oopsware.intra
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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 Content-Type Size
alter_owner.patch application/octet-stream 4.3 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2005-08-03 23:43:37 Solving the OID-collision problem
Previous Message Mark Woodward 2005-08-03 21:00:16 US Census database (Tiger 2004FE)