Thread: Are triggers part of the transaction block that triggered the trigger?

Are triggers part of the transaction block that triggered the trigger?

From
Philip Hallstrom
Date:
Hi all -
    Are triggers part of the transaction block that triggered the
trigger?  I mean if I have a trigger that updates (an insert) a table (say
for logging or whatever) and that insert fails will the original query the
fired the trigger also get rolled back?

I'm using 7.0.3.

Thanks!

-philip




Re: Are triggers part of the transaction block that triggered the trigger?

From
"Robert B. Easter"
Date:
On Wednesday 03 January 2001 13:28, you wrote:
> Hi all -
>     Are triggers part of the transaction block that triggered the
> trigger?  I mean if I have a trigger that updates (an insert) a table (say
> for logging or whatever) and that insert fails will the original query the
> fired the trigger also get rolled back?

In my experience with PL/pgSQL triggers, yes.  Like, if I do RAISE EXCEPTION
in the trigger, then the whole transaction the trigger was part of gets
abort/rollback.  Some of the triggers were called recusively when the trigger
would do an update which would cause the trigger to get called again for a
different row.  An exeception in any of the recursive calls of the trigger
would rollback everything that happened recursively too.

--
-------- Robert B. Easter  reaster@comptechnews.com ---------
-- CompTechNews Message Board http://www.comptechnews.com/ --
-- CompTechServ Tech Services http://www.comptechserv.com/ --
---------- http://www.comptechnews.com/~reaster/ ------------