Re: Help with trigger - Mailing list pgsql-novice

From Michael Fuhr
Subject Re: Help with trigger
Date
Msg-id 20041008140206.GA60144@winnie.fuhr.org
Whole thread Raw
In response to Re: Help with trigger  (Michael Fuhr <mike@fuhr.org>)
List pgsql-novice
On Fri, Oct 08, 2004 at 12:52:52AM -0600, Michael Fuhr wrote:

> The trigger function below, fired after inserts and updates, might
> be close to what you need.  However, it doesn't enforce the 2-tuple
> limit -- it only contains the logic to delete records based on the
> criteria you specified.  It worked in the minimal tests I performed,
> but I'd recommend doing more thorough testing before using it in
> production.

I should also point out that the trigger function I posted doesn't
deal with concurrency.  For example, if an update happens in one
transaction, and an insert happens in another transaction before
the update commits, then you could end up with two records that
should have been deleted but weren't.  The function I posted was
merely to show how one might perform the tests you need to make.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

pgsql-novice by date:

Previous
From: Michael Fuhr
Date:
Subject: Re: Help with trigger
Next
From: "Keith Worthington"
Date:
Subject: how to stop postmaster