Re: Referential Integrity corrupted sometimes by Rules - Mailing list pgsql-bugs

From José María Fernández González
Subject Re: Referential Integrity corrupted sometimes by Rules
Date
Msg-id 3B461185.981821E3@cnb.uam.es
Whole thread Raw
In response to Referential Integrity corrupted sometimes by Rules  (pgsql-bugs@postgresql.org)
List pgsql-bugs
Tom Lane wrote:
>
> pgsql-bugs@postgresql.org writes:
> > -- Rule over the referenced table
> > -- which breaks referential integrity
> > create rule nodelrel
> > as on delete to rel
> > where old.ref > 3 and user = 'prueba'
> > do instead nothing;
>

Hi Tom,
first of all, my congratulations to the PostgreSQL team, for this fantastic
ORDBMS. I'm working with it since 6.4.2 version, and each improvement since then
is placing PostgreSQL above the other (commercial and non-commercial) products.

> This rule is preventing the foreign key triggers from performing the
> DELETEs implied by your ON DELETE CASCADE command.  If we made the
> triggers bypass the rules, we'd get other complaints about that.
> At the moment, the rule wins.  If you want to propose a different
> behavior, let's hear it.
But, PostgreSQL makes an external (not internal) difference among triggers and
constraint triggers (described as special and for internal use in the reference
manual). Surely there are many reasons to have only one level of triggers (I'm
thinking on two or three now), but why don't two levels? The first level with
triggers, which can be bypassed by rules, and the second level with constraint
triggers, which cannot be bypassed by them.
Following with the two levels concept, when you define a trigger you could have
a parameter to set the 'unbypassable' behaviour (with the normal one set as
default), so the database designer could choose when she/he/it needs to tune a
complex design.
Best regards,    José María Fernández

--
José María Fernández González        e-mail: jmfernandez@cnb.uam.es
Tlfn:    (+34) 91 585 49 21        Fax:    (+34) 91 585 45 06
Grupo de Diseño de Proteinas        Protein Design Group
Centro Nacional de Biotecnología    National Center of Biotechnology
C.P.: 28049                Zip Code: 28049
Campus Universidad Autónoma. Cantoblanco, Madrid, Spain.


pgsql-bugs by date:

Previous
From: "William M. Shubert"
Date:
Subject: Corrupted index/unique column after vacuuming
Next
From: Carl Anderson
Date:
Subject: shared library compile error