Received: from chronozon.artofdns.com (cr466046-a.etob1.on.wave.home.com [24.42.158.249]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f5IKcJa77113 for ; Mon, 18 Jun 2001 16:38:19 -0400 (EDT) (envelope-from stef@chronozon.artofdns.com) Received: from chronozon.artofdns.com (cr466046-a.etob1.on.wave.home.com [24.42.158.249]) by chronozon.artofdns.com (Postfix) with SMTP id CBAA2C7F2 for ; Mon, 18 Jun 2001 16:43:20 -0400 (EDT) Content-Type: text/plain; charset="iso-8859-1" From: Stef Telford Organization: Hades Inc To: pgsql-sql@postgresql.org Subject: Referential Integrity Question (Delete/Insert during Transaction) Date: Mon, 18 Jun 2001 16:43:16 -0400 X-Mailer: KMail [version 1.2] References: <3B2E6D28.17314.A02C932@localhost> In-Reply-To: <3B2E6D28.17314.A02C932@localhost> MIME-Version: 1.0 Message-Id: <01061816431601.11299@chronozon.artofdns.com> Content-Transfer-Encoding: 8bit X-Archive-Number: 200106/274 X-Sequence-Number: 3535 hello again everyone, I seem to have hit what i -think- may be a bug (but i am not crying wolf jst yet ;). I have three tables. action, client and order_details. action has a primary key 'order', client references action (along with adding the client_id as part of its primary key), order_details references client (both parts of the primary key there). all foreign keys (order in client and order+client_id in order_details) are set to INITIALLY DEFERRED. so far so good i hope. Now, i have a trigger that fires on insert, so i delete from the live database and then insert the changes rather than doing an update. not great, but shouldnt be a problem. The problem comes when i do this: mms_post=# BEGIN; BEGIN mms_post=# DELETE from client WHERE order_id = 22; DELETE 1 mms_post=# INSERT INTO client mms_post-#(cli_business_name,cli_chain_id,cli_business_type,cli_short_name,cl i_sic,order_id,client_id,cli_agent_bank_id,cli_operating_name,creation_id,cli_ web_page,cli_tcc,creation_date) mms_post-# VALUES ('STEFS','100-000000000333',1,'FHASDLKJH HFAKSDJ HKALSDJ',2534,22,'100-00000000555',230,'FHASDLKJH HFAKSDJ HKALSDJFH','jack','fgahsk@afsdhfkja.net','R','2001-06-18 13:46:45-04'); INSERT 24211 1 mms_post=# COMMIT; ERROR: referential integrity violation - key in client still referenced from order_details Now. the way i understand it, shouldnt the integrity of any foreign keys be checked at the -end- of the transaction, after all the commands have been processed ? it seems that the DELETE is being processed and rejected, but the foreign key would be 'okay' due to the following INSERT. I have tried SET CONSTRAINTS as well with no difference :\ Does this make any sense or am i completely mad ? (more than likely) regards, Stefs.