Re: delete cascade not working - Mailing list pgsql-general

From Kenneth Tilton
Subject Re: delete cascade not working
Date
Msg-id 49F370B2.6080404@gmail.com
Whole thread Raw
In response to Re: delete cascade not working  (Joshua Tolley <eggyknap@gmail.com>)
Responses Re: delete cascade not working
List pgsql-general

Joshua Tolley wrote:
> On Sat, Apr 25, 2009 at 04:01:20PM -0400, Kenneth Tilton wrote:
>> Given constraint:
>>
>> ALTER TABLE provider_input.common
>>   ADD CONSTRAINT common_pin_file_load_sid_fkey FOREIGN KEY
>> (pin_file_load_sid)
>>       REFERENCES provider_input.file_load (sid) MATCH FULL
>>       ON UPDATE NO ACTION ON DELETE CASCADE;
>
> <snip>
>
>> I do not actually instantiate common, I have a table that inherits from
>> that. I will play around now to see if that is an issue, thought I'd
>> send up a flare here at the same time.
>
> First guess: the foreign key constraint needs to exist on the child
> table;

I just confirmed that a common row gets deleted but not the row from the
class that inherits from common.


> having the key on the parent means nothing for the child table.

But I am "inheriting" from the parent, so everything about the parent
should be true for me unless overridden. I mean in the usual sense of
inherit I know from OO.

The only thing I see in the doc that is relevant is about multiple
inheritance where it talks about columns duplicated in parents and says
"all constraints provided from any declaration are merged together and
all are applied to the new table" so it seems to me pg understands that
at least some constraints should be inherited.

kt



pgsql-general by date:

Previous
From: Joshua Tolley
Date:
Subject: Re: delete cascade not working
Next
From: Joshua Tolley
Date:
Subject: Re: delete cascade not working