Re: ALTER TABLE modifications - Mailing list pgsql-patches

From Rod Taylor
Subject Re: ALTER TABLE modifications
Date
Msg-id 1068828247.35839.80.camel@jester
Whole thread Raw
In response to Re: ALTER TABLE modifications  (Dave Cramer <pg@fastcrypt.com>)
List pgsql-patches
> lock table
> create newtable as select c1, c2, c3::newtype
> modify pg_class to point to the new filename
> modify existing pg_attribute for the column in question
> recreate indexes that exist on the column
> unlock table

I actually tried this to start with an ran into several dead-ends in
trying to rebuild constraints, defaults, etc.  In order to do this I
think you would need to create a second pg_class entry and do a full
table swap.

By far, the easiest method to preserve order without writing a ton of
additional code is to do something that is on the TODO list already,
separate the visible position from physical position.

Doing the above has lots of added benefits, where spending a ton of time
on TYPE change has very few benefits.


pgsql-patches by date:

Previous
From: Tom Lane
Date:
Subject: Re: ALTER TABLE modifications
Next
From: Peter Eisentraut
Date:
Subject: Re: ALTER TABLE modifications