Re: BUG #13572: Foreign Key Corruption

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: herbertsilver(at)gmail(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #13572: Foreign Key Corruption
Date: 2015-08-14 21:07:42
Message-ID: 13106.1439586462@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

herbertsilver(at)gmail(dot)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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2015-08-15 16:01:59 Re: BUG #13571: sql-only extension segfaults backend during creation
Previous Message herbertsilver 2015-08-14 16:39:19 BUG #13572: Foreign Key Corruption