Re: ENABLE/DISABLE CONSTRAINT NAME

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: wangshuo(at)highgo(dot)com(dot)cn
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, 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-14 00:17:19
Message-ID: CA+TgmoabJW1D3+xxXkeqH43DKyqPzqk9V4bB0im8wRO09zroLg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Sep 12, 2013 at 10:03 PM, <wangshuo(at)highgo(dot)com(dot)cn> wrote:
> Second, I tested the check and the foreign key constraint as your test
> above.
> And no error found, as fellow:

You're missing the point. Peter wasn't worried that your patch throws
an error; he's concerned about the fact that it doesn't.

In PostgreSQL, you can only create the following view because test1
has a primary key over column a:

=> 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;

The reason that, if the primary key weren't there, it would be
ambiguous which row should be returned as among multiple values where
a is equal and b is not. If you can disable the constraint, then you
can create precisely that problem.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2013-09-14 01:30:39 Re: [PATCH] Add transforms feature
Previous Message Richard Poole 2013-09-13 23:41:25 patch: add MAP_HUGETLB to mmap() where supported (WIP)