Re: Making a unique constraint deferrable?

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Ivan Voras <ivoras(at)gmail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Making a unique constraint deferrable?
Date: 2017-02-28 17:10:43
Message-ID: CAKFQuwa4WeboO=5pMhPFU6VXYS=Q_0j-OrT0jszu871fwa7MbQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Feb 28, 2017 at 10:05 AM, Ivan Voras <ivoras(at)gmail(dot)com> wrote:

> On 28 February 2017 at 18:03, David G. Johnston <
> david(dot)g(dot)johnston(at)gmail(dot)com> wrote:
>
>> On Tue, Feb 28, 2017 at 9:50 AM, Ivan Voras <ivoras(at)gmail(dot)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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Yasin Sari 2017-02-28 17:19:35 Re: json aggregation question
Previous Message Ivan Voras 2017-02-28 17:05:13 Re: Making a unique constraint deferrable?