Multiple inheritance and ALTER TABLE issue

From: Manuel Rigger <rigger(dot)manuel(at)gmail(dot)com>
To: PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Multiple inheritance and ALTER TABLE issue
Date: 2019-07-27 09:21:54
Message-ID: CA+u7OA4qogDv9rz1HAb-ADxttXYPqQdUdPY_yd4kCzywNxRQXA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi everyone,

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? The documentation mentions that ALTER TABLE
"will propagate any changes in column data definitions and check
constraints down the inheritance hierarchy", but not up the
inheritance hierarchy, so this might be expected.

Best,
Manuel

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2019-07-27 09:39:47 BUG #15929: logical decoding can not write down the analyse result when the output file is touched.
Previous Message Alvaro Herrera 2019-07-26 22:20:28 Re: DISCARD TEMP results in "ERROR: cache lookup failed for type 0"