Re: Possible to emulate pre-8.2 behaviour of SET CONSTRAINTS? - Mailing list pgsql-sql

From Tom Lane
Subject Re: Possible to emulate pre-8.2 behaviour of SET CONSTRAINTS?
Date
Msg-id 1893.1169437008@sss.pgh.pa.us
Whole thread Raw
In response to Possible to emulate pre-8.2 behaviour of SET CONSTRAINTS?  ("Simon Kinsella" <simon@bluefiresystems.co.uk>)
List pgsql-sql
"Simon Kinsella" <simon@bluefiresystems.co.uk> writes:
> My system currently runs on PostgreSQL 8.1 and makes use of the old
> behaviour of SET CONSTRAINTS, namely that the command is applied to all
> constraints that match the specified name.

Unfortunately that was pretty far away from what the SQL spec says :-(

> This makes it very easy to write
> a general-case function that can change the DEFERRED mode on a given
> constraint that is present in several similar schemas (sounds odd maybe but
> it works very well in my case!). 

I think you could do it fairly easily still, eg
for rec in select nspname from pg_namespace n join pg_constraint c on n.oid = c.connamespace where conname = $1 loop
     execute 'set constraints ' || quote_ident(rec.nspname) || '.' || quote_ident($1) || ' immediate';       end loop;
 

Exceedingly untested, but something close to this seems like it'd solve
your problem.
        regards, tom lane


pgsql-sql by date:

Previous
From: "Simon Kinsella"
Date:
Subject: Possible to emulate pre-8.2 behaviour of SET CONSTRAINTS?
Next
From: Louis-David Mitterrand
Date:
Subject: list variable attributes in one select