From: Jeff Frost <jeff@frostconsultingllc.com>
To: Richard Huxton <dev@archonet.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-sql@postgresql.org
Subject: Re: update before drop causes OID problems in transaction?
Date: Mon, 20 Mar 2006 09:18:17 -0800 (PST)
Message-ID: <Pine.LNX.4.64.0603200910200.30710@discord.dyndns.org> (raw)
In-Reply-To: <441EB977.3000706@archonet.com>
References: <Pine.LNX.4.64.0603171434230.11424@discord.dyndns.org>
<10754.1142635969@sss.pgh.pa.us>
<Pine.LNX.4.64.0603171454170.11424@discord.dyndns.org>
<Pine.LNX.4.64.0603172012190.11424@discord.dyndns.org>
<13574.1142663266@sss.pgh.pa.us>
<Pine.LNX.4.64.0603172233140.11424@discord.dyndns.org>
<13832.1142664905@sss.pgh.pa.us>
<Pine.LNX.4.64.0603181802170.11424@discord.dyndns.org>
<441EB977.3000706@archonet.com>
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 <jeff@frostconsultingllc.com>
Frost Consulting, LLC http://www.frostconsultingllc.com/
Phone: 650-780-7908 FAX: 650-649-1954
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: jeff@frostconsultingllc.com, dev@archonet.com, tgl@sss.pgh.pa.us
Subject: Re: update before drop causes OID problems in transaction?
In-Reply-To: <Pine.LNX.4.64.0603200910200.30710@discord.dyndns.org>
References: <Pine.LNX.4.64.0603171434230.11424@discord.dyndns.org> <10754.1142635969@sss.pgh.pa.us> <Pine.LNX.4.64.0603171454170.11424@discord.dyndns.org> <Pine.LNX.4.64.0603172012190.11424@discord.dyndns.org> <13574.1142663266@sss.pgh.pa.us> <Pine.LNX.4.64.0603172233140.11424@discord.dyndns.org> <13832.1142664905@sss.pgh.pa.us> <Pine.LNX.4.64.0603181802170.11424@discord.dyndns.org> <441EB977.3000706@archonet.com> <Pine.LNX.4.64.0603200910200.30710@discord.dyndns.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox