Skip site navigation (1) Skip section navigation (2)

Re: enum types and binary queries

From: Decibel! <decibel(at)decibel(dot)org>
To: Merlin Moncure <mmoncure(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>,PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>,Andrew Dunstan <andrew(at)dunslane(dot)net>
Subject: Re: enum types and binary queries
Date: 2007-08-31 17:17:14
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackerspgsql-patches
On Fri, Aug 31, 2007 at 08:49:05AM -0400, Merlin Moncure wrote:
> On 8/30/07, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> > "Merlin Moncure" <mmoncure(at)gmail(dot)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(at)decibel(dot)org
EnterpriseDB      512.569.9461 (cell)

In response to


pgsql-hackers by date

Next:From: Decibel!Date: 2007-08-31 17:30:02
Subject: Re: Password requirement in windows installer
Previous:From: Kevin GrittnerDate: 2007-08-31 17:02:39
Subject: Attempt to stop dead instance can stop a random process?

pgsql-patches by date

Next:From: Andrew DunstanDate: 2007-08-31 17:41:47
Subject: Re: enum types and binary queries
Previous:From: Andrew DunstanDate: 2007-08-31 15:14:29
Subject: Re: enum types and binary queries

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group