Re: PRIMARY KEY and INHERITANCE - Mailing list pgsql-hackers

From Horst Herb
Subject Re: PRIMARY KEY and INHERITANCE
Date
Msg-id 01010110095208.08574@munin.midgard
Whole thread Raw
In response to PRIMARY KEY and INHERITANCE  (Ferruccio Zamuner <nonsolosoft@diff.org>)
Responses Re: PRIMARY KEY and INHERITANCE
List pgsql-hackers
On Monday 01 January 2001 01:42, Ferruccio Zamuner wrote:
> Hi,
>
> some months ago I've asked for a suggestion for this bug:
>
> create table a (
>        id serial primary key,
>        something text
> );
>
> create table b (
>        morething text
> ) inherits (a);
>
> create table c (
>        trouble int references b;
> );
> NOTICE:  CREATE TABLE will create implicit trigger(s) for FOREIGN KEY
> check(s) ERROR:  PRIMARY KEY for referenced table "b" not found
>
>
> How is possible to resolve this bug?
> How is possible to talk about a ORDBMS with this kind of error?

It is not a bug, I would call it a missing feature. I had the same problem, 
and somebody from this list helped me with a private email. I think this 
should be included in the FAQ and general documentation.

What happens is that the attribute "id" is inherited, but the index on "id" 
is not. The workaround is:

create unique index table_b_id on b(id);

Then the index exists, and the foreign key can be referenced.

Yes, I share your believe that the automatic generation of this index should 
be a minimum requirement for an _O_RDBMS, but who will have time to implement 
it properly?

Regards,
Horst


pgsql-hackers by date:

Previous
From: "Oliver Elphick"
Date:
Subject: Re: PRIMARY KEY and INHERITANCE
Next
From: Larry Rosenman
Date:
Subject: pg_dumpall (7.1beta1, current CVS)