Re: how to create a non-inherited CHECK constraint in CREATE TABLE

From: Nikhil Sontakke <nikkhils(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Jim Nasby <jim(at)nasby(dot)net>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: how to create a non-inherited CHECK constraint in CREATE TABLE
Date: 2012-04-12 05:20:31
Message-ID: CANgU5Zdqg20Wigt8vQRox7BEDe3Q96mMSZ1sqA+vQ9kSx0gxHA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Magnus Hagander 2012-04-12 05:59:33 Re: Last gasp
Previous Message Tom Lane 2012-04-12 03:49:38 Re: Last gasp