Received: from megazone.bigpanda.com ([63.150.15.178]) by postgresql.org (8.11.3/8.11.4) with ESMTP id fAK87tm68663 for ; Tue, 20 Nov 2001 03:07:56 -0500 (EST) (envelope-from sszabo@megazone23.bigpanda.com) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 547F5D5E6; Tue, 20 Nov 2001 00:07:56 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 4A3155BE7; Tue, 20 Nov 2001 00:07:56 -0800 (PST) Date: Tue, 20 Nov 2001 00:07:56 -0800 (PST) From: Stephan Szabo To: Tom Lane Cc: Subject: Re: Foreign Key Constraint Deletion Order In-Reply-To: <27655.1006229491@sss.pgh.pa.us> Message-ID: <20011120000343.G53451-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Archive-Number: 200111/287 X-Sequence-Number: 5669 On Mon, 19 Nov 2001, Tom Lane wrote: > writes: > > Am I asking for too much, or RI and triggers were not > > designed for operations like this example in the > > first place? > > The problem is that RI is implemented by triggers, and there's > no guarantees about the firing order of multiple triggers. > So you don't know whether your custom triggers will fire > before or after the RI actions occur. Even specifying the after trigger order wouldn't help him I think. He'd want the deletion of the details rows and their associated triggers to run before the actual deletion of the master row. I'd guess that would require the cascade delete to be being done as a before delete trigger.