Re: Possible to emulate pre-8.2 behaviour of SET CONSTRAINTS?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Simon Kinsella" <simon(at)bluefiresystems(dot)co(dot)uk>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Possible to emulate pre-8.2 behaviour of SET CONSTRAINTS?
Date: 2007-01-22 03:36:48
Message-ID: 1893.1169437008@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

"Simon Kinsella" <simon(at)bluefiresystems(dot)co(dot)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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Louis-David Mitterrand 2007-01-22 07:43:48 list variable attributes in one select
Previous Message Simon Kinsella 2007-01-21 23:52:28 Possible to emulate pre-8.2 behaviour of SET CONSTRAINTS?