Robert Haas <robertmh...@gmail.com> writes:
> On Fri, May 28, 2010 at 12:07 AM, Joseph Adams
> <joeyadams3.14...@gmail.com> wrote:
>> I learned that to return an enum value from C, one needs to return the
>> OID of the right row of the pg_enum table.  I eventually managed to
>> write the code below, which is mostly based on the enum_in function in
>> src/backend/utils/adt/enum.c .

> PG_RETURN macros shouldn't do any nontrivial processing (see the
> existing ones for references).

Yeah, that was my first reaction too.  If we don't already have one,
it would be appropriate to provide a "lookup enum value" function
(functionally about the same as enum_in, but designed to be called
conveniently from C).  Then, if you needed to work from a textual
enum label, you'd call that function and then PG_RETURN_OID.

However, for a built-in enum type, I agree with Robert's solution of
just #define-ing fixed OIDs for the values of the type.

                        regards, tom lane

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to