Re: enums

From: Gregory Maxwell <gmaxwell(at)gmail(dot)com>
To: Jim Nasby <jnasby(at)pervasive(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: enums
Date: 2005-10-27 22:46:24
Message-ID: e692861c0510271546ud7a08c7h3ed3f97315671f38@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 10/27/05, Jim Nasby <jnasby(at)pervasive(dot)com> wrote:
> Adding -hackers back to the list...
> > You could as equally say that it's ordering it by the order of the
> > enum declaration, which seems quite reasonable to me.
>
> I don't really see why that's considered reasonable, especially as a default. I could maybe see an argument for having a means to see this ordering, but IMO anything depending on that is broken. I don't think we should be making any guarantees about how enums are stored in the database (including ordering).

> Your examples show why I don't think it's a good idea to use MySQL as a guide for how to do enums.

Yes, MySQL is broken in some regards, as usual. However, the API isn't
bad (except for the fact that it doesn't care what invalid crap you
throw at it), and more importantly there are thousands of apps and
developers who think around that interface. We should copy it without
the brokenness as much as possible unless we have good cause
otherwise.

> If we do decide to include the concept of ordering in enums, then it should be fully supported and not just an artifact of our storage mechanism. This means supporting things like being able to re-order the accepted values in an enum. But like I said, I just don't see the use case for doing that.

So what do you propose we do for a default ordering? I hope you don't
think we should force a sort as though the enum labels were text...
That almost certainly incorrect for most applications of enums, which
are used to make opaque labels more human compatible.

MySQL's behavior of allowing the user to specify the collation in the
typedef makes a lot of sense to me, it doesn't matter that it actually
works as an artifact of the storage backend. I'd argue that it would
make sense to sort by the specification order even if we changed the
backend to use varchars rather than numbers.

In response to

  • Re: enums at 2005-10-27 22:23:58 from Jim Nasby

Responses

  • Re: enums at 2005-10-27 23:04:48 from Jim C. Nasby
  • Re: enums at 2005-10-27 23:17:16 from Andrew Dunstan

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2005-10-27 23:02:45 Re: enums
Previous Message Tom Lane 2005-10-27 22:39:15 Re: ERROR: invalid memory alloc request size <a_big_number_here>