ALTER TABLE ADD COLUMN - Mailing list pgsql-hackers

From Chris Bitmead
Subject ALTER TABLE ADD COLUMN
Date
Msg-id 3753BF99.9C23F094@bigfoot.com
Whole thread Raw
In response to Re: [HACKERS] CVS  (Todd Graham Lewis <tlewis@mindspring.net>)
Responses Re: [HACKERS] ALTER TABLE ADD COLUMN
List pgsql-hackers
Hi guys. I was trying to add a column to a class again. The class is low
down in an inheritance hierarchy.

This time, I remembered to add the * after the table name, so I thought
that I was ok. Everything seemed ok, and the database went on working as
expected for ages.

Then one day I had to restore my database and I found again that pg_dump
doesn't work with
ERROR:  pg_atoi: error in "1999-05-10 16:27:40+10": can't parse "-05-10
16:27:40+10"

because I think it dumps columns in the wrong order.

Fortunately I was able to restore the database by abandoning that column
and removing it from the table definition. Fortunately I didn't  have
much data in that column that was too much loss to lose (yet).

I know I mentioned this problem before, but I thought it was because I
had forgotten the "*" on the ALTER TABLE ADD COLUMN statement. Now I
realise that even when you remember it, you can be bitten. Worse, you
can be bitten much later after you've forgotten what was the cause.

I'm not sure what to do now. I really do need to add that extra column.
If I thought really really hard, I might be able to figure out how to do
it with Perl, re-arrangement of columns etc. But I've got a lot of
tables and it sounds all too hard. The frustrating thing is that adding
the columns actually works. It's just that it can't be restored properly
after a catastrophy.



-- 
Chris Bitmead
http://www.bigfoot.com/~chris.bitmead
mailto:chris.bitmead@bigfoot.com


pgsql-hackers by date:

Previous
From: Vadim Mikheev
Date:
Subject: LOCKTAG updated -> gmake clean is required
Next
From: Chris Bitmead
Date:
Subject: pg_dump