From: | Nikhil Sontakke <nikhil(dot)sontakke(at)enterprisedb(dot)com> |
---|---|
To: | Robert Haas <robertmhaas(at)gmail(dot)com> |
Cc: | Jacky Leng <lengjianquan(at)163(dot)com>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Bug of ALTER TABLE DROP CONSTRAINT |
Date: | 2009-04-02 12:24:48 |
Message-ID: | a301bfd90904020524q25197c22o2e69a87cb0f1180@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
> > 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,
Yeah it will be a matter of finding the affected column entries and invoking
the removal of the not null entry from their corresponding pg_attribute
rows.
> but I'm not really sure there's much point, since the situation is
> rare and the workaround is easy.
>
Yeah and it is documented already. Although it is not obvious immediately
that a not-null attribute gets tagged onto the involved columns separately
for primary, unique-not-null types of constraints.
Regards,
Nikhils
--
http://www.enterprisedb.com
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2009-04-02 13:05:05 | Re: Bug of ALTER TABLE DROP CONSTRAINT |
Previous Message | Hiroshi Inoue | 2009-04-02 12:03:21 | Re: More message encoding woes |