Thread: pgsql: SQL JSON functions

pgsql: SQL JSON functions

From
Andrew Dunstan
Date:
SQL JSON functions

This Patch introduces three SQL standard JSON functions:

JSON() (incorrectly mentioned in my commit message for f4fb45d15c)
JSON_SCALAR()
JSON_SERIALIZE()

JSON() produces json values from text, bytea, json or jsonb values, and
has facilitites for handling duplicate keys.
JSON_SCALAR() produces a json value from any scalar sql value, including
json and jsonb.
JSON_SERIALIZE() produces text or bytea from input which containis or
represents json or jsonb;

For the most part these functions don't add any significant new
capabilities, but they will be of use to users wanting standard
compliant JSON handling.

Nikita Glukhov

Reviewers have included (in no particular order) Andres Freund, Alexander
Korotkov, Pavel Stehule, Andrew Alsup, Erik Rijkers, Zihong Yu,
Himanshu Upadhyaya, Daniel Gustafsson, Justin Pryzby.

Discussion: https://postgr.es/m/cd0bb935-0158-78a7-08b5-904886deac4b@postgrespro.ru

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/606948b058dc16bce494270eea577011a602810e

Modified Files
--------------
doc/src/sgml/keywords/sql2016-02-reserved.txt |   3 +
src/backend/executor/execExpr.c               |  45 +++++
src/backend/executor/execExprInterp.c         |  42 +++-
src/backend/nodes/copyfuncs.c                 |  53 +++++
src/backend/nodes/equalfuncs.c                |  38 ++++
src/backend/nodes/nodeFuncs.c                 |  14 ++
src/backend/parser/gram.y                     |  56 +++++-
src/backend/parser/parse_expr.c               | 152 +++++++++++++--
src/backend/parser/parse_target.c             |   9 +
src/backend/utils/adt/format_type.c           |   4 +
src/backend/utils/adt/json.c                  |  51 +++--
src/backend/utils/adt/jsonb.c                 |  64 +++---
src/backend/utils/adt/ruleutils.c             |  13 +-
src/include/executor/execExpr.h               |   5 +
src/include/nodes/nodes.h                     |   3 +
src/include/nodes/parsenodes.h                |  35 ++++
src/include/nodes/primnodes.h                 |   5 +-
src/include/parser/kwlist.h                   |   4 +-
src/include/utils/json.h                      |  21 +-
src/include/utils/jsonb.h                     |  21 ++
src/test/regress/expected/sqljson.out         | 267 ++++++++++++++++++++++++++
src/test/regress/sql/sqljson.sql              |  57 ++++++
22 files changed, 880 insertions(+), 82 deletions(-)