Re: how to create a non-inherited CHECK constraint in CREATE TABLE - Mailing list pgsql-hackers

From Nikhil Sontakke
Subject Re: how to create a non-inherited CHECK constraint in CREATE TABLE
Date
Msg-id CANgU5Zdqg20Wigt8vQRox7BEDe3Q96mMSZ1sqA+vQ9kSx0gxHA@mail.gmail.com
Whole thread Raw
In response to Re: how to create a non-inherited CHECK constraint in CREATE TABLE  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: how to create a non-inherited CHECK constraint in CREATE TABLE  (Noah Misch <noah@leadboat.com>)
List pgsql-hackers
Hi,

Cumulative reaction to all the responses first:

Whoa! :)

I was under the impression that a majority of us felt that the current mechanism was inadequate. Also if you go through the nabble thread, the fact that CREATE TABLE did not support such constraints was considered to be an annoyance. And I was enquired if/when I can provide this functionality. Apologies though with the timing.
 
> +1 for fixing up the syntax before 9.2 goes out the door.  I think the
> original syntax was misguided to begin with.

Well, it was fine in isolation, but once you consider how to make CREATE
TABLE do this too, it's hard to avoid the conclusion that you need to
attach the modifier to the CHECK constraint not the ALTER TABLE command.


Yeah, exactly.
 
> CHECK NO INHERIT sounds fine to me; will that display ALTER TABLE ONLY
> x as the one true way of doing this?

s/display/displace/, I think you meant?  Yeah, that's what I understand
the proposal to be.


Displace yes. It would error out if someone says

ALTER TABLE ONLY... CHECK ();

suggesting to use the ONLY with the CHECK.

This patch does this and also makes both CREATE TABLE and ALTER TABLE use it in a uniform manner.

Regarding "NO INHERIT" versus "ONLY", we again have had discussions on the longish original thread quite a while back:

http://postgresql.1045698.n5.nabble.com/Check-constraints-on-partition-parents-only-tt4633334.html

But now if we prefer NO INHERIT, I can live with that.

Regards,
Nikhils

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Last gasp
Next
From: Magnus Hagander
Date:
Subject: Re: Last gasp