Re: VARIANT / ANYTYPE datatype - Mailing list pgsql-hackers

From Joseph Adams
Subject Re: VARIANT / ANYTYPE datatype
Date
Msg-id BANLkTikVmxrDPkKGi3V-SCDy64kE7uZ2Kg@mail.gmail.com
Whole thread Raw
In response to Re: VARIANT / ANYTYPE datatype  (Joseph Adams <joeyadams3.14159@gmail.com>)
Responses Re: VARIANT / ANYTYPE datatype
List pgsql-hackers
On Tue, May 10, 2011 at 10:29 PM, Joseph Adams
<joeyadams3.14159@gmail.com> wrote:
> The VARIANT type, or similar, would be useful for the JSON data type
> I've been intermittently working on, as it would allow us to create a
> function like this:
>
>    from_json(JSON) returns VARIANT

This occurred to me: if PostgreSQL functions could return ANYELEMENT,
then we could just say:
   from_json(JSON) returns ANYELEMENT -- no intermediate VARIANT value

Likewise, the variant conversion functions (which could be invoked
automatically) could be done this way:
   to_variant(ANYELEMENT) returns VARIANT   from_variant(VARIANT) returns ANYELEMENT

However, I'm not familiar enough with the innards of PostgreSQL's type
system to know if returning ANYELEMENT would be possible and make
sense.


pgsql-hackers by date:

Previous
From: Joseph Adams
Date:
Subject: Re: VARIANT / ANYTYPE datatype
Next
From: Pavel Stehule
Date:
Subject: Re: VARIANT / ANYTYPE datatype