From: | Bruce Momjian <bruce(at)momjian(dot)us> |
---|---|
To: | Simon Riggs <simon(at)2ndQuadrant(dot)com> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: ALTER TABLE .... make constraint DEFERRABLE |
Date: | 2010-06-03 01:06:12 |
Message-ID: | 201006030106.o5316Cv00489@momjian.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Simon Riggs wrote:
>
> Deferrable unique constraints seem an interesting feature, though I have
> either some questions or some issues, not sure which.
>
> I don't seem to be able to find any way to do an ALTER TABLE that adds
> this new capability to an existing table.
I was able to do it:
test=> create table test (x int unique DEFERRABLE INITIALLY DEFERRED);
NOTICE: CREATE TABLE / UNIQUE will create implicit index "test_x_key"
for table "test"
CREATE TABLE
test=> alter table test add column y int;
ALTER TABLE
test=> alter table test add unique (y) DEFERRABLE INITIALLY DEFERRED;
NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index
"test_y_key" for table "test"
ALTER TABLE
Is that what you were asking?
> There is no way to add a constraint via a CREATE TABLE AS SELECT, so
> that means there is no way to use the feature at all in that case.
Uh, CREATE TABLE AS SELECT seems to be very limited, but I have not
heard any complaints about it before.
> Also, foreign keys can't be defined that refer to a deferrable primary
> key. That isn't mentioned at all in the manual with regard to the
> DEFERRABLE clause, though it is mentioned in the FK section. You get
> this error message
> ERROR: cannot use a deferrable unique constraint for referenced table
>
> The use case for this feature looks a little narrow at present. Can we
> do something about usability?
Not sure why that was a limitation.
--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ None of us is going to be here forever. +
From | Date | Subject | |
---|---|---|---|
Next Message | Florian Pflug | 2010-06-03 01:07:49 | Re: recovery getting interrupted is not so unusual as it used to be |
Previous Message | Stephen Frost | 2010-06-03 00:47:10 | Re: Keepalive for max_standby_delay |