Re: to suspend constraints

Lists: pgsql-general
From: "Jowisz" <jowisz(at)USUNTO(dot)rozanka(dot)wroc(dot)pl>
To: pgsql-general(at)postgresql(dot)org
Subject: to suspend constraints
Date: 2003-03-26 00:54:59
Message-ID: b5qtp9$47p$1@nemesis.news.tpi.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Hello,

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...

Thanks in advance & greets
Adam


From: Jules Alberts <root(at)localhost(dot)localdomain(dot)invalid>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: to suspend constraints
Date: 2003-03-26 07:15:30
Message-ID: slrnb82kgj.dn2.root@systemec.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

* Jowisz <jowisz(at)USUNTO(dot)rozanka(dot)wroc(dot)pl> Wed, 26 Mar 2003 01:54:59 +0100:
> Hello,
>
> 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...
>
> Thanks in advance & greets Adam

Have a look at DEFERRABLE and INITIALLY DEFERRED in the CREATE TABLE
statement.


From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Jowisz <jowisz(at)USUNTO(dot)rozanka(dot)wroc(dot)pl>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: to suspend constraints
Date: 2003-03-27 05:59:52
Message-ID: 20030326215126.O70893-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: 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).