Re: to suspend constraints - Mailing list pgsql-general

From Stephan Szabo
Subject Re: to suspend constraints
Date
Msg-id 20030326215126.O70893-100000@megazone23.bigpanda.com
Whole thread Raw
In response to to suspend constraints  ("Jowisz" <jowisz@USUNTO.rozanka.wroc.pl>)
List pgsql-general
On Wed, 26 Mar 2003, Jowisz wrote:

> Does anyone knows, is there any possibility to turn off temporarily (to
> suspend) constraints checking? I couldn't find this in docs. Or maybe there
> isn't way to do things like this...

Not in any easy user-accessable way that I know of (apart from dropping a
constraint and re-adding it).

If you're willing to go through some moderately painful changing of system
tables, you can stop foreign keys (and all user defined triggers) by
setting reltriggers to 0 in pg_class, but you have to be careful to set it
back to the correct value.  You can (at least in current sources) do
something similar for check constraints with relchecks AFAICS.  NOT NULL
can be controlled with attnotnull in the pg_attribute row for the
particular attribute.  I don't know of a reasonable way to turn off unique
(flipping indisunique in the pg_index row seems to not take effect
immediately if the index has been used in your session, and I'm really not
sure it's safe in any case).


pgsql-general by date:

Previous
From: "shreedhar"
Date:
Subject: Re: trigger question.
Next
From: Tom Lane
Date:
Subject: Re: [HACKERS] Solution to UPDATE...INSERT problem