Re: Working with PostgreSQL enums in C code
От | Tom Lane |
---|---|
Тема | Re: Working with PostgreSQL enums in C code |
Дата | |
Msg-id | 24404.1275054440@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Re: Working with PostgreSQL enums in C code (Robert Haas <robertmhaas@gmail.com>) |
Ответы |
Re: Working with PostgreSQL enums in C code
|
Список | pgsql-hackers |
Robert Haas <robertmhaas@gmail.com> writes: > On Fri, May 28, 2010 at 12:07 AM, Joseph Adams > <joeyadams3.14159@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
В списке pgsql-hackers по дате отправления: