From: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
---|---|
To: | Joshua Kramer <josh(at)bitbuckets(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Trigger Behavior in Transactions |
Date: | 2005-12-26 16:06:53 |
Message-ID: | 200512261606.jBQG6rv02710@candle.pha.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Joshua Kramer wrote:
>
> Greetings,
>
> Where in the documentation can I find information on the low-level
> behavior of triggers that fire as a result of insert/update statements
> inside of transactions?
>
> Do the triggers fire at the point the transaction is COMMITted? Or as
> soon as the statements are encountered? (If this is the case, how are
> rollbacks done - does the trigger also fire for the rollback?)
>
> I am creating a mechanism for updating PG databases remotely (from another
> PG database) for a magazine article I'm writing, and I need to figure out
> how to engineer the trigger mechamisms so they work properly.
These are complex questions. Triggers fire at the end of the statement,
unless they are DEFERRRED (look that up). I recommend you look up MVCC
to see how triggers fired on statement end are automatically rolled back
on abort, meaning we don't re-run the triggers on abort, the changes
the trigger made are ignored by other backends.
--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
From | Date | Subject | |
---|---|---|---|
Next Message | Zlatko Matić | 2005-12-26 18:03:14 | Re: ODBC connection string, MS Access |
Previous Message | Bruno Wolff III | 2005-12-25 15:00:24 | Re: newbie : setting access for users in a web enviroment |