Re: enum types and binary queries - Mailing list pgsql-hackers

From Decibel!
Subject Re: enum types and binary queries
Date
Msg-id 20070831171714.GZ38801@decibel.org
Whole thread Raw
In response to Re: enum types and binary queries  ("Merlin Moncure" <mmoncure@gmail.com>)
Responses Re: enum types and binary queries  (Andrew Dunstan <andrew@dunslane.net>)
List pgsql-hackers
On Fri, Aug 31, 2007 at 08:49:05AM -0400, Merlin Moncure wrote:
> On 8/30/07, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> > "Merlin Moncure" <mmoncure@gmail.com> writes:
> > > I noticed that enums are not available to be queried as binary through
> > > the protocol.
> >
> > What do you think the binary representation ought to be?  Copying OIDs
> > seems pretty useless.
>
> I'm on the fence on this one.
>
> I actually think this would be ok, if you mean pg_enum.oid, or the
> string would be fine too.  I agree that binary protocol is supposed to
> be fast, and I can prefetch the pg_enum table to the client and do the
> magic there.  Many other binary formats do similarly inscrutable
> things.

The last time I worked on a project where we had C code access the
database, we added stuff to map C enums to ints in the database (along
with a parent table to store the enum label). ISTM it'd be good if we
had a way to get the numeric index out of an enum. I also like the idea
of having a fixed ordering to the labels in an enum.

> One other very small observation: afaict, there appears to be no way
> to list enum contents in psql (although you can list the enums
> themselves in the type listing).  Maybe this should be possible?  I'm
> willing to take a stab at these things if Andrew is busy.

Is there an SRF that will return this info? ISTM you should be able to
get the labels programmatically as well as via psql.
--
Decibel!, aka Jim Nasby                        decibel@decibel.org
EnterpriseDB      http://enterprisedb.com      512.569.9461 (cell)

pgsql-hackers by date:

Previous
From: "Kevin Grittner"
Date:
Subject: Attempt to stop dead instance can stop a random process?
Next
From: Decibel!
Date:
Subject: Re: Password requirement in windows installer