Tom Lane wrote:
> Thom Brown <thombrown(at)gmail(dot)com> writes:
>> 2009/11/4 Alvaro Herrera <alvherre(at)commandprompt(dot)com>:
>>> KaiGai Kohei wrote:
>>>> I think we should not allow to rename a column with attinhcount > 1.
>>> I think we should fix ALTER TABLE to cope with multiple inheritance.
>> I'd be interested to see how this should work.
> Yeah. I don't think a "fix" is possible, because there is no
> non-astonishing way for it to behave. I think KaiGai is right that
> forbidding the rename is the best solution.
The attached patch forbids rename when the attribute is inherited
from multiple parents.
postgres=# CREATE TABLE t1 (a int, b int);
postgres=# CREATE TABLE t2 (b int, c int);
postgres=# CREATE TABLE t3 (d int) INHERITS (t1, t2);
NOTICE: merging multiple inherited definitions of column "b"
postgres=# SELECT * FROM t3;
a | b | c | d
postgres=# ALTER TABLE t1 RENAME b TO x;
ERROR: cannot rename multiple inherited column "b"
The regression test detected a matter in the misc test.
It tries to rename column "a" of "a_star" table, but it failed due to
the new restriction.
-- test the "star" operators a bit more thoroughly -- this time,
-- throw in lots of NULL fields...
-- a is the type root
-- b and c inherit from a (one-level single inheritance)
-- d inherits from b and c (two-level multiple inheritance)
-- e inherits from c (two-level single inheritance)
-- f inherits from e (three-level single inheritance)
CREATE TABLE a_star (
CREATE TABLE b_star (
) INHERITS (a_star);
CREATE TABLE c_star (
) INHERITS (a_star);
CREATE TABLE d_star (
) INHERITS (b_star, c_star);
At the misc test,
--- 242,278 ----
ALTER TABLE c_star* RENAME COLUMN c TO cc;
ALTER TABLE b_star* RENAME COLUMN b TO bb;
ALTER TABLE a_star* RENAME COLUMN a TO aa;
+ ERROR: cannot rename multiple inherited column "a"
SELECT class, aa
FROM a_star* x
WHERE aa ISNULL;
! ERROR: column "aa" does not exist
! LINE 1: SELECT class, aa
It seems to me it is a case the regression test to be fixed up.
(We don't have any reasonable way to know whether a certain attribute
has a same source, or not.)
OSS Platform Development Division, NEC
KaiGai Kohei <kaigai(at)ak(dot)jp(dot)nec(dot)com>
In response to
pgsql-hackers by date
|Next:||From: Tom Lane||Date: 2009-11-05 01:34:02|
|Subject: Shall we just get rid of plpgsql's RENAME?|
|Previous:||From: Tatsuo Ishii||Date: 2009-11-05 00:22:59|
|Subject: Re: Architecture of walreceiver (Streaming Replication)|