inheritance and primary key contraint - Mailing list pgsql-general

From david.butcher@cathaynetworks.com
Subject inheritance and primary key contraint
Date
Msg-id 1021837447.3ce800874e076@sinclair.swishmail.com
Whole thread Raw
List pgsql-general
The primary key constraint does not seem to be enforced across inheritance.

Page 69 7.2 referennce manual
"unique contraints and primary keys are not inherited in the current
implementation. This makes the combination of unique constraints and inheritance
rather dysfunctional'.

In the following example, we are able to insert 2 rows with identical primary
keys - one on the base table and one on the derived table. Both examples exhibit
the same behavior.

What can we do to enforce uniqueness over the whole tree?

CREATE TABLE Base( baseId  integer, PRIMARY KEY ( baseId ) );
CREATE TABLE Derived () INHERITS (Base);
insert into Derived (baseId) values (1);
// this insert should fail, but does not
insert into Base (baseId) values (1);


CREATE TABLE Base( baseId  integer, PRIMARY KEY ( baseId ) );
CREATE TABLE Derived (PRIMARY KEY (baseId)) INHERITS (Base);
insert into Derived (baseId) values (1);
insert into Base (baseId) values (1);
// this insert should fail, but does not
insert into Base (baseId) values (1);



pgsql-general by date:

Previous
From: Uros Gruber
Date:
Subject: Re: LIMIT between some column
Next
From: "sheetal"
Date:
Subject: Help..