Re(2): REFERENCES fails on derived classes

From: "Michael Caine" <mcaine(at)artlogic(dot)com>
To: sszabo(at)megazone23(dot)bigpanda(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re(2): REFERENCES fails on derived classes
Date: 2001-06-11 11:17:38
Message-ID: fc.000f4b1100146d133b9aca00c10327eb.146d14@artlogic.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

a month i was told that my possible bug submission was "sort of" a bug.
the report and reply are below.

now i write a follow up because i don't know how to establish a workroom.
specifically, i know know that a unique constraint must be added to an
inherited "id" field, even if it's a primary key in the base table. i can
do this by 'CREATE INDEX', but this creates a completely new constraint.
i want to share the unique 'serial' behavior between the base table and
derived table, so that en entry in either table is unique between the
tables. that way, when i do a 'SELECT baseTable*' kind of command, i can
differentiate between two records. is there a way to do this, or could
this be considered a valid bug of some sort?

thank you,
jmichael

sszabo(at)megazone23(dot)bigpanda(dot)com writes:
>On Sat, 2 Jun 2001, J. Michael Caine wrote:
>
>> the following works:
>>
>> create table t1 (id serial primary key);
>> create table t2 (id serial primary key);
>> create table t12 (
>> t1_id int references t1(id) on delete cascade,
>> t2_id int references t2(id) on delete cascade
>> );
>>
>> but the following does not:
>> create table t1d () inherits(t1);
>> create table t1d2 (
>> t1d_id int references t1d(id) on delete cascade,
>> t2_id int references t2(id) on delete cascade
>> );
>>
>> i'm told:
>> ERROR: UNIQUE constraint matching given keys for referenced table t1d
>not
>> found
>>
>> i'm working in postgresql 7.1 (i686-pc-linux-gnu)
>>
>> hope this is a bug (and i'm not wasting your time) and easily
>verifiable,
>
>Sort of. The unique constraint does not get inherited by t1d right now
>(nor do fk constraints inherit) so there isn't a unique constraint on
>t1d(id). Add a unique constraint to t1d(id) and it should work.
>

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Michael Roth 2001-06-11 13:49:22 FATAL Error
Previous Message Stephan Szabo 2001-06-09 23:10:19 Re: furiously yours