Re: enums - Mailing list pgsql-hackers

From Rod Taylor
Subject Re: enums
Date
Msg-id 1130466207.846.40.camel@home
Whole thread Raw
In response to Re: enums  ("Jim C. Nasby" <jnasby@pervasive.com>)
List pgsql-hackers
> > It would just be a standard "ALTER TABLE foo ALTER COLUMN bar TYPE 
> > newtype USING expression" operation. You would write a function that 
> > took a value of the old type and returned a value of the new type and 
> > use a cll to that function in the expression. Since these would be named 
> > types, unlike the case in mysql where they are anonymously defined 
> > inline, this would present no difficulties at all.
> 
> But why force a re-write of the entire table just to change the name of
> something?
> 
> Or is ALTER COLUMN TYPE smart enough to not touch anything if the
> mapping function is equality?

Nearly all ALTER TABLE commands are processed in the same way. In fact,
in some cases they are combined (ADD column is broken down then
re-combined later for a single rewrite).

You could pretty easily add this type of logic to skip the rewrite stage
if not needed.

-- 



pgsql-hackers by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: enums
Next
From: Philip Yarra
Date:
Subject: pl/pgsql breakage in 8.1b4?