ALTER TABLE ... ALTER CONSTRAINT
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
Attachments:
alter_table_alter_constraint.v1.sqlapplication/octet-stream; name=alter_table_alter_constraint.v1.sqlDownload+198-0
On 2013-06-08 21:45:24 +0100, Simon Riggs wrote:
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.
I haven't looked at the patch in detail, but I am very, very much in
favor of the feature in general… I have wished for this more than once,
and it certainly cost me more time working around it than it would have
cost to implement it.
Thanks,
Andres Freund
--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Andres Freund <andres@2ndquadrant.com> wrote:
On 2013-06-08 21:45:24 +0100, Simon Riggs wrote:
ALTER TABLE foo
ALTER CONSTRAINT fktable_fk_fkey DEFERRED INITIALLY IMMEDIATE;
I haven't looked at the patch in detail, but I am very, very much in
favor of the feature in general… I have wished for this more than once
+1
--
Kevin Grittner
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Andres Freund <andres@2ndquadrant.com> writes:
I haven't looked at the patch in detail, but I am very, very much in
favor of the feature in general… I have wished for this more than once,
+1
--
Dimitri Fontaine
http://2ndQuadrant.fr PostgreSQL : Expertise, Formation et Support
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On Mon, Jun 10, 2013 at 11:06 PM, Dimitri Fontaine
<dimitri@2ndquadrant.fr>wrote:
Andres Freund <andres@2ndquadrant.com> writes:
I haven't looked at the patch in detail, but I am very, very much in
favor of the feature in general… I have wished for this more than once,+1
+1. It will be useful.
--
Michael
At 2013-06-08 21:45:24 +0100, simon@2ndQuadrant.com wrote:
ALTER TABLE foo
ALTER CONSTRAINT fktable_fk_fkey DEFERRED INITIALLY IMMEDIATE;
I read the patch (looks good), applied it on HEAD (fine), ran make check
(fine), and played with it in a test database. It looks great, and from
previous responses it's something a lot of people have wished for.
I'm marking this ready for committer.
-- Abhijit
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On Sun, Jun 23, 2013 at 8:58 PM, Abhijit Menon-Sen <ams@2ndquadrant.com>wrote:
At 2013-06-08 21:45:24 +0100, simon@2ndQuadrant.com wrote:
ALTER TABLE foo
ALTER CONSTRAINT fktable_fk_fkey DEFERRED INITIALLY IMMEDIATE;I read the patch (looks good), applied it on HEAD (fine), ran make check
(fine), and played with it in a test database. It looks great, and from
previous responses it's something a lot of people have wished for.I'm marking this ready for committer.
After the commit, I'm now getting the compiler warning:
tablecmds.c: In function 'ATPrepCmd':
tablecmds.c:2953: warning: 'pass' may be used uninitialized in this function
case AT_AlterConstraint (line 3130) is the only case branch that does not
set pass.
Cheers,
Jeff
On 24 June 2013 21:42, Jeff Janes <jeff.janes@gmail.com> wrote:
On Sun, Jun 23, 2013 at 8:58 PM, Abhijit Menon-Sen <ams@2ndquadrant.com>wrote:
At 2013-06-08 21:45:24 +0100, simon@2ndQuadrant.com wrote:
ALTER TABLE foo
ALTER CONSTRAINT fktable_fk_fkey DEFERRED INITIALLY IMMEDIATE;I read the patch (looks good), applied it on HEAD (fine), ran make check
(fine), and played with it in a test database. It looks great, and from
previous responses it's something a lot of people have wished for.I'm marking this ready for committer.
After the commit, I'm now getting the compiler warning:
tablecmds.c: In function 'ATPrepCmd':
tablecmds.c:2953: warning: 'pass' may be used uninitialized in this
functioncase AT_AlterConstraint (line 3130) is the only case branch that does not
set pass.
The investigation is into why my current compiler didn't report that.
Thanks though.
--
Simon Riggs http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
On 24 June 2013 22:17, Simon Riggs <simon@2ndquadrant.com> wrote:
On 24 June 2013 21:42, Jeff Janes <jeff.janes@gmail.com> wrote:
On Sun, Jun 23, 2013 at 8:58 PM, Abhijit Menon-Sen <ams@2ndquadrant.com>wrote:
At 2013-06-08 21:45:24 +0100, simon@2ndQuadrant.com wrote:
ALTER TABLE foo
ALTER CONSTRAINT fktable_fk_fkey DEFERRED INITIALLY IMMEDIATE;I read the patch (looks good), applied it on HEAD (fine), ran make check
(fine), and played with it in a test database. It looks great, and from
previous responses it's something a lot of people have wished for.I'm marking this ready for committer.
After the commit, I'm now getting the compiler warning:
tablecmds.c: In function 'ATPrepCmd':
tablecmds.c:2953: warning: 'pass' may be used uninitialized in this
functioncase AT_AlterConstraint (line 3130) is the only case branch that does not
set pass.The investigation is into why my current compiler didn't report that.
Thanks though.
Looks like that really is a deficiency in my tool chain on OSX, rather than
some bug/user error. Even at the very latest, very shiny version.
Latest versions of gcc trap the error, so I'll have to investigate an
alternative.
--
Simon Riggs http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
Simon Riggs escribi�:
Looks like that really is a deficiency in my tool chain on OSX, rather than
some bug/user error. Even at the very latest, very shiny version.Latest versions of gcc trap the error, so I'll have to investigate an
alternative.
Funnily enough, on Debian Wheezy with gcc 4.7.2 I don't get the warning,
and Andres with gcc 4.7.3 (from Debian unstable) does see it. (Of
course, the 4.8 version shipped with unstable also shows it.)
Clang similarly requires pretty new versions to show the warning.
--
�lvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers