Re: [GENERAL] Making a unique constraint deferrable? - Mailing list pgsql-general

From David G. Johnston
Subject Re: [GENERAL] Making a unique constraint deferrable?
Date
Msg-id CAKFQuwa4WeboO=5pMhPFU6VXYS=Q_0j-OrT0jszu871fwa7MbQ@mail.gmail.com
Whole thread Raw
In response to Re: [GENERAL] Making a unique constraint deferrable?  (Ivan Voras <ivoras@gmail.com>)
List pgsql-general
On Tue, Feb 28, 2017 at 10:05 AM, Ivan Voras <ivoras@gmail.com> wrote:
On 28 February 2017 at 18:03, David G. Johnston <david.g.johnston@gmail.com> wrote:
On Tue, Feb 28, 2017 at 9:50 AM, Ivan Voras <ivoras@gmail.com> wrote:

ivoras=# alter table foo alter constraint "foo_a_b_key" deferrable;
ERROR:  constraint "foo_a_b_key" of relation "foo" is not a foreign key constraint


​A more clear error message would be:

EROR:  cannot alter non-foreign key constraint "foo_a_b_key"​ of relation "foo"

Though I'm not sure how that meshes with the error message style guides...


Any idea what underlying technical reason prohibits marking non-fk constraints as deferrable?


Not off hand - but a unique (and PK by extension) constraint is implemented by creating an underlying unique index​ and the ALTER CONSTRAINT command probably doesn't want to go messing around with that.  While the columns involved in a FK constraint can also be indexed the two concepts are not physically linked together.

David J.

pgsql-general by date:

Previous
From: Ivan Voras
Date:
Subject: Re: [GENERAL] Making a unique constraint deferrable?
Next
From: Yasin Sari
Date:
Subject: Re: [GENERAL] json aggregation question