Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WVYjt-0003ow-1J for pgsql-general@arkaria.postgresql.org; Thu, 03 Apr 2014 03:54:53 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WVYjr-0004TZ-UH for pgsql-general@arkaria.postgresql.org; Thu, 03 Apr 2014 03:54:51 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WVYjq-0004SE-Rl for pgsql-general@postgresql.org; Thu, 03 Apr 2014 03:54:50 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WVYja-0003Fs-0z for pgsql-general@postgresql.org; Thu, 03 Apr 2014 03:54:50 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id s333sWun003037; Wed, 2 Apr 2014 23:54:32 -0400 From: Tom Lane To: Amit Langote cc: Postgres General Subject: Re: Table Rewrite During ALTER TABLE ... ADD COLUMN ... DEFAULT NULL In-reply-to: References: Comments: In-reply-to Amit Langote message dated "Thu, 03 Apr 2014 12:31:51 +0900" Date: Wed, 02 Apr 2014 23:54:32 -0400 Message-ID: <3036.1396497272@sss.pgh.pa.us> X-Pg-Spam-Score: -2.5 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-general Precedence: bulk Sender: pgsql-general-owner@postgresql.org 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 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 (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general