X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 802CF9DC97D for ; Wed, 1 Mar 2006 14:23:52 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 54750-10 for ; Wed, 1 Mar 2006 14:23:52 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from r1.mycybernet.net (r1.mycybernet.net [209.5.206.8]) by postgresql.org (Postfix) with ESMTP id 77AC39DC821 for ; Wed, 1 Mar 2006 14:23:49 -0400 (AST) Received: from 227-54-222-209.mycybernet.net ([209.222.54.227]:40246 helo=phlogiston.dydns.org) by r1.mycybernet.net with esmtp (Exim 4.50 (FreeBSD)) id 1FEVzK-000D7Q-6C for pgsql-sql@postgresql.org; Wed, 01 Mar 2006 13:23:50 -0500 Received: by phlogiston.dydns.org (Postfix, from userid 1000) id D333A4040; Wed, 1 Mar 2006 13:23:45 -0500 (EST) Date: Wed, 1 Mar 2006 13:23:45 -0500 From: Andrew Sullivan To: pgsql-sql@postgresql.org Subject: Re: Help with trigger that updates a row prior to a potentially aborted deletion? Message-ID: <20060301182345.GJ17356@phlogiston.dyndns.org> References: <20060301133041.8EFFA19B797@smtp03l.fasthosts.co.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20060301133041.8EFFA19B797@smtp03l.fasthosts.co.uk> User-Agent: Mutt/1.5.9i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.078 required=5 tests=[AWL=0.078] X-Spam-Score: 0.078 X-Spam-Level: X-Archive-Number: 200603/15 X-Sequence-Number: 24361 On Wed, Mar 01, 2006 at 01:30:23PM -0000, Simon Kinsella wrote: > I'm trying to achieve this with a BEFORE DELETE trigger, which would set the > 'marked_for_deletion' field to TRUE before attempting the delete proper. > Then if the DELETE fails the row would still be tagged and I'd be happy. > Problem is, when the DELETE operation fails with a RESTRICT VIOLATION error > the entire operation is rolled back, including the BEFORE triggers, leaving > me back where I started. Yes. In 8.1, you could use a subtransaction for the DELETE, which I think would allow you to rollback at that point and still leave the UPDATE in place. A -- Andrew Sullivan | ajs@crankycanuck.ca The fact that technology doesn't work is no bar to success in the marketplace. --Philip Greenspun