pgsql: Add 'ignore_nulls' option to row_to_json

From: Stephen Frost <sfrost(at)snowman(dot)net>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Add 'ignore_nulls' option to row_to_json
Date: 2014-09-12 01:32:14
Message-ID: E1XSFig-000681-53@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Add 'ignore_nulls' option to row_to_json

Provide an option to skip NULL values in a row when generating a JSON
object from that row with row_to_json. This can reduce the size of the
JSON object in cases where columns are NULL without really reducing the
information in the JSON object.

This also makes row_to_json into a single function with default values,
rather than having multiple functions. In passing, change array_to_json
to also be a single function with default values (we don't add an
'ignore_nulls' option yet- it's not clear that there is a sensible
use-case there, and it hasn't been asked for in any case).

Pavel Stehule

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/95d737ff45a38809130a2c633d9e6bc26c825036

Modified Files
--------------
doc/src/sgml/func.sgml | 6 ++--
src/backend/catalog/system_views.sql | 14 ++++++++
src/backend/utils/adt/json.c | 55 +++++++++-----------------------
src/include/catalog/catversion.h | 2 +-
src/include/catalog/pg_proc.h | 8 ++---
src/include/utils/json.h | 2 --
src/test/regress/expected/json.out | 58 ++++++++++++++++++++++++++++++++++
src/test/regress/sql/json.sql | 24 ++++++++++++++
8 files changed, 118 insertions(+), 51 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2014-09-12 01:41:34 pgsql: Fix vacuumdb --analyze-in-stages --all order
Previous Message Bruce Momjian 2014-09-11 22:44:04 pgsql: pg_upgrade: adjust C comments