pgsql: Get rid of bogus dependency on typcategory in to_json() and frie - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Get rid of bogus dependency on typcategory in to_json() and frie
Date
Msg-id E1Wio5M-00020w-Qk@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Get rid of bogus dependency on typcategory in to_json() and friends.

These functions were relying on typcategory to identify arrays and
composites, which is not reliable and not the normal way to do it.
Using typcategory to identify boolean, numeric types, and json itself is
also pretty questionable, though the code in those cases didn't seem to be
at risk of anything worse than wrong output.  Instead, use the standard
lsyscache functions to identify arrays and composites, and rely on a direct
check of the type OID for the other cases.

In HEAD, also be sure to look through domains so that a domain is treated
the same as its base type for conversions to JSON.  However, this is a
small behavioral change; given the lack of field complaints, we won't
back-patch it.

In passing, refactor so that there's only one copy of the code that decides
which conversion strategy to apply, not multiple copies that could (and
have) gotten out of sync.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/0ca6bda8e7501947c05f30c127f6d12ff90b5a64

Modified Files
--------------
src/backend/utils/adt/json.c |  410 +++++++++++++++++++-----------------------
1 file changed, 181 insertions(+), 229 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Get rid of bogus dependency on typcategory in to_json() and frie
Next
From: Tom Lane
Date:
Subject: pgsql: Get rid of bogus dependency on typcategory in to_json() and frie