Re: BUG #13572: Foreign Key Corruption - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #13572: Foreign Key Corruption
Date
Msg-id 13106.1439586462@sss.pgh.pa.us
Whole thread Raw
In response to BUG #13572: Foreign Key Corruption  (herbertsilver@gmail.com)
List pgsql-bugs
herbertsilver@gmail.com writes:
> I'm having a bug here. I have a main table and another one referencing to
> its primary key. I'm being able to delete records from the main table at the
> same time postgres keeps the orphaneds rows on the second one.

> I belive it's because of a rule I'm using that is causing the bug, although
> I think it was not supposed to happen anyway.

Yup.  Rules act at a level lower than foreign keys, ie a rule can rewrite
the query that is trying to implement ON DELETE CASCADE.  And here you
have an ON DELETE DO INSTEAD rule on the target table.  This is not a bug,
it's just the way those two features work together.

            regards, tom lane

pgsql-bugs by date:

Previous
From: herbertsilver@gmail.com
Date:
Subject: BUG #13572: Foreign Key Corruption
Next
From: Tom Lane
Date:
Subject: Re: BUG #13571: sql-only extension segfaults backend during creation