Joseph Adams wrote:
By the way, just curious: why can't the internal representation of an
enum just be an INT starting from 0 by default, like in C? That would
make a heck of a lot more sense, in my opinion. It might also allow
users to do things like this in the future:
Please review
On Mon, Jun 7, 2010 at 5:16 PM, Joseph Adams wrote:
> I don't know if the JSON datatype will be a contrib module or built-in
> yet, but if it were contrib, would it still be better to use fixed
> OIDs anyway?
Part of the point is that EXPLAIN (FORMAT JSON) should return json, so
this needs to be
Excerpts from Joseph Adams's message of lun jun 07 17:16:12 -0400 2010:
> > 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.
>
> I don't know if the JSON datatype will be a contrib module or built-in
> yet, but if it
On Fri, May 28, 2010 at 9:47 AM, Tom Lane wrote:
> Robert Haas writes:
>> On Fri, May 28, 2010 at 12:07 AM, Joseph Adams
>> 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
Robert Haas writes:
> On Fri, May 28, 2010 at 12:07 AM, Joseph Adams
> 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
On Fri, May 28, 2010 at 12:07 AM, Joseph Adams
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
I encountered a situation while implementing JSON support where I
needed to return an enum value from a C function. To clarify, here's
the SQL:
CREATE TYPE json_type_t AS ENUM ('null', 'string', 'number', 'bool',
'object', 'array');
CREATE OR REPLACE FUNCTION json_type(json)
RETURNS json_type_t