> 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.