Re: Bug of ALTER TABLE DROP CONSTRAINT

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 13:17:48
Message-ID: a301bfd90904020617p20d41a1ag63b266825f707546@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

> >>
> >> 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.
>
> Actually it's more complicated than that. You'd need to remember
> whether or not the NOT NULL was added when the primary key was added,
> or whether it was there before, and only drop it if it wasn't there
> before.
>

Hmm, and maybe that is the reason why this is not clubbed with the removal
of the primary constraint. Otherwise it seems to be a matter of decompiling
the conkey and generating AT_DropNotNull nodes for the involved columns
within ATPrepCmd and the rest should happen automatically. So I guess we can
let it be.

Regards,
Nikhils
--
http://www.enterprisedb.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2009-04-02 14:01:18 Re: Bug of ALTER TABLE DROP CONSTRAINT
Previous Message Magnus Hagander 2009-04-02 13:07:25 Path case sensitivity on windows