Re: PATCH: Implement value_to_json for single-datum conversion

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Craig Ringer <ringerc(at)ringerc(dot)id(dot)au>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: PATCH: Implement value_to_json for single-datum conversion
Date: 2012-08-13 04:33:00
Message-ID: 21714.1344832380@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Craig Ringer <ringerc(at)ringerc(dot)id(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2012-08-13 04:48:31 Re: PATCH: Implement value_to_json for single-datum conversion
Previous Message Craig Ringer 2012-08-13 04:05:08 Re: PATCH: Implement value_to_json for single-datum conversion