Re: [HACKERS] ALTER TABLE ADD COLUMN - Mailing list pgsql-hackers

From Chris Bitmead
Subject Re: [HACKERS] ALTER TABLE ADD COLUMN
Date
Msg-id 37547FC3.40106A5E@bigfoot.com
Whole thread Raw
In response to Re: [HACKERS] ALTER TABLE ADD COLUMN  (Bruce Momjian <maillist@candle.pha.pa.us>)
List pgsql-hackers
Bruce Momjian wrote:

> Our TODO now has:
> 
>         * ALTER TABLE ADD COLUMN to inherited table put column in wrong place
> 
> I don't think any of us understand the issues on this one.

Let me guess at the problem. When you add a column, it doesn't change
all the records, therefore the column must be added at the end. This
means that the columns will not be in the same order as if you had
created them from scratch.

There seem to be three solutions:
a) Go to a much more sophisticated schema system, with versions and
version numbers (fairly hard but desirable to fix other schema change
problems). Then insert the column in the position it is supposed to be
in.

b) Fix the copy command to input and output the columns, not in the
order they are in, but in the order they would be in on re-creation.

c) make the copy command take arguments specifying the field names, like
INSERT can do.

I think it would be good if Postgres had all 3 features. Probably (b) is
the least work.


pgsql-hackers by date:

Previous
From: darcy@druid.net ("D'Arcy" "J.M." Cain)
Date:
Subject: INET and CIDR comparisons
Next
From: "Hiroshi Inoue"
Date:
Subject: RE: [HACKERS] Open 6.5 items