pg.ddx.io pgsql-bugs@postgresql.org mailing list archivehelp / color / mirror / Atom feed
ADD CHECK fails for parent table if column used in CHECK is fully-qualified 2+ messages / 2 participants [nested] [flat]
* ADD CHECK fails for parent table if column used in CHECK is fully-qualified @ 2019-07-24 10:00 Manuel Rigger <rigger.manuel@gmail.com> 2019-07-25 02:09 ` Re: ADD CHECK fails for parent table if column used in CHECK is fully-qualified Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 1 reply; 2+ messages in thread From: Manuel Rigger @ 2019-07-24 10:00 UTC (permalink / raw) To: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org> Hi everyone, 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? Without a child table, this works as I would expect. If this is expected, I think that the error message could be misleading. It seems that the full-qualified c0 column (i.e., t0.c0) triggers this, because the following works: CREATE TABLE t0(c0 boolean); CREATE TABLE t1(c0 boolean) INHERITS(t0); ALTER TABLE t0 ADD CHECK(c0); -- no error Best, Manuel ^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: ADD CHECK fails for parent table if column used in CHECK is fully-qualified 2019-07-24 10:00 ADD CHECK fails for parent table if column used in CHECK is fully-qualified Manuel Rigger <rigger.manuel@gmail.com> @ 2019-07-25 02:09 ` Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 2+ messages in thread From: Tom Lane @ 2019-07-25 02:09 UTC (permalink / raw) To: Manuel Rigger <rigger.manuel@gmail.com>; +Cc: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org> 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 ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2019-07-25 02:09 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2019-07-24 10:00 ADD CHECK fails for parent table if column used in CHECK is fully-qualified Manuel Rigger <rigger.manuel@gmail.com> 2019-07-25 02:09 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox