Re: enum types and binary queries

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Merlin Moncure <mmoncure(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: enum types and binary queries
Date: 2007-08-30 18:48:02
Message-ID: 46D710E2.3070604@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Merlin Moncure wrote:
> I noticed that enums are not available to be queried as binary through
> the protocol. Is this a known issue? Too late to fix for 8.3? This
> is kind of a pain, because it forces any query that returns an enum to
> return the entire result as text. afaik, enums are the only POD type
> to behave this way.
>
> postgres=# create type foo as enum('foo');
> CREATE TYPE
>
> postgres=# copy (select 'foo'::foo) to '/home/postgres/foo.txt' binary;
> ERROR: no binary output function available for type foo
>

The trouble is that an enum doesn't have an immutable internal binary value.

I guess we could say that the binary value is the integer offset of the
value in the enum ordering, and translate it back on input. Providing
the binary IO funcs shouldn't be too hard if we do that, unless I'm
missing something.

cheers

andrew

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2007-08-30 18:54:21 Re: reindexdb hangs
Previous Message Tom Lane 2007-08-30 18:14:00 Re: Advice on MyXactMade* flags, MyLastRecPtr, pendingDeletes and lazy XID assignment

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2007-08-30 18:58:48 Re: enum types and binary queries
Previous Message Tom Lane 2007-08-30 18:40:22 Re: HOT patch - version 14