Re: Table Rewrite During ALTER TABLE ... ADD COLUMN ... DEFAULT NULL - Mailing list pgsql-general

From Amit Langote
Subject Re: Table Rewrite During ALTER TABLE ... ADD COLUMN ... DEFAULT NULL
Date
Msg-id CA+HiwqGzakcVbKbfxv6ThNcAmp_ZgakagKTM1u80PAF2mnNVcQ@mail.gmail.com
Whole thread Raw
In response to Re: Table Rewrite During ALTER TABLE ... ADD COLUMN ... DEFAULT NULL  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Table Rewrite During ALTER TABLE ... ADD COLUMN ... DEFAULT NULL
List pgsql-general
On Thu, Apr 3, 2014 at 12:54 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Amit Langote <amitlangote09@gmail.com> writes:
>> When I do the following:
>
>> ALTER TABLE table ADD COLUMN numeric(x) DEFAULT NULL;
>
>> The table is rewritten whereas notes section on the manual page for
>> ALTER TABLE says otherwise (which holds true for most of the cases
>> though).
>
> Try it without the explicit DEFAULT clause.
>

Thanks, that does the trick.

> Some experimentation suggests that we are smart about "DEFAULT NULL"
> unless the column type requires a length-coercion cast, in which
> case the default expression involves a function call, and that doesn't
> get elided.
>

Is there a warning about such behavior in the manual?
Is it useful to include it somewhere (not sure where though)?

--
Amit


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Table Rewrite During ALTER TABLE ... ADD COLUMN ... DEFAULT NULL
Next
From: Tom Lane
Date:
Subject: Re: Table Rewrite During ALTER TABLE ... ADD COLUMN ... DEFAULT NULL