[prev in list] [next in list] [prev in thread] [next in thread]
List: pgsql-bugs
Subject: Re: ADD CHECK fails for parent table if column used in CHECK is fully-qualified
From: Tom Lane <tgl () sss ! pgh ! pa ! us>
Date: 2019-07-25 2:09:52
Message-ID: 13268.1564020592 () sss ! pgh ! pa ! us
[Download RAW message or body]
Manuel Rigger <rigger.manuel@gmail.com> writes:
> Consider the following case:
> CREATE TABLE t0(c0 boolean);
> CREATE TABLE t1(c0 boolean) INHERITS(t0);
> ALTER TABLE t0 ADD CHECK(t0.c0);
> -- unexpected: ERROR: missing FROM-clause entry for table "t0"
> Is it expected that this fails?
I don't really have a problem with that. You specified that the
check was on t0, and that would be an invalid constraint for t1.
Now it is a bit weird that you can do this:
regression=# CREATE TABLE t0(c0 boolean);
CREATE TABLE
regression=# ALTER TABLE t0 ADD CHECK(t0.c0);
ALTER TABLE
regression=# CREATE TABLE t1() INHERITS(t0);
CREATE TABLE
That happens because after the ALTER, the check constraint is
remembered as just c0:
regression=# \d t0
Table "public.t0"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
c0 | boolean | | |
Check constraints:
"t0_c0_check" CHECK (c0)
and that can be propagated down to t1. So the system has forgotten
a syntactic detail that perhaps it shouldn't have. But I can't
get excited about changing that.
regards, tom lane
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic