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.