before and after triggers - Mailing list pgsql-general

From Dennis Gearon
Subject before and after triggers
Date
Msg-id 3E8DCC40.1030501@cvc.net
Whole thread Raw
Responses Re: before and after triggers  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
Re: before and after triggers  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
After reading the manual, this point didn't seem to have been made. Trigger
fucntions are supposed to return OPAQUE, (i.e. 'void' in 'C/++' syntax). But the
manuals also say that BEFORE triggers can return NULL to avoid the INSERT or
UPDATE from occurring. Is this contradictory? Is that actually ONE way to avoid
a UPDATE or INSERTION from happening?

My understanding, inferred different parts of diffeent manuals, is the below,
correct me if I'm wrong:

BEFORE TRIGGERS
    Can change the values in the NEW Tuple for:
        INSERTS and UPDATES.
    Can void the action of:
        INSERTS and UPDATES
        by returning NULL. (does this kill the transaction?)
    Can stop completely an action with an error message for:
        INSERTS,DELETES, and UPDATES
        by RAISING an EXCEPTION. (This DOES Kill the xaction)

AFTER TRIGGERS
    Can stop completely an action with an error message:
        INSERTS,DELETES, and UPDATES
        by RAISING an EXCEPTION. (This DOES Kill the xaction)
    Have the advantage of seeing the final results of
        an action on a table before canceling it.

ALL TRIGGERS
    Are not DEFERRABLE in anyway. They happen immediately:
        AFTER or BEFORE each ROW is acted upon.



pgsql-general by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: feature request - adding columns with default value
Next
From: Stephan Szabo
Date:
Subject: Re: before and after triggers