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