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

[BUG?] strange behavior in ALTER TABLE ... RENAME TO on inherited columns

From: KaiGai Kohei <kaigai(at)ak(dot)jp(dot)nec(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: [BUG?] strange behavior in ALTER TABLE ... RENAME TO on inherited columns
Date: 2009-11-04 06:36:15
Message-ID: 4AF120DF.3070108@ak.jp.nec.com (view raw or flat)
Thread:
Lists: pgsql-hackers
Is it an expected behavior?

  postgres=# CREATE TABLE t1 (a int, b int);
  CREATE TABLE
  postgres=# CREATE TABLE t2 (b int, c int);
  CREATE TABLE
  postgres=# CREATE TABLE t3 (d int) inherits (t1, t2);
  NOTICE:  merging multiple inherited definitions of column "b"
  CREATE TABLE

The t3.d is inherited from t1 and t2. Its attinhcount is 2.

  postgres=# ALTER TABLE t1 RENAME b TO x;
  ALTER TABLE

It alters name of the column 'b' in the t1 and its child tables ('t3').

  postgres=# SELECT * FROM t1;
   a | x
  ---+---
  (0 rows)

  postgres=# SELECT * FROM t2;
  ERROR:  could not find inherited attribute "b" of relation "t3"

Because t3.b is also inherited from the t2, but ALTER TABLE does not
care about multiple inherited columns well.

I think we should not allow to rename a column with attinhcount > 1.

Any comments?

Thanks,
-- 
OSS Platform Development Division, NEC
KaiGai Kohei <kaigai(at)ak(dot)jp(dot)nec(dot)com>

Responses

pgsql-hackers by date

Next:From: Fujii MasaoDate: 2009-11-04 10:40:19
Subject: Re: BUG #4961: pg_standby.exe crashes with no args
Previous:From: Tom LaneDate: 2009-11-04 05:56:02
Subject: Re: DISTINCT ON

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