Craig Ringer <ringerc@ringerc.id.au> writes:
> As for the value_to_json crashing, works for me:
> postgres=# SELECT value_to_json(42);
> value_to_json
> ---------------
> 42
> (1 row)
Oh, right, because there actually is support for anyelement in the
underlying C function. There is not in the quote_literal case.
> Purely so I understand what the correct handling of the anyelement+text
> overload would've been: In light of your comments on opr_sanity would
> the right approach be to add a second C function like text_to_json that
> only accepts 'text' to avoid confusing the sanity check?
Actually, given the above, what did you need value_to_json(text) for at
all? Wouldn't value_to_json(anyelement) have covered it?
But yeah, the general approach to suppressing complaints from that
opr_sanity test is to make more C entry points. The point of it,
in some sense, is that if you want to make an assumption that two
types are binary-equivalent then it's better to have that assumption
in C code than embedded in the pg_proc entries. The cases that we
let pass via the "expected" outputs are only ones where binary
equivalence seems pretty well assured, like text vs varchar.
regards, tom lane