X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 536519FA3B3 for ; Fri, 19 May 2006 13:42:06 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 91740-01 for ; Fri, 19 May 2006 13:42:00 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by postgresql.org (Postfix) with ESMTP id 6C6089FA22C for ; Fri, 19 May 2006 13:42:00 -0300 (ADT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 14BE7351CC; Fri, 19 May 2006 09:41:59 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 11D1E351C6; Fri, 19 May 2006 09:41:59 -0700 (PDT) Date: Fri, 19 May 2006 09:41:59 -0700 (PDT) From: Stephan Szabo To: Kaloyan Iliev Cc: pgsql-sql@postgresql.org Subject: Re: Problem with SET CONSTRAINTS ALL DEFERRED; In-Reply-To: <446DAC63.1080701@faith.digsys.bg> Message-ID: <20060519094126.S89276@megazone.bigpanda.com> References: <446DAC63.1080701@faith.digsys.bg> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/156 X-Sequence-Number: 25187 On Fri, 19 May 2006, Kaloyan Iliev wrote: > Hi Friends, > > I am trying to postpone the foreign key constraint check till the end of > transaction but it doesn't work. > Can anyone help me with a tip what I am doing wrong. Was the constraint created as deferrable (which is not the default)? ALL DEFERRED actually only applies to deferrable constraints. > > Thanks in advance. > > Kaloyan Iliev > > test=# BEGIN; > BEGIN > test=# > test=# SET CONSTRAINTS ALL DEFERRED; > SET CONSTRAINTS > test=# DELETE FROM picture > test-# USING > element_picture > test-# WHERE > picture.id = element_picture.picture_id > test-# > AND element_picture.element_id = 8; > ERROR: update or delete on "picture" violates foreign key constraint > "picture_id" on "element_picture" > DETAIL: Key (id)=(223) is still referenced from table "element_picture". > > > select version(); > version > ------------------------------------------------------------------------------------------------ > PostgreSQL 8.1.2 on i386-portbld-freebsd6.0, compiled by GCC cc (GCC) > 3.4.4 [FreeBSD] 20050518 > (1 row) > > > ---------------------------(end of broadcast)--------------------------- > TIP 1: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly >