Re: PRIMARY KEY and INHERITANCE

From: Horst Herb <hherb(at)malleenet(dot)net(dot)au>
To: Ferruccio Zamuner <nonsolosoft(at)diff(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: PRIMARY KEY and INHERITANCE
Date: 2000-12-31 23:09:52
Message-ID: 01010110095208.08574@munin.midgard
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Larry Rosenman 2000-12-31 23:59:17 pg_dumpall (7.1beta1, current CVS)
Previous Message Andrew McMillan 2000-12-31 22:18:03 Re: Upper limit on number of buffers?