Re: Review: Non-inheritable check constraints

From: Nikhil Sontakke <nikkhils(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Greg Smith <greg(at)2ndquadrant(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Review: Non-inheritable check constraints
Date: 2011-12-20 15:03:33
Message-ID: CANgU5Zfu6BKcrvBUhqNyjCA_fFt51L4gDbm6bRysORsghqGn4Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> rhaas=# create table A(ff1 int);
>> CREATE TABLE
>> rhaas=# create table B () inherits (A);
>> CREATE TABLE
>> rhaas=# create table C () inherits (B);
>> CREATE TABLE
>> rhaas=# alter table only b add constraint chk check (ff1 > 0);
>> ALTER TABLE
>> rhaas=# alter table a add constraint chk check (ff1 > 0);
>> NOTICE: merging constraint "chk" with inherited definition
>> ALTER TABLE
>>
>> At this point, you'll find that a has a constraint, and b has a
>> constraint, but *c does not have a constraint*. That's bad, because
>> a's constraint wasn't "only" and should therefore have propagated all
>> the way down the tree.
>>
>>
> Apologies, I did not check this particular scenario.
>
> I guess, here, we should not allow merging of the inherited constraint
> into an "only" constraint. Because that breaks the semantics for "only"
> constraints. If this sounds ok, I can whip up a patch for the same.
>
>
PFA, patch which does just this.

postgres=# alter table a add constraint chk check (ff1 > 0);
ERROR: constraint "chk" for relation "b" is an ONLY constraint. Cannot
merge

Regards,
Nikhils

Attachment Content-Type Size
only_constraint_no_merge.patch application/octet-stream 1.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2011-12-20 15:32:40 Re: sync_seqscans in postgresql.conf
Previous Message Dimitri Fontaine 2011-12-20 15:01:33 Extensions and 9.2