Re: enums - Mailing list pgsql-hackers

From Jim C. Nasby
Subject Re: enums
Date
Msg-id 20051028182327.GK13187@pervasive.com
Whole thread Raw
In response to Re: enums  (Andrew Dunstan <andrew@dunslane.net>)
Responses Re: enums
List pgsql-hackers
On Thu, Oct 27, 2005 at 10:34:57PM -0400, Andrew Dunstan wrote:
> 
> 
> Jim C. Nasby wrote:
> 
> >On Thu, Oct 27, 2005 at 09:45:05PM -0400, Andrew Dunstan wrote:
> > 
> >
> >>Jim C. Nasby wrote:
> >>
> >>   
> >>
> >>>Andrew, you mentioned that if you want to change the ordering you should
> >>>just create a new type. What about if you need to change the values that
> >>>are in the enum? MySQL does (or at least did, it's been some time since
> >>>I've messed with this) a horrible job at that. There's no way to rename
> >>>anything; you have to add the new names you want, then do a bulk update,
> >>>then delete the (now old) names. IMO this is broken.
> >>>
> >>>
> >>>     
> >>>
> >>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?
> > 
> >
> 
> Because you are not just changing the name of something.

No, I was refering specifically to the case of wanting to rename
something. IE: you setup an enum for sky colors (blue, black), and then
the PHB issues an edict that the daytime sky is now green. In this case
you (or at least I) don't want to define a new enum, I just want to
change 'blue' to 'green' in that enum. There's no reason it needs to hit
the table at all.
-- 
Jim C. Nasby, Sr. Engineering Consultant      jnasby@pervasive.com
Pervasive Software      http://pervasive.com    work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf       cell: 512-569-9461


pgsql-hackers by date:

Previous
From: "Jim C. Nasby"
Date:
Subject: Re: enums
Next
From: "Jim C. Nasby"
Date:
Subject: Re: pl/pgsql breakage in 8.1b4?