Re: [GENERAL] Table Rewrite During ALTER TABLE ... ADD COLUMN ... DEFAULT NULL

2014-04-02 Thread Amit Langote
On Thu, Apr 3, 2014 at 1:19 PM, Tom Lane wrote: > Amit Langote writes: >> On Thu, Apr 3, 2014 at 12:54 PM, Tom Lane wrote: >>> 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

Re: [GENERAL] Table Rewrite During ALTER TABLE ... ADD COLUMN ... DEFAULT NULL

2014-04-02 Thread Amit Langote
On Thu, Apr 3, 2014 at 1:19 PM, Tom Lane wrote: > Amit Langote writes: >> On Thu, Apr 3, 2014 at 12:54 PM, Tom Lane wrote: >>> 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

Re: [GENERAL] Table Rewrite During ALTER TABLE ... ADD COLUMN ... DEFAULT NULL

2014-04-02 Thread Tom Lane
Amit Langote writes: > On Thu, Apr 3, 2014 at 12:54 PM, Tom Lane wrote: >> 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 elid

Re: [GENERAL] Table Rewrite During ALTER TABLE ... ADD COLUMN ... DEFAULT NULL

2014-04-02 Thread Amit Langote
On Thu, Apr 3, 2014 at 12:54 PM, Tom Lane wrote: > Amit Langote 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 c

Re: [GENERAL] Table Rewrite During ALTER TABLE ... ADD COLUMN ... DEFAULT NULL

2014-04-02 Thread Tom Lane
Amit Langote 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 claus

[GENERAL] Table Rewrite During ALTER TABLE ... ADD COLUMN ... DEFAULT NULL

2014-04-02 Thread Amit Langote
Hi, 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). http://www.postgresql.org/docs/devel/static/sql-altertable.html As