|From:||Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>|
|To:||Manuel Rigger <rigger(dot)manuel(at)gmail(dot)com>|
|Cc:||PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>|
|Subject:||Re: Multiple inheritance and ALTER TABLE issue|
|Views:||Raw Message | Whole Thread | Download mbox | Resend email|
Manuel Rigger <rigger(dot)manuel(at)gmail(dot)com> writes:
> Consider the test case below:
> CREATE TABLE t0(c0 boolean);
> CREATE TABLE t1(c0 boolean);
> CREATE TABLE t2(c0 boolean) INHERITS(t0, t1);
> ALTER TABLE t0 ALTER c0 TYPE TEXT;
> UPDATE t1 SET c0 = TRUE; -- ERROR: attribute "c0" of relation "t2"
> does not match parent's type
> The ALTER TABLE leaves t1 behind in an unusable state, which is
> somewhat unexpected. I would expect that either the ALTER TABLE fails
> unless also t1 is explicitly updated, or that the ALTER TABLE updates
> the column in t1. Updating the other tables does not cause a problem:
> UPDATE t2 SET c0 = TRUE; -- no error
> UPDATE t0 SET c0 = 'asdf'; -- no error
> Is this behavior intended?
Hm. I would say that the ALTER COLUMN TYPE operation should have thrown
an error instead of trying to change the type of a multiply-inherited
column. As you say, no good can come of that.
Given such a restriction, there would be no way to change c0's type while
the multi-inheritance situation exists. You'd have to disinherit t2 from
one parent or the other, change the type in both parents, and then
re-inherit from the removed parent. That is possible, and given the lack
of prior complaints, it seems like it'd be a sufficient answer to anyone
who needs to do it.
regards, tom lane
|Next Message||Bruce Momjian||2019-07-27 21:41:30||Re: BUG #15912: The units of `autovacuum_vacuum_cost_delay` setting should be documented|
|Previous Message||Tom Lane||2019-07-27 15:23:29||Re: BUG #15930: Redact PGPASSWORD environment variable in psql|