X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (mx2.hub.org [200.46.204.254]) by postgresql.org (Postfix) with ESMTP id DF17E11F6D5B for ; Thu, 13 Apr 2006 15:29:37 -0300 (ADT) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Score: -1.747 X-Spam-Level: X-Spam-Status: No, score=-1.747 required=5 tests=[AWL=-0.217, BAYES_00=-2.599, SPF_NEUTRAL=1.069] Received: from postgresql.org ([200.46.204.71]) by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) with ESMTP id jD21ZTkyvZpf for ; Thu, 13 Apr 2006 15:29:30 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) by postgresql.org (Postfix) with ESMTP id 0010711F6CB3 for ; Thu, 13 Apr 2006 15:29:28 -0300 (ADT) Received: from [172.16.5.67] (64-132-13-2.gen.twtelecom.net [64.132.13.2]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by noel.decibel.org (Postfix) with ESMTP id 1E56956423; Thu, 13 Apr 2006 13:29:28 -0500 (CDT) In-Reply-To: <26792.1144949880@sss.pgh.pa.us> References: <1144135482.063425.33380@z34g2000cwc.googlegroups.com> <20060411225515.GZ49405@pervasive.com> <200604121603.43986.josh@agliodbs.com> <20060413001024.GP49405@pervasive.com> <6236.1144888514@sss.pgh.pa.us> <4D23826E-7325-4946-B79A-80E321E0E497@gmail.com> <26792.1144949880@sss.pgh.pa.us> Mime-Version: 1.0 (Apple Message framework v749.3) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: Cc: Christian Storm , Josh Berkus , pgsql-performance@postgresql.org, PFC Content-Transfer-Encoding: 7bit From: Jim Nasby Subject: Re: pgmemcache Date: Thu, 13 Apr 2006 13:29:25 -0500 To: Tom Lane X-Mailer: Apple Mail (2.749.3) X-Archive-Number: 200604/310 X-Sequence-Number: 18394 On Apr 13, 2006, at 12:38 PM, Tom Lane wrote: > Christian Storm writes: >> Not sure if I follow why this is a problem. Seems like it would be >> beneficial to have both BEFORE and AFTER COMMIT triggers. >> With the BEFORE COMMIT trigger you would have the ability to 'un- >> commit' (rollback) the transaction. With >> the AFTER COMMIT trigger you wouldn't have that option because the >> commit has already been successful. However, >> with an AFTER COMMIT you would be able to trigger other downstream >> events that rely on a transaction successfully committing. > > An AFTER COMMIT trigger would have to be in a separate transaction. > What happens if there's more than one, and one of them fails? Even > more to the point, if it's a separate transaction, don't you have > to fire all these triggers again when you commit that transaction? > The idea seems circular. I suspect that in reality you'd probably want each on-commit trigger to be it's own transaction, but it depends on what you're doing. Also, I can't see any use for them where you'd actually be interacting with the database, only if you were calling something externally via a function. One example would be sending an email out when a certain table changes; in many cases it's better to let the change happen even if the email can't be sent, and you'd rather not send an email if the transaction just ends up rolling back for some reason. And yes, you'd have to ensure you didn't code yourself up a trigger loop. -- Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com Pervasive Software http://pervasive.com work: 512-231-6117 vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461