From: Tom Lane <tgl@sss.pgh.pa.us>
To: chris@zenmgt.com
Cc: pgsql-admin@postgresql.org
Subject: Re: unimplemented functions
Date: Fri, 19 Mar 2004 10:32:50 -0500
Message-ID: <24446.1079710370@sss.pgh.pa.us> (raw)
In-Reply-To: <opr41qfqyl6gy8po@news.gmane.org>
References: <opr41qfqyl6gy8po@news.gmane.org>
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
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: tgl@sss.pgh.pa.us, chris@zenmgt.com
Subject: Re: unimplemented functions
In-Reply-To: <24446.1079710370@sss.pgh.pa.us>
References: <opr41qfqyl6gy8po@news.gmane.org> <24446.1079710370@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox