From: | Jan Wieck <JanWieck(at)Yahoo(dot)com> |
---|---|
To: | gearond(at)cvc(dot)net |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: before and after triggers |
Date: | 2003-04-04 18:58:48 |
Message-ID: | 3E8DD5E8.EF9349C@Yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Dennis Gearon wrote:
>
> 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?)
It does not abort the transaction and they can silently suppress
DELETE's too.
> 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.
They only see the final result up to the row they are fired for. Since
the following is right, they would need the ability to predict the
future in an INSERT or UPDATE that affects multiple rows.
>
> ALL TRIGGERS
> Are not DEFERRABLE in anyway. They happen immediately:
> AFTER or BEFORE each ROW is acted upon.
Jan
--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck(at)Yahoo(dot)com #
From | Date | Subject | |
---|---|---|---|
Next Message | nolan | 2003-04-04 19:00:05 | Getting consecutive sequence values |
Previous Message | Tom Lane | 2003-04-04 18:55:20 | Re: before and after triggers |