X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id D4D36D1EC3D for ; Fri, 19 Mar 2004 15:32:56 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 44645-09 for ; Fri, 19 Mar 2004 11:32:50 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 60603D1E9B7 for ; Fri, 19 Mar 2004 11:32:46 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2JFWou8024447; Fri, 19 Mar 2004 10:32:50 -0500 (EST) To: chris@zenmgt.com Cc: pgsql-admin@postgresql.org Subject: Re: unimplemented functions In-reply-to: References: Comments: In-reply-to chris@zenmgt.com message dated "Thu, 18 Mar 2004 18:15:16 +1100" Date: Fri, 19 Mar 2004 10:32:50 -0500 Message-ID: <24446.1079710370@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200403/261 X-Sequence-Number: 12830 chris@zenmgt.com writes: > ERROR: adding columns with defaults is not implemented > HINT: Add the column, then use ALTER TABLE SET DEFAULT. > When will this be fixed? Probably not very soon, as it is easily worked around, and the spec-mandated behavior is not necessarily what you want anyway. ALTER TABLE t ADD COLUMN c INT DEFAULT 42; is equivalent per SQL spec to ALTER TABLE t ADD COLUMN c INT; ALTER TABLE t ALTER COLUMN c SET DEFAULT 42; UPDATE t SET c = DEFAULT; That last step is fairly expensive since it forces an update of every row of the table. (The ALTERs themselves only touch catalog data and are cheap even with large tables.) If you are intending to load the new column with non-default values then you probably don't really want the UPDATE step. Without it, the new column will read as NULL until you get around to setting it. regards, tom lane