Re: Bug of ALTER TABLE DROP CONSTRAINT - Mailing list pgsql-hackers

From Robert Haas
Subject Re: Bug of ALTER TABLE DROP CONSTRAINT
Date
Msg-id 603c8f070904020455k47229181h58a629ab9b7b3623@mail.gmail.com
Whole thread Raw
In response to Bug of ALTER TABLE DROP CONSTRAINT  ("Jacky Leng" <lengjianquan@163.com>)
Responses Re: Bug of ALTER TABLE DROP CONSTRAINT  (Nikhil Sontakke <nikhil.sontakke@enterprisedb.com>)
List pgsql-hackers
On Thu, Apr 2, 2009 at 3:25 AM, Jacky Leng <lengjianquan@163.com> wrote:
> Considering the following sequence:
>    create table t(a int primary key);
>    alter table t drop constraint t_pkey;
>    insert into t values(null);
>    ERROR:  null value in column "a" violates not-null constraint
>
> My question is, why "null" is not allowed to be inserted after primary key
> constraint has been dropped.

Making a column into the primary key forces the column to NOT NULL.
You'll need to DROP NOT NULL separately.

It's probably possible to beat on the code hard enough to fix this,
but I'm not really sure there's much point, since the situation is
rare and the workaround is easy.

...Robert


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: [GENERAL] string_to_array with empty input
Next
From: Hiroshi Inoue
Date:
Subject: Re: More message encoding woes