X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 94A449DCCAD for ; Mon, 20 Mar 2006 13:18:27 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 24253-05-2 for ; Mon, 20 Mar 2006 13:18:25 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from smtp102.sbc.mail.mud.yahoo.com (smtp102.sbc.mail.mud.yahoo.com [68.142.198.201]) by postgresql.org (Postfix) with SMTP id 9C4CF9DCB48 for ; Mon, 20 Mar 2006 13:18:24 -0400 (AST) Received: (qmail 2886 invoked from network); 20 Mar 2006 17:18:20 -0000 Received: from unknown (HELO discord.dyndns.org) (jeffroe996@sbcglobal.net@69.226.238.225 with plain) by smtp102.sbc.mail.mud.yahoo.com with SMTP; 20 Mar 2006 17:18:20 -0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by discord.dyndns.org (8.13.4/8.13.4) with ESMTP id k2KHIHYH031555; Mon, 20 Mar 2006 09:18:17 -0800 Date: Mon, 20 Mar 2006 09:18:17 -0800 (PST) From: Jeff Frost X-X-Sender: jeff@discord.dyndns.org To: Richard Huxton cc: Tom Lane , pgsql-sql@postgresql.org Subject: Re: update before drop causes OID problems in transaction? In-Reply-To: <441EB977.3000706@archonet.com> Message-ID: References: <10754.1142635969@sss.pgh.pa.us> <13574.1142663266@sss.pgh.pa.us> <13832.1142664905@sss.pgh.pa.us> <441EB977.3000706@archonet.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.118 required=5 tests=[AWL=0.118] X-Spam-Score: 0.118 X-Spam-Level: X-Archive-Number: 200603/312 X-Sequence-Number: 24658 On Mon, 20 Mar 2006, Richard Huxton wrote: >> I stripped the tables and queries down to the minimum that demonstrated the >> error. Interestingly, the problem was not reproducible until I added the >> credit_card_audit_account_id constraint below: >> >> CONSTRAINT credit_card_audit_account_id_fkey FOREIGN KEY (account_id) >> REFERENCES accounts_basics (id) MATCH FULL >> ON UPDATE NO ACTION ON DELETE NO ACTION DEFERRABLE INITIALLY DEFERRED > > I'm not sure a deferred constraint makes sense if you're dropping the table > before the end of the transaction. I'm not sure whether the DROP should be > prevented or what other error should be provided, but I can't see how both > the constraint and the drop can occur. Indeed much of this transaction might not make sense as it is really all done just for schema change and not part of normal operation. And in fact, you're correct that removing the DEFERRABLE property of the constraint allows the transaction to commit, so the workaround for my update as part of the transaction problem would be to set constraints immediate as part of that transaction like so: SET CONSTRAINTS credit_card_audit_account_id_fkey IMMEDIATE; And indeed this does work. > Another problem might well be with your plpgsql trigger function. If you're > dropping/re-creating credit_card_audit then that'll give you the error you're > seeing. The trigger shouldn't be firing at all in this scenario as it is on credit_card and not credit_card_audit. Are you saying that it could cause this sort of problem even though it doesn't fire? -- Jeff Frost, Owner Frost Consulting, LLC http://www.frostconsultingllc.com/ Phone: 650-780-7908 FAX: 650-649-1954