Inheritance referential integrity problem - Mailing list pgsql-general

From Petru Paler
Subject Inheritance referential integrity problem
Date
Msg-id Pine.LNX.4.44.0204021535230.20774-100000@rostock.criermedia.ro
Whole thread Raw
Responses Re: Inheritance referential integrity problem  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
List 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


pgsql-general by date:

Previous
From: "Yuri A. Kabaenkov"
Date:
Subject: changeing type of column
Next
From: Devrim GUNDUZ
Date:
Subject: Re: changeing type of column