Re: 7.3.3 ADD COLUMN wierdness

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Brian O'Donoghue" <bodonoghue(at)stockbyte(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org, kguest(at)stockbyte(dot)com
Subject: Re: 7.3.3 ADD COLUMN wierdness
Date: 2003-06-16 14:38:55
Message-ID: 2815.1055774335@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"Brian O'Donoghue" <bodonoghue(at)stockbyte(dot)com> writes:
> ALTER TABLE blah ADD COLUMN whatever integer not null;
> Adding NOT NULL columns is not implemented.
> Add the column, then use ALTER TABLE ... SET NOT NULL.

> Hmm, the last time I checked, this should have worked.

Although 7.1 allowed that, it did not work correctly --- the NOT NULL
wasn't checked. 7.3 is aware that it can't handle it :-).

You can do ALTER TABLE ADD COLUMN, then UPDATE to fill all the rows
with a suitable value, then ALTER again to set the NOT NULL constraint.

Yeah, it's a pain, but no one's gotten around to writing the code that
would be needed to handle doing this in one step.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2003-06-16 14:45:13 Re: 7.3.3 ADD COLUMN wierdness
Previous Message Brian O'Donoghue 2003-06-16 13:43:41 Re: 7.3.3 ADD COLUMN wierdness