From: Carlos Moreno <moreno@mochima.com>
To: pgsql-sql@postgresql.org
Subject: Re: Update aborted if trigger function fails?
Date: Tue, 12 Apr 2005 10:55:30 -0400
Message-ID: <425BE162.6010501@mochima.com> (raw)
In-Reply-To: <425B7920.4040002@archonet.com>
References: <425ADE3F.1090206@mochima.com>
<425B7920.4040002@archonet.com>
Richard Huxton wrote:
>> I just noticed this (odd?) behaviour, and it kind of
>> scares me.
>
>> Isn't this a little fragile? Is there something I
>> could do to avoid this situation? Should trigger
>> functions be extremely simple as to guarantee that
>> an error would never happen?
>
> There's nothing else it can do, really. Far better that the whole update
> fails than you get an inconsistent database.
>
> Imagine you have a banking system, and every time you add a row to the
> transaction-history, you update the "current_balance" table. Which would
> you prefer, both updates fail, or the two get out of sync?
Yes, you are absolutely correct.
I guess the concern came up as result of a particular
situation, in which failing to properly process the
trigger function is not that crucial (I wanted to
update some additional information that is "optional",
and that can be reconstructed easily after discovering
that the trigger function had been failing). But in
our case, failing to complete the update is rather
critical (things can be reconstructed but under certain
conditions only, and only by temporarily shutting down
the system for a few minutes).
So, I was thinking that there may be a way for the user
to instruct PG to ignore the fact that the trigger
function failed -- that way, we would overcome the
difficulties that you mention in improving dependency
checking when functions are involved -- PG wouldn't have
to determine it: the user would tell it.
> So - how do you deal with this? Well, you test.
Fair enough.
Thanks!
Carlos
--
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: moreno@mochima.com
Subject: Re: Update aborted if trigger function fails?
In-Reply-To: <425BE162.6010501@mochima.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox