Re: Need "InBetween" (not just Before and After) Trigger

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Matt Doucleff <matt(at)digitalfountain(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Need "InBetween" (not just Before and After) Trigger
Date: 2001-01-14 04:17:32
Message-ID: 14399.979445852@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Matt Doucleff <matt(at)digitalfountain(dot)com> writes:
> I want a trigger to happen after constraint checking but before row
> insertion.

In other words, you'd like your trigger to be able to violate the
constraints?

This does *not* strike me as a good idea.

> If I use a "before" trigger, the constraints are checked after I've
> already performed my action. Thus I have performed my action yet no
> row is inserted (which is inconsistent).

> If I use an "after" trigger, the constraints are checked first. If
> the row is inserted, I attempt to perform my action. If my action
> fails, then I have an inserted row but no action, which is also
> inconsistent.

Seems to me this is all irrelevant, because in either case, the first
action will be rolled back if the second one fails. There might be
some marginal amount of time wasted, which you could minimize by
arranging things so that the more-likely-to-fail action is done first.
But I see no correctness issue.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Thomas T. Thai 2001-01-14 05:25:06 performance hit with --enable-debug
Previous Message Alvar Freude 2001-01-13 23:38:00 Re: Compare dates.