Re: WIP: extensible enums

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, Greg Stark <gsstark(at)mit(dot)edu>, Robert Haas <robertmhaas(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: WIP: extensible enums
Date: 2010-10-24 21:09:18
Message-ID: 4CC4A07E.2040104@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 10/24/2010 03:33 PM, Tom Lane wrote:
> Dean Rasheed<dean(dot)a(dot)rasheed(at)gmail(dot)com> writes:
>> The point with an OID array is that you wouldn't need to store the
>> enumsortorder values at all. The sort order would just be the index of
>> the OID in the array. So the comparison code would read the OID array,
>> traverse it building an array of enum_sort structs {oid, idx}, sort
>> that by OID and cache it.
> Hmm. But I guess we'd have to keep that array in the pg_type row,
> and it'd be a huge PITA to work with at the SQL level. For instance,
> psql and pg_dump can easily be adapted to use enumsortorder instead
> of pg_enum.oid when they want to read out the labels in sorted order.
> Doing the same with an array representation would be a very different
> and much uglier query. I'm not eager to contort the catalog
> representation that much.

If that's the only objection I don't know that it's terribly serious.
psql and pg_dump could sanely use something like:

select enum_oid, row_number() over () as sort_order
from unnest(null::myenum) as enum_oid

That said, I'm generally wary of array fields, especially in the catalog.

cheers

andrew

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2010-10-24 21:20:55 Re: WIP: extensible enums
Previous Message Tom Lane 2010-10-24 20:53:30 Re: typenameTypeId refactoring