pgsql: SQL/JSON constructors

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: SQL/JSON constructors
Date: 2022-03-27 21:07:46
Message-ID: E1nYa6z-001ewM-Td@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

SQL/JSON constructors

This patch introduces the SQL/JSON standard constructors for JSON:

JSON()
JSON_ARRAY()
JSON_ARRAYAGG()
JSON_OBJECT()
JSON_OBJECTAGG()

For the most part these functions provide facilities that mimic
existing json/jsonb functions. However, they also offer some useful
additional functionality. In addition to text input, the JSON() function
accepts bytea input, which it will decode and constuct a json value from.
The other functions provide useful options for handling duplicate keys
and null values.

This series of patches will be followed by a consolidated documentation
patch.

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/f4fb45d15c59d7add2e1b81a9d477d0119a9691a

Modified Files
--------------
src/backend/executor/execExpr.c | 63 +++
src/backend/executor/execExprInterp.c | 48 ++
src/backend/jit/llvm/llvmjit_expr.c | 6 +
src/backend/jit/llvm/llvmjit_types.c | 1 +
src/backend/nodes/copyfuncs.c | 173 +++++++
src/backend/nodes/equalfuncs.c | 132 ++++++
src/backend/nodes/makefuncs.c | 15 +
src/backend/nodes/nodeFuncs.c | 152 +++++++
src/backend/nodes/outfuncs.c | 18 +
src/backend/nodes/readfuncs.c | 22 +
src/backend/optimizer/util/clauses.c | 23 +
src/backend/parser/gram.y | 265 ++++++++++-
src/backend/parser/parse_expr.c | 589 ++++++++++++++++++++++++
src/backend/parser/parse_target.c | 13 +
src/backend/parser/parser.c | 16 +
src/backend/utils/adt/json.c | 422 +++++++++++++++--
src/backend/utils/adt/jsonb.c | 224 ++++++++--
src/backend/utils/adt/jsonb_util.c | 24 +-
src/backend/utils/adt/ruleutils.c | 212 +++++++--
src/backend/utils/misc/queryjumble.c | 12 +
src/include/catalog/pg_aggregate.dat | 22 +
src/include/catalog/pg_proc.dat | 70 +++
src/include/executor/execExpr.h | 14 +
src/include/nodes/makefuncs.h | 1 +
src/include/nodes/nodes.h | 8 +
src/include/nodes/parsenodes.h | 96 +++-
src/include/nodes/primnodes.h | 25 ++
src/include/parser/kwlist.h | 6 +
src/include/utils/json.h | 6 +
src/include/utils/jsonb.h | 9 +
src/interfaces/ecpg/preproc/parse.pl | 2 +
src/interfaces/ecpg/preproc/parser.c | 14 +
src/test/regress/expected/opr_sanity.out | 6 +-
src/test/regress/expected/sqljson.out | 746 +++++++++++++++++++++++++++++++
src/test/regress/parallel_schedule | 2 +-
src/test/regress/sql/opr_sanity.sql | 6 +-
src/test/regress/sql/sqljson.sql | 282 ++++++++++++
37 files changed, 3615 insertions(+), 130 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2022-03-27 22:32:47 pgsql: Fix up compiler warnings/errors from f4fb45d15.
Previous Message Daniel Gustafsson 2022-03-27 20:43:35 pgsql: Remove more unused module imports from TAP tests