pgsql: Get rid of bogus dependency on typcategory in to_json() and frie

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Get rid of bogus dependency on typcategory in to_json() and frie
Date: 2014-05-09 16:55:48
Message-ID: E1Wio5M-000213-SZ@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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
------
REL9_3_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/13c6799958f82b3f3ad1123c0be58d8420973a63

Modified Files
--------------
src/backend/utils/adt/json.c | 379 +++++++++++++++++-------------------------
1 file changed, 152 insertions(+), 227 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Alexander Korotkov 2014-05-09 17:27:34 Re: [COMMITTERS] pgsql: Clean up jsonb code.
Previous Message Robert Haas 2014-05-09 14:48:21 pgsql: Code review for logical decoding patch.