Re: [GENERAL] enum bug

2016-03-14 Thread Elein
Elein Mustain el...@varlena.com 510-637-9106 > On Mar 13, 2016, at 7:22 PM, Alvaro Herrera wrote: > > Elein wrote: > > Hi Elein, > >> * When an insert into an enum column fails give the person a hint as to >> valid values > >> -- Lousy message. Show enum list.

Re: [GENERAL] enum bug

2016-03-14 Thread Alvaro Herrera
Joshua D. Drake wrote: > On 03/14/2016 08:48 AM, Alvaro Herrera wrote: > >(*) Yes, I'm being a bit sarcastic here, sorry about that. I actually > >learned quite a bit of database design and related topics by translating > >the "General Bits" column she used to write, many years ago. > > Your

Re: [GENERAL] enum bug

2016-03-14 Thread Andrew Sullivan
On Sun, Mar 13, 2016 at 10:20:05PM -0400, Melvin Davidson wrote: > The point is, they are an archaic data type and it's a hell of a lot easier > to use Foreign Keys to insure integrity. So don't use them? Nobody, surely, is forcing you to use enums. I recall when enums were added. I recall

Re: [GENERAL] enum bug

2016-03-14 Thread Melvin Davidson
On Mon, Mar 14, 2016 at 12:07 PM, Joshua D. Drake wrote: > On 03/14/2016 09:02 AM, David G. Johnston wrote: > > ​The one nice thing about enums is that you get two concepts in one >> column - a human readable label and a system used ordering. >> >> i.e., "SELECT

Re: [GENERAL] enum bug

2016-03-14 Thread Joshua D. Drake
On 03/14/2016 09:02 AM, David G. Johnston wrote: ​The one nice thing about enums is that you get two concepts in one column - a human readable label and a system used ordering. i.e., "SELECT enum_value FROM tbl ORDER BY enum_value" actually ​ ​gives you a meaningful order without having to

Re: [GENERAL] enum bug

2016-03-14 Thread David G. Johnston
On Mon, Mar 14, 2016 at 8:52 AM, Joshua D. Drake wrote: > > If improved enough, maybe we could get to a >> point where they could actually be used; otherwise why the heck did we >> let the feature in the database in the first place? I think all these >> "use a lookup

Re: [GENERAL] enum bug

2016-03-14 Thread David G. Johnston
On Mon, Mar 14, 2016 at 8:48 AM, Alvaro Herrera wrote: > Joshua D. Drake wrote: > > On 03/11/2016 03:19 PM, Elein wrote: > > > > >An unused (yet) enum type cannot display the enum ranges. An empty table > > >containing that type cannot display enum ranges. > > > > >

Re: [GENERAL] enum bug

2016-03-14 Thread Joshua D. Drake
On 03/14/2016 08:48 AM, Alvaro Herrera wrote: Joshua D. Drake wrote: On 03/11/2016 03:19 PM, Elein wrote: An unused (yet) enum type cannot display the enum ranges. An empty table containing that type cannot display enum ranges. The example selects were what I did to figure out that

Re: [GENERAL] enum bug

2016-03-14 Thread Joshua D. Drake
On 03/11/2016 03:19 PM, Elein wrote: An unused (yet) enum type cannot display the enum ranges. An empty table containing that type cannot display enum ranges. The example selects were what I did to figure out that enum_ranges only worked on existing data. Sorry if they were confusing. But the

Re: [GENERAL] enum bug

2016-03-13 Thread Alvaro Herrera
Elein wrote: Hi Elein, >* When an insert into an enum column fails give the person a hint as to > valid values > -- Lousy message. Show enum list. > insert into badinfo values ('green'); > ERROR: invalid input value for enum rainbow: "green" > LINE 1: insert into badinfo values

Re: [GENERAL] enum bug

2016-03-13 Thread Melvin Davidson
The post refers to the generic unmanageability of enums in genaral, it just uses MySQL as a reference basis. Google evil enum and you will find several articles that all say the same thing. To be specific,even in PostgreSQL, there is no easy way to delete enum values once they exist, other than

Re: [GENERAL] enum bug

2016-03-13 Thread Alvaro Herrera
Melvin Davidson wrote: > Enums are evil! > http://www.lornajane.net/posts/2010/is-enum-evil ??? This post is about MySQL's enums, which aren't really related to Postgres enums: "In order to change the allowed values of an enum column, we need to issue an alter table statement

Re: [GENERAL] enum bug

2016-03-11 Thread Elein
Elein Mustain el...@varlena.com 510-637-9106 > On Mar 11, 2016, at 3:45 PM, David G. Johnston > wrote: > >> On Fri, Mar 11, 2016 at 4:19 PM, Elein wrote: > >> An unused (yet) enum type cannot display the enum ranges. An empty table >>

Re: [GENERAL] enum bug

2016-03-11 Thread David G. Johnston
On Fri, Mar 11, 2016 at 4:19 PM, Elein wrote: > An unused (yet) enum type cannot display the enum ranges. An empty table > containing that type cannot display enum ranges. > ​Yes, it can. ​CREATE TYPE rainbow AS enum ('red','orange','yellow','blue','purple'); SELECT

Re: [GENERAL] enum bug

2016-03-11 Thread Elein
The point is that enum information belongs to a type, not a column value of that type. This is the difference between a class and a class instance. If you get that, you understand. The workaround suggested only works if some non-empty row in some table has a column defined to be that enum

Re: [GENERAL] enum bug

2016-03-11 Thread David G. Johnston
On Fri, Mar 11, 2016 at 2:55 PM, Melvin Davidson wrote: > Enums are evil! > http://www.lornajane.net/posts/2010/is-enum-evil > > ​Using red background is evil :) I'll disagree on the premise but will agree that without a better implementation and handling of change our

Re: [GENERAL] enum bug

2016-03-11 Thread David G. Johnston
On Fri, Mar 11, 2016 at 2:36 PM, Elein wrote: > > > Bug/Improvement: > > > >Enums belong to types, not to column values. > > > >* Create a built in function, like enum_range( type ), independent of > tables > > that shows a type's enum values. > >create or

Re: [GENERAL] enum bug

2016-03-11 Thread John R Pierce
On 3/11/2016 1:36 PM, Elein wrote: >Bug/Improvement: > >Enums belong to types, not to column values I've read this post twice, and I'm still unclear on what you're saying is a problem, and what your proposed solution is... -- john r pierce, recycling bits in santa cruz -- Sent

Re: [GENERAL] enum bug

2016-03-11 Thread Melvin Davidson
On Fri, Mar 11, 2016 at 4:36 PM, Elein wrote: > > > Bug/Improvement: > > > >Enums belong to types, not to column values. > > > >* Create a built in function, like enum_range( type ), independent of > tables > > that shows a type's enum values. > >create or

[GENERAL] enum bug

2016-03-11 Thread Elein
> Bug/Improvement: > >Enums belong to types, not to column values. > >* Create a built in function, like enum_range( type ), independent of > tables > that shows a type's enum values. >create or replace function enum_range( typein regtype ) returns name[] > language sql