Re: PATCH: Implement value_to_json for single-datum conversion

Craig Ringer <ringerc@ringerc.id.au>

From: Craig Ringer <ringerc@ringerc.id.au>
To: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2012-08-13T04:05:08Z
Lists: pgsql-hackers

Attachments

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? The comments on 
the affected check in opr_sanity say that it's not necessarily wrong so 
long as the called function is prepared to handle the different 
arguments its self - which it is, since it's already accepting anyelement.

The test comment reads:

   Note that the expected output of this part of the test will
   need to be modified whenever new pairs of types are made 
binary-equivalent,
   or when new polymorphic built-in functions are added

so that seems reasonable.


postgres=# \df quote_literal
                               List of functions
    Schema   |     Name      | Result data type | Argument data types |  
Type
------------+---------------+------------------+---------------------+--------
  pg_catalog | quote_literal | text             | anyelement | normal
  pg_catalog | quote_literal | text             | text | normal
(2 rows)

postgres=# \df value_to_json
                               List of functions
    Schema   |     Name      | Result data type | Argument data types |  
Type
------------+---------------+------------------+---------------------+--------
  pg_catalog | value_to_json | json             | anyelement | normal
  pg_catalog | value_to_json | json             | text | normal
(2 rows)

Revised patch that tweaks the expected result of opr_sanity attached.

--
Craig Ringer