Re: ALTER TABLE ADD COLUMN can't use NOT NULL?

From: "Christopher Kings-Lynne" <chriskl(at)familyhealth(dot)com(dot)au>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Bradley McLean" <brad(at)bradm(dot)net>
Cc: <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: ALTER TABLE ADD COLUMN can't use NOT NULL?
Date: 2001-11-13 01:38:46
Message-ID: GNELIHDDFBOCMGBFGEFOEEGACAAA.chriskl@familyhealth.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> Bradley McLean <brad(at)bradm(dot)net> writes:
> > In the CVS tip from this morning:
> > a123=# alter table test add test1 int4 not null;
> > ERROR: Adding NOT NULL columns is not implemented.
> > Add the column, then use ALTER TABLE ADD CONSTRAINT.
>
> > I'm pretty sure the first one used to work just fine.
>
> No, it never worked per spec. The spec requires the constraint to
> be enforced immediately, and since the values of the new column
> would all be null, there's no way for this to be a legal command.
>
> What's legal per spec is an ADD that provides a DEFAULT along with
> specifying NOT NULL. But we don't support ADD with a DEFAULT yet :-(

As far as I am aware, we don't even support using ALTER TABLE ADD CONSRAINT
to add a NOT NULL constraint, so I have no idea why the ERROR: message tells
people to do that!!!

Or am I wrong?

Chris

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Christopher Kings-Lynne 2001-11-13 01:44:16 Regression test database still stuffed
Previous Message mlw 2001-11-12 23:19:14 Re: rename index?