X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 6F67BD1B529 for ; Thu, 23 Oct 2003 13:54:59 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 56494-06 for ; Thu, 23 Oct 2003 10:54:32 -0300 (ADT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by svr1.postgresql.org (Postfix) with ESMTP id 757FAD1B517 for ; Thu, 23 Oct 2003 10:54:28 -0300 (ADT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 9952A352CB; Thu, 23 Oct 2003 06:54:13 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 98106352C9; Thu, 23 Oct 2003 06:54:13 -0700 (PDT) Date: Thu, 23 Oct 2003 06:54:13 -0700 (PDT) From: Stephan Szabo To: Alvaro Herrera Cc: Peter Childs , "scott.marlowe" , pgsql-general@postgresql.org Subject: Re: Trigger In-Reply-To: <20031023114719.GA23703@dcc.uchile.cl> Message-ID: <20031023064929.I12332@megazone.bigpanda.com> References: <20031023114719.GA23703@dcc.uchile.cl> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/1123 X-Sequence-Number: 51196 On Thu, 23 Oct 2003, Alvaro Herrera wrote: > On Thu, Oct 23, 2003 at 08:16:27AM +0100, Peter Childs wrote: > > > > > > On Wed, 22 Oct 2003, scott.marlowe wrote: > > > > > On Wed, 22 Oct 2003, Peter Childs wrote: > > > > > > > Is it possible to deferr a trigger until commit, Or to have the > > > > trigger not occur if the transaction is rolled back? Like transaction. > > > > Background, we are trying to get the database to tell clients when > > records get updated, deleted or inserted so that they can update there > > on-screen displays without having to query the database every couple of > > seconds which would put an unnessary strain on the database. Hence > > producing quicker respose times. > > You should probably be using an AFTER trigger ... when those get > executed, the transaction is ready to commit and will not abort (barring > any major problems, like your server go nuts or something). This is not true, actually. After triggers generally happen at the end of statement (with the exception of deferred constraint triggers and some wierdness with functions) and can themselves throw an exception condition so even barring internal problems, it's unsafe to assume that an exception won't happen after your trigger runs.