Re: Execute Shell script after insert

From: Sam Mason <sam(at)samason(dot)me(dot)uk>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Execute Shell script after insert
Date: 2008-10-28 12:25:17
Message-ID: 20081028122517.GT2459@frubble.xen.chris-lamb.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Oct 27, 2008 at 04:16:16PM -0400, Tom Lane wrote:
> Sam Mason <sam(at)samason(dot)me(dot)uk> writes:
> > when something goes wrong (as code inevitably does) the database
> > will continue doing things automatically for you (like touching the
> > filesystem) when you're fighting against it trying to fix things.
>
> The usual explanation of why this is a bad idea is that if the
> transaction aborts at some point after running the trigger, then the
> INSERT effectively didn't happen --- but the trigger's
> outside-the-database effects still happened, and there's no way to cause
> them to roll back. So you will inevitably end up with the database
> being out of sync with whatever you're trying to use the trigger to update.

Yes, that's probably better.

As a meta-comment, doing things in a stored procedure is still subject
to rollback (albeit with *many* less provisos) and hence there's still a
possibility of things getting out of step with each other. In general,
multiple failure domains (i.e. more than one) are difficult however
they are arranged. This is mainly why databases are nice, you can
normally just hide away in your own little world and pretend that there
is only one failure domain and, as an added bonus, it's even got nice
transactional semantics.

Sam

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Andrew Sullivan 2008-10-28 12:28:54 Re: Archiving WAL for 7.4.21
Previous Message Brent Austin 2008-10-28 12:22:55 [Help] Config Failure on Mac OSX: psqlodbc-08.03.0300