From: | Dennis Gearon <gearond(at)cvc(dot)net> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | before and after triggers |
Date: | 2003-04-04 18:17:36 |
Message-ID: | 3E8DCC40.1030501@cvc.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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.
From | Date | Subject | |
---|---|---|---|
Next Message | Stephan Szabo | 2003-04-04 18:33:18 | Re: before and after triggers |
Previous Message | Stephan Szabo | 2003-04-04 17:41:35 | Re: feature request - adding columns with default value |