Re: PATCH: Implement value_to_json for single-datum conversion - Mailing list pgsql-hackers

From Tom Lane
Subject Re: PATCH: Implement value_to_json for single-datum conversion
Date
Msg-id 21714.1344832380@sss.pgh.pa.us
Whole thread Raw
In response to Re: PATCH: Implement value_to_json for single-datum conversion  (Craig Ringer <ringerc@ringerc.id.au>)
List pgsql-hackers
Craig Ringer <ringerc@ringerc.id.au> writes:
> OK, opr_sanity was failing because I added the value_to_json(text) alias 
> to ensure that:

>    value_to_json('some_literal')

> worked, following the same approach as quote_literal(anyelement) and 
> quote_literal(text). That should be reasonable, right?

No, it isn't.  What you're proposing is to let opr_sanity think that
text and anyelement are interchangeable to C functions, which is so
far from reality as to be ludicrous.  That would be seriously damaging
to its ability to detect errors.

But more to the point, your analogy to quote_literal is faulty anyway.
If you looked at that, what you'd find is that only quote_literal(text)
is a C function.  The other one is a SQL wrapper around a coercion to
text followed by the C function.  I rather imagine that the definition
as you have it would crash on, say, value_to_json(42).
        regards, tom lane



pgsql-hackers by date:

Previous
From: Craig Ringer
Date:
Subject: Re: PATCH: Implement value_to_json for single-datum conversion
Next
From: Tom Lane
Date:
Subject: Re: PATCH: Implement value_to_json for single-datum conversion