Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WVZ1F-0004Oe-Kq for pgsql-general@arkaria.postgresql.org; Thu, 03 Apr 2014 04:12:49 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WVZ1F-0000YI-3U for pgsql-general@arkaria.postgresql.org; Thu, 03 Apr 2014 04:12:49 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WVZ1C-0000Y7-Qb for pgsql-general@postgresql.org; Thu, 03 Apr 2014 04:12:46 +0000 Received: from mail-oa0-x229.google.com ([2607:f8b0:4003:c02::229]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WVZ16-0003aJ-Dw for pgsql-general@postgresql.org; Thu, 03 Apr 2014 04:12:46 +0000 Received: by mail-oa0-f41.google.com with SMTP id j17so1391352oag.0 for ; Wed, 02 Apr 2014 21:12:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=dJRijQjmnHsvMCnKGCAvCjr1xmCIVhkKiXQpGZaD2wU=; b=vJisx49JyHz3Ddgz9DdQvpCaUvZCZilL45PEUhU/PsCPGNC4OGiFmQrprABncaNB69 RFEQsHZjJyReSw0FrNroXzdqHmPBcUbeVzL52M+RtmBDdGFjaSgjP9LSrH9AaeZu+s/+ 2yLyvLfywfJn2y9njDG5c2QMDVIxgixImFEWUsrqmwqQxHlqOoQliRIMMnODr4FvnEOL 4U9ZPb+VjqJZUZIiYaP0NWq9dC/islj+zLmSMPQYK8415N4C9Pve+jXxcHnTzj/OY+WM Xm5Ogpt0z/cwR1ieAg5N7iq9VWlaJXGMB7dBmkiHv5GbRya1d7mOnH1AghU0Uy++IaWv hs6A== X-Received: by 10.60.160.201 with SMTP id xm9mr78623oeb.50.1396498358784; Wed, 02 Apr 2014 21:12:38 -0700 (PDT) MIME-Version: 1.0 Received: by 10.76.169.98 with HTTP; Wed, 2 Apr 2014 21:12:18 -0700 (PDT) In-Reply-To: <3036.1396497272@sss.pgh.pa.us> References: <3036.1396497272@sss.pgh.pa.us> From: Amit Langote Date: Thu, 3 Apr 2014 13:12:18 +0900 Message-ID: Subject: Re: Table Rewrite During ALTER TABLE ... ADD COLUMN ... DEFAULT NULL To: Tom Lane Cc: Postgres General Content-Type: text/plain; charset=UTF-8 X-Pg-Spam-Score: -1.8 (-) 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 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 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 -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general