ALTER TABLE ... ALTER CONSTRAINT

From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: ALTER TABLE ... ALTER CONSTRAINT
Date: 2013-06-08 20:45:24
Message-ID: CA+U5nML4d_HJfp2+hcbYQcGA_Y30nxt+Yu-44KVtQgcSJB09+w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

While fiddling with FK tuning, it was useful to be able to enable and
disable the DEFERRED mode of constraints.

That is not currently possible in SQL, so I wrote this patch. Without
this you have to drop and then re-add a constraint, which is
impractical for large tables.

e.g.
CREATE TABLE fktable (id integer, fk integer REFERENCES pktable (id));

ALTER TABLE foo
ALTER CONSTRAINT fktable_fk_fkey DEFERRED INITIALLY IMMEDIATE;

Includes docs and tests.

Currently works for FKs only. Potentially other constraints can be
supported in future.

--
Simon Riggs http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

Attachment Content-Type Size
alter_table_alter_constraint.v1.sql application/octet-stream 11.3 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Smith 2013-06-08 20:57:36 Re: Cost limited statements RFC
Previous Message Jeff Janes 2013-06-08 20:43:27 Re: Cost limited statements RFC