before and after triggers

Поиск
Список
Период
Сортировка
От Dennis Gearon
Тема before and after triggers
Дата
Msg-id 3E8DCC40.1030501@cvc.net
обсуждение исходный текст
Ответы Re: before and after triggers  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
Re: before and after triggers  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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 по дате отправления:

Предыдущее
От: Stephan Szabo
Дата:
Сообщение: Re: feature request - adding columns with default value
Следующее
От: Stephan Szabo
Дата:
Сообщение: Re: before and after triggers