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

Поиск
Список
Период
Сортировка
От terry@greatgulfhomes.com
Тема Re: Bug in 7.2.1? -- ERROR: Adding columns with defaults is not implemented.
Дата
Msg-id 001601c22699$f8156a40$2766f30a@development.greatgulfhomes.com
обсуждение исходный текст
Ответ на Bug in 7.2.1? -- ERROR: Adding columns with defaults is not implemented.  (adwolf1@yahoo.com (ad wolf))
Список 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@greatgulfhomes.com

> -----Original Message-----
> From: pgsql-general-owner@postgresql.org
> [mailto:pgsql-general-owner@postgresql.org]On Behalf Of ad wolf
> Sent: Saturday, July 06, 2002 8:33 PM
> To: pgsql-general@postgresql.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
>




В списке pgsql-general по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Bug in 7.2.1? -- ERROR: Adding columns with defaults is not implemented.
Следующее
От: Peter Schuller
Дата:
Сообщение: Frontend/backend protocol: authentication