Re: Happy column adding (was RE: [HACKERS] Happy column dropping) - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Happy column adding (was RE: [HACKERS] Happy column dropping)
Date
Msg-id 14033.948820995@sss.pgh.pa.us
Whole thread Raw
In response to RE: Happy column adding (was RE: [HACKERS] Happy column dropping)  ("Hiroshi Inoue" <Inoue@tpf.co.jp>)
Responses Re: Happy column adding (was RE: [HACKERS] Happy column dropping)
Re: Happy column adding (was RE: [HACKERS] Happy column dropping)
Re: Happy column adding
List pgsql-hackers
"Hiroshi Inoue" <Inoue@tpf.co.jp> writes:
>>>> Even default is not allowed in ADD COLUMN now.
>> 
>> It's not a matter of *allowed*, it's a parsing deficiency. The fact that
>> there was a default declared gets silently ignored.

> IIRC,there were some reason that default for new column had been rejected.

Well, yeah: wouldn't you expect that "ADD COLUMN x DEFAULT 42" would
cause every row currently existing in the table to acquire x = 42,
rather than x = NULL?  In fact that would *have* to happen to allow
constraints to be added; consider ADD COLUMN x DEFAULT 42 NOT NULL.

The only way to make that happen is for ADD COLUMN to switch over to
an implementation that rewrites all the tuples.  Which I think is the
right way to go ... but per this discussion, it's not a trivial fix.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [SQL] DISTINCT ON: speak now or forever hold your peace
Next
From: Tom Lane
Date:
Subject: Re: Happy column adding (was RE: [HACKERS] Happy column dropping)