pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
unimplemented functions
3+ messages / 3 participants
[nested] [flat]

* unimplemented functions
@ 2004-03-18 07:15 chris@zenmgt.com
  2004-03-19 14:38 ` Re: unimplemented functions Bill Montgomery <billm@lulu.com>
  2004-03-19 15:32 ` Re: unimplemented functions Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 2 replies; 3+ messages in thread

From: chris@zenmgt.com @ 2004-03-18 07:15 UTC (permalink / raw)
  To: pgsql-admin

I'm new to postgres and pgadmin3 (on Windows XP).

I've just tried to make a change to a table using pgAdmin3 (1.0.2) and I 
get:-

---------------------------
pgAdmin III
---------------------------
An error has occured:

ERROR:  adding columns with defaults is not implemented
HINT:  Add the column, then use ALTER TABLE SET DEFAULT.

---------------------------
OK
---------------------------

When will this be fixed? Is this the right forum for discussing 
unimplemented fuctions? Is there somewhere or someone specific to point is 
out with?




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: unimplemented functions
  2004-03-18 07:15 unimplemented functions chris@zenmgt.com
@ 2004-03-19 14:38 ` Bill Montgomery <billm@lulu.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Bill Montgomery @ 2004-03-19 14:38 UTC (permalink / raw)
  To: pgsql-admin

chris@zenmgt.com wrote:

> I'm new to postgres and pgadmin3 (on Windows XP).
>
> I've just tried to make a change to a table using pgAdmin3 (1.0.2) and 
> I get:-
>
> ---------------------------
> pgAdmin III
> ---------------------------
> An error has occured:
>
> ERROR:  adding columns with defaults is not implemented
> HINT:  Add the column, then use ALTER TABLE SET DEFAULT.
>
> ---------------------------
> OK
> ---------------------------
>
> When will this be fixed? Is this the right forum for discussing 
> unimplemented fuctions? Is there somewhere or someone specific to 
> point is out with?


Chris,

This isn't a pgadmin bug--it is a limitation of Postgres. You can't add 
a column to a table *and* set a default value for it all in one 
statement. Try the hint that is given: add the column, then alter the 
column to set the default value. You can read the details of using the 
ALTER command in the Postgres online documentation.

Regards,

Bill Montgomery



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: unimplemented functions
  2004-03-18 07:15 unimplemented functions chris@zenmgt.com
@ 2004-03-19 15:32 ` Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 0 replies; 3+ messages in thread

From: Tom Lane @ 2004-03-19 15:32 UTC (permalink / raw)
  To: chris@zenmgt.com; +Cc: pgsql-admin

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



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2004-03-19 15:32 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-03-18 07:15 unimplemented functions chris@zenmgt.com
2004-03-19 14:38 ` Bill Montgomery <billm@lulu.com>
2004-03-19 15:32 ` Tom Lane <tgl@sss.pgh.pa.us>

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