Re: Bug in 7.2.1? -- ERROR: Adding columns with defaults is not implemented.

From: terry(at)greatgulfhomes(dot)com
To: "'ad wolf'" <adwolf1(at)yahoo(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Bug in 7.2.1? -- ERROR: Adding columns with defaults is not implemented.
Date: 2002-07-08 16:10:24
Message-ID: 001601c22699$f8156a40$2766f30a@development.greatgulfhomes.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Although in 7.1 you did not get the error message, I do not believe the
setting default or NOT NULL actually did anything (I am certain for 7.0).

7.2 no longer silently ignores the issue, it aborts with an error message.

It is easy too set the default in a second statement:
ALTER TABLE t1 ALTER COLUMN c1 SET DEFAULT 'default';

To implement the NOT NULL you either have to drop and recreate the table
(which is what I do) or manually insert the appropriate trigger (Ugh).

What I do is add the column without the NOT NULL or default,
then use the ALTER TABLE to set the column default,
then use pg_dump -t tablename databasename > table_backup
then vi table_backup and change the NULL to NOT NULL for the column
then drop the table
then reload the table with the NOT NULL constraint with:
psql -e database < table_backup

Hope this helps.

PS I highly recommend 7.2, there is a lot of good usefull stuff in there,
eg outer joins

Terry Fielder
Network Engineer
Great Gulf Homes / Ashton Woods Homes
terry(at)greatgulfhomes(dot)com

> -----Original Message-----
> From: pgsql-general-owner(at)postgresql(dot)org
> [mailto:pgsql-general-owner(at)postgresql(dot)org]On Behalf Of ad wolf
> Sent: Saturday, July 06, 2002 8:33 PM
> To: pgsql-general(at)postgresql(dot)org
> Subject: [GENERAL] Bug in 7.2.1? -- ERROR: Adding columns
> with defaults
> is not implemented.
>
>
> Using pg 7.1.2, I can enter the following statement successfully:
>
> # alter table manufacturer add column dummy integer not null default
> 1;
>
> However, under 7.2.1, the same statement gets me --
>
> ERROR: Adding columns with defaults is not implemented.
> Add the column, then use ALTER TABLE SET DEFAULT.
>
> My question is two-fold -- first, is this new behavior a feature, or a
> bug?
>
> Second, what features/fixes would i lose by reverting to 7.1.2?
>
> I'd like to stick with 7.2.1, but this new behavior is making it
> difficult for me. I can't simply drop & recreate all my tables just
> to add a column!
>
> Any help would be appreciated!
>
> adam
>
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Peter Schuller 2002-07-08 16:11:34 Frontend/backend protocol authentication
Previous Message Stephan Szabo 2002-07-08 16:10:23 Re: PostgreSQL doesn't use indexes even is enable_seqscan