Re: assertions and constraint triggers - Mailing list pgsql-hackers

From Tom Lane
Subject Re: assertions and constraint triggers
Date
Msg-id 4307.1281903175@sss.pgh.pa.us
Whole thread Raw
In response to assertions and constraint triggers  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-hackers
Peter Eisentraut <peter_e@gmx.net> writes:
> Thinking about SQL assertions (check constraints that are independent of
> one particular table), do you think it would be reasonable to implement
> those on top of constraint triggers?  On creation you'd hook up a
> trigger to each of the affected tables.  And the trigger function runs
> the respective check expression.  Conceptually, this doesn't seem to be
> very far away from foreign key constraints after all.

On further reflection it seems like the major implementation problem
would be to identify "the affected tables".  What if the assertion
references views, or user-defined functions that contain queries?
Even an assertion on a table with inheritance children would be a
bit problematic.  In principle you could handle the latter case by
propagating copies of the trigger to all the children, but we have
no mechanism for that now.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: Cost of AtEOXact_Buffers in --enable-cassert
Next
From: Heikki Linnakangas
Date:
Subject: Re: DropRelFileNodeBuffers API change (was Re: [BUGS] BUG #5599: Vacuum fails due to index corruption issues)