Inheritance referential integrity problem

From: Petru Paler <ppetru(at)ppetru(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Inheritance referential integrity problem
Date: 2002-04-02 15:40:30
Message-ID: Pine.LNX.4.44.0204021535230.20774-100000@rostock.criermedia.ro
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello everyone,

I'm using Postgresql's very nice inheritance support in a project, but I
just stumbled upon a problem that I'm not sure how to fix (or whether it's
my problem or postgresql's).

Here is a small set of tables that can be used to reproduce the problem:

create table a (id integer primary key);
create table b (foo varchar(100)) inherits(a);
create table c(id integer primary key, b_id integer references a(id));

The data:

test=# insert into b(id, foo) values (1, 'asd');
INSERT 19991 1
test=# select * from b;
id | foo
----+-----
1 | asd
(1 row)

test=# select * from a;
id
----
1
(1 row)

And the problem:

test=# insert into c (id, b_id) values (5, 1);
ERROR: <unnamed> referential integrity violation - key referenced from c
not found in a

Could someone enlighten me on what I'm missing? Why is the constraint not
satisfied, since the key is clearly present in a? If that row is
considered to belong to b, then why does it show up in a?

If possible, please Cc me on the responses as I'm not subscribed to this
mailing list.

Thank you,
Petru

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2002-04-02 15:41:38 Re: Trivial query, large query, but very sad results.
Previous Message Tom Lane 2002-04-02 15:36:37 Re: v7.2.1 Released: Critical Bug Fix