add column .. default - Mailing list pgsql-hackers

From Rod Taylor
Subject add column .. default
Date
Msg-id 1055988581.23385.48.camel@jester
Whole thread Raw
Responses Re: add column .. default
List pgsql-hackers
I took a quick glance at this.

It boils down to essentially an:

1) ALTER TABLE .. ADD COLUMN <column> DEFAULT <default> <constraints>
2) UPDATE .. SET <column> = <default> IF <default> IS NOT NULL;
3) Add <constraints> including NOT NULL, CHECK, Foreign Key, etc. each
of which will do it's own confirmation pass on the values inserted into
the table by step 2 for the table for the new column.

If all additional constraints are added after the values are in the
table (via standard ALTER TABLE functions), is there anything the update
(step 2) needs to check aside from Domain constraints (coerce <default>
to datatype of <column>)?

For the update I intend to use double space, as if the user did those
items as individual commands within the same transaction.  Someone can
make it more efficient in regards to constraint checks, etc. in the
future if they want -- I don't intend to.

--
Rod Taylor <rbt@rbt.ca>

PGP Key: http://www.rbt.ca/rbtpub.asc

pgsql-hackers by date:

Previous
From: "Matthew T. O'Connor"
Date:
Subject: Re: Two weeks to feature freeze
Next
From: Alvaro Herrera
Date:
Subject: Re: Two weeks to feature freeze