X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 0C370D1B18F for ; Mon, 31 May 2004 23:05:10 -0300 (ADT) 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 17782-07 for ; Mon, 31 May 2004 23:05:12 -0300 (ADT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id DE945D1B173 for ; Mon, 31 May 2004 23:05:07 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i5125BBf014141; Mon, 31 May 2004 22:05:12 -0400 (EDT) To: Oleg Mayevskiy Cc: pgsql-sql@postgresql.org Subject: Re: insert or update violates foreign key constraint.why? In-reply-to: References: Comments: In-reply-to Oleg Mayevskiy message dated "Fri, 28 May 2004 15:49:34 +0200" Date: Mon, 31 May 2004 22:05:11 -0400 Message-ID: <14140.1086055511@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200405/231 X-Sequence-Number: 17945 Oleg Mayevskiy writes: > it seems to be a simple problem, but it is not. Yes it is ... you're expecting the RI triggers to fire during the plpgsql function, but in fact they fire at completion of the outer statement that called the plpgsql function. There's been some debate about whether this is really the most desirable behavior, but that's how it is at the moment. regards, tom lane