Re: ENABLE/DISABLE CONSTRAINT NAME - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: ENABLE/DISABLE CONSTRAINT NAME
Date
Msg-id 523230E5.9050708@gmx.net
Whole thread Raw
In response to Re: ENABLE/DISABLE CONSTRAINT NAME  (wangshuo@highgo.com.cn)
Responses Re: ENABLE/DISABLE CONSTRAINT NAME
List pgsql-hackers
On 9/11/13 1:09 AM, wangshuo@highgo.com.cn wrote:
> Peter Eisentraut wrote:
>> Note that other schema objects can depend on the existence of
>> constraints.  For example, the validity of a view might depend on the
>> existence of a primary key constraint.  What would you do with the view
>> if the primary key constraint is temporarily disabled?
>>
> 
> Thanks for your reply.
>  I could't  clearly understand your opinion,  could you give  me more
> information or example?

=> create table test1 (a int constraint pk primary key, b text);
=> create view test2 as select a, b from test1 group by a;
=> alter table test1 drop constraint pk;
ERROR:  2BP01: cannot drop constraint pk on table test1 because other
objects depend on it
DETAIL:  view test2 depends on constraint pk on table test1
HINT:  Use DROP ... CASCADE to drop the dependent objects too.

(This has to do with whether ungrouped columns are allowed in the select
list when the presence of constraints ensures well-defined results.)

When trying to drop the constraint, the choice is to abort the drop or
to drop dependent objects.  When you are talking about
enabling/disabling the constraint, it's not clear what to do.




pgsql-hackers by date:

Previous
From: Kevin Grittner
Date:
Subject: Re: lcr v5 - primary/candidate key in relcache
Next
From: Kevin Grittner
Date:
Subject: record identical operator