Re: Bug of ALTER TABLE DROP CONSTRAINT

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Jacky Leng <lengjianquan(at)163(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Bug of ALTER TABLE DROP CONSTRAINT
Date: 2009-04-02 11:55:15
Message-ID: 603c8f070904020455k47229181h58a629ab9b7b3623@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Apr 2, 2009 at 3:25 AM, Jacky Leng <lengjianquan(at)163(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Hiroshi Inoue 2009-04-02 12:03:21 Re: More message encoding woes
Previous Message Robert Haas 2009-04-02 11:50:18 Re: [GENERAL] string_to_array with empty input