X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 411F0D1B56B for ; Wed, 13 Aug 2003 15:55:23 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 34763-06 for ; Wed, 13 Aug 2003 12:53:46 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 47997D1B53A for ; Wed, 13 Aug 2003 12:55:12 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3509144; Wed, 13 Aug 2003 08:55:35 -0700 Content-Type: text/plain; charset="iso-8859-2" From: Josh Berkus Organization: Aglio Database Solutions To: "=?iso-8859-2?q?SZ=DBCS?= =?iso-8859-2?q?=20G=E1bor?=" , Subject: Re: Order of triggers - totally lost Date: Wed, 13 Aug 2003 08:55:04 -0700 User-Agent: KMail/1.4.3 References: <001001c36183$4f636570$0403a8c0@fejleszt4> <200308130754.32211.jgardner@jonathangardner.net> <003e01c361b1$37d02780$0403a8c0@fejleszt4> In-Reply-To: <003e01c361b1$37d02780$0403a8c0@fejleszt4> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200308130855.04062.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/139 X-Sequence-Number: 14755 G: > * what is sure about trigger execution order? > (Cristoph Haller partially answered my question, quoting future plans) My perspective: multiple triggers of the same type on the same table are a really bad idea if execution order matters. Any setup like this is automatically maintenence hell, even when we add some sort of "trigger priority" feature. If your table needs multiple BEFORE operations, you should put the operations into one large procedure with branching logic. > * are there generic recommendations what kind of things to put in > before and after triggers? before triggers: re-formating input and inserting complex defaults before saving to table; historical archiving of old data; data validation. after triggers: updating related tables; chronological logging of activity. > * how about FOR EACH STATEMENT triggers? > (we only use FOR EACH ROW triggers) These will not work until 7.4, and then there will be some limitations (which will hopefully go away in 7.5). -- Josh Berkus Aglio Database Solutions San Francisco