Skip site navigation (1) Skip section navigation (2)

ALTER TABLE ... OWNER TO does not change ownership recursively

From: Ryan Kelly <rpkelly22(at)gmail(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: ALTER TABLE ... OWNER TO does not change ownership recursively
Date: 2012-04-26 11:42:32
Message-ID: 20120426114232.GA31886@llserver.lakeliving.com (view raw or flat)
Thread:
Lists: pgsql-bugs
It seems that ALTER TABLE ... OWNER TO does not change the ownership of
any inheriting tables. The documentation states:

> If ONLY is specified, only that table is altered. If ONLY is not
> specified, the table and any descendant tables are altered.

Which to me indicates that ownership should be altered on the target table and
any descendant tables as well.

Here is a small test case to reproduce the problem:

create table parent (id int);
create table child () inherits (parent);
create role new_owner;
alter table parent owner to new_owner;

After performing this sequence of commands, \d looks like:
 Schema |     Name      |   Type   |   Owner 
--------+---------------+----------+-----------
 public | child         | table    | ryan
 public | parent        | table    | new_owner

But I would expect that without specifying only, I would get:
 Schema |     Name      |   Type   |   Owner   
--------+---------------+----------+-----------
 public | child         | table    | new_owner
 public | parent        | table    | new_owner

Attached is a patch which fixes this issue. It is based off of REL8_4_11.

Version: PostgreSQL 8.4.11 on i386-apple-darwin10.8.0, compiled by GCC i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3), 64-bit

-Ryan Kelly

Attachment: at-owner-inheritance.patch
Description: text/x-diff (5.9 KB)

Responses

pgsql-bugs by date

Next:From: dodobasDate: 2012-04-26 16:02:21
Subject: BUG #6617: FETCH FIRST syntax accepts only constants and notparameters
Previous:From: Tom LaneDate: 2012-04-26 03:59:24
Subject: Re: BUG #6612: Functions can be called inside CHECK statements

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group