ALTER TABLE ... DISABLE TRIGGERS Isolation leve

From: CG <cgg007(at)yahoo(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: ALTER TABLE ... DISABLE TRIGGERS Isolation leve
Date: 2011-05-09 17:05:38
Message-ID: 577889.30680.qm@web37906.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I'm using 8.4.1

I want to add a column to a table, but there are update triggers that will fire that don't need to fire for this operation. So, I'd like to add the column with triggers off. Normally this operation would take 10 or so seconds, so locking the table for that amount of time is not a big deal. I just want to make sure that no new data gets written to the table while the triggers are disabled.

BEGIN;
ALTER TABLE foo ADD COLUMN bar DISABLE TRIGGER USER;
COMMIT;

seems to leave the triggers disabled.

My tests seem to show that

BEGIN;
ALTER TABLE foo DISABLE TRIGGER USER;

locks the table fully, then

ALTER TABLE foo ADD COLUMN bar;
ALTER TABLE foo ENABLE TRIGGER USER;
COMMIT;

gets the job done. I only pause because I figured that the single DISABLE triggerin transaction would have flopped back when the transaction committed. I was wrong about that.... I only need a little bit of affirmation or a kick in the right direction.

Thanks folks.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Merlin Moncure 2011-05-09 18:01:23 Re: stunnel with just postgresql client part
Previous Message tv 2011-05-09 15:29:11 Re: simple update query too long