Re: Review: Non-inheritable check constraints

Поиск
Список
Период
Сортировка
От Nikhil Sontakke
Тема Re: Review: Non-inheritable check constraints
Дата
Msg-id CANgU5Zcmg4jVyp4A2AjmO2UEX0Hbd7CfHTXC95m0Sqk=af+yRQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Review: Non-inheritable check constraints  (Robert Haas <robertmhaas@gmail.com>)
Ответы Re: Review: Non-inheritable check constraints  (Nikhil Sontakke <nikkhils@gmail.com>)
Список pgsql-hackers

 
> Agreed. I just tried out the scenarios laid out by you both with and without
> the committed patch and AFAICS, normal inheritance semantics have been
> preserved properly even after the commit.

No, they haven't.  I didn't expect this to break anything when you
have two constraints with different names.  The problem is when you
have two constraints with the same name.

Testing reveals that this is, in fact, broken:

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.

Regards,
Nikhils

В списке pgsql-hackers по дате отправления:

Предыдущее
От: "ktm@rice.edu"
Дата:
Сообщение: Re: sync_seqscans in postgresql.conf
Следующее
От: Dimitri Fontaine
Дата:
Сообщение: Extensions and 9.2