Re: Re: a primer on trigger?

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Chris Jones <chris(at)mt(dot)sri(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Re: a primer on trigger?
Date: 2001-05-04 21:52:56
Message-ID: Pine.BSF.4.21.0105041438150.61624-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Fri, 4 May 2001, Chris Jones wrote:

> On Fri, May 04, 2001 at 12:59:54PM -0700, Stephan Szabo wrote:
>
> > The problem is that you have the problem in reverse then, unless what's
> > done by the trigger is "optional" sortof. What happens if there is an
> > error, and you can't do the outside operation? You once again end up
> > out of sync with the database, but this time the outside thing is missing
> > the records. You still need something to come in every so often and make
> > sure stuff is correct.
> >
> > This whole class of things is just ugly.
>
> I'm a little weak on database theory, but isn't this what two-phase
> commit is for?

I'm very weak on database theory, but the problem here is trying to
interface to external things. With an after commit trigger, you can know
that the rows are committed safely, but what happens if your external
interface fails. Even if you can rollback the database changes, what
about previous external changes that were made assuming that we were
successful. For example:

transaction adds three rows
transaction commits
post-trigger sends mail 1
post-trigger sends mail 2
post-trigger attempts to send mail 3, but for some reason it fails.
<Now we want to uncommit the rows. But we also want to
unsend the 2 mails to keep everything in the same state>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message newsreader 2001-05-04 22:00:58 Re: a primer on trigger?
Previous Message Fran Fabrizio 2001-05-04 21:50:59 subtratcing dates