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

From: "Simon Kinsella" <simon(at)bluefiresystems(dot)co(dot)uk>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: FW: Possible to emulate pre-8.2 behaviour of SET CONSTRAINTS?
Date: 2007-01-22 10:50:15
Message-ID: 20070122105038.805CA19F306@smtp07l.fasthosts.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-patches pgsql-sql


That sounds like a plan - will give it a go. Thanks!

simon

-----Original Message-----
From: Tom Lane [mailto:tgl(at)sss(dot)pgh(dot)pa(dot)us]
Sent: Monday, January 22, 2007 3:37 AM
To: Simon Kinsella
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: [SQL] Possible to emulate pre-8.2 behaviour of SET CONSTRAINTS?

"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

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Achilleas Mantzios 2007-01-22 11:12:04 server process (PID xxx) was terminated by signal 7
Previous Message Rajesh Kumar Mallah 2007-01-22 08:05:59 Re: Getting previous statements executed a backend currenly in an <idle> in transaction state.

Browse pgsql-patches by date

  From Date Subject
Next Message Achilleas Mantzios 2007-01-22 11:12:04 server process (PID xxx) was terminated by signal 7
Previous Message Adriaan van Os 2007-01-22 09:19:25 Re: [HACKERS] BUG #2907: pg_get_serial_sequence quoting

Browse pgsql-sql by date

  From Date Subject
Next Message Achilleas Mantzios 2007-01-22 11:12:04 server process (PID xxx) was terminated by signal 7
Previous Message A. Kretschmer 2007-01-22 08:24:02 Re: list variable attributes in one select