Re: ENABLE/DISABLE CONSTRAINT NAME

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: wangshuo(at)highgo(dot)com(dot)cn
Cc: David Johnston <polobo(at)yahoo(dot)com>, Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>, Jeff Davis <pgsql(at)j-davis(dot)com>
Subject: Re: ENABLE/DISABLE CONSTRAINT NAME
Date: 2013-09-12 21:23:49
Message-ID: 523230E5.9050708@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 9/11/13 1:09 AM, wangshuo(at)highgo(dot)com(dot)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.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kevin Grittner 2013-09-12 22:27:27 record identical operator
Previous Message Kevin Grittner 2013-09-12 19:21:04 Re: lcr v5 - primary/candidate key in relcache