public inbox for [email protected]  
help / color / mirror / Atom feed
From: Tom Lane <[email protected]>
To: Amit Langote <[email protected]>
Cc: Postgres General <[email protected]>
Subject: Re: Table Rewrite During ALTER TABLE ... ADD COLUMN ... DEFAULT NULL
Date: Wed, 02 Apr 2014 23:54:32 -0400
Message-ID: <[email protected]> (raw)
In-Reply-To: <CA+HiwqE35_+z0_gFw9mp=_0MLgPfb=+QY910LG7C-sBNTvqdgg@mail.gmail.com>
References: <CA+HiwqE35_+z0_gFw9mp=_0MLgPfb=+QY910LG7C-sBNTvqdgg@mail.gmail.com>
List-Unsubscribe: <mailto:[email protected]?body=unsub%20pgsql-general>

Amit Langote <[email protected]> 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.

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.

			regards, tom lane


-- 
Sent via pgsql-general mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



view thread (9+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: Table Rewrite During ALTER TABLE ... ADD COLUMN ... DEFAULT NULL
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox