Re: constraint modification on todo list

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jeroen Ruigrok/asmodai <asmodai(at)wxs(dot)nl>
Cc: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: constraint modification on todo list
Date: 2003-09-08 21:22:42
Message-ID: 3128.1063056162@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Jeroen Ruigrok/asmodai <asmodai(at)wxs(dot)nl> writes:
> Because what I can imagine, and please correct me if I miss something in
> my thought pattern, you have a small gap between dropping a constraint
> and adding the new one allowing the possibility of missing checks.

If you're concerned about concurrent transactions, you should do the
change like this:

begin;
alter table drop constraint ...;
alter table add constraint ...;
commit;

which leaves no window for missed checks. (The first ALTER will take
out an exclusive lock on the table, which will be held till end of
transaction.)

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2003-09-08 21:29:10 Re: pgsql in shared lib
Previous Message Tom Lane 2003-09-08 21:19:13 Re: ISO 8601 "Time Intervals" of the "format with time-unit deignators"