pgsql: SQL/JSON: add standard JSON constructor functions

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: SQL/JSON: add standard JSON constructor functions
Date: 2023-03-29 10:13:22
Message-ID: E1phSnx-000IYc-43@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

SQL/JSON: add standard JSON constructor functions

This commit introduces the SQL/JSON standard-conforming constructors for
JSON types:

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

Most of the functionality was already present in PostgreSQL-specific
functions, but these include some new functionality such as the ability
to skip or include NULL values, and to allow duplicate keys or throw
error when they are found, as well as the standard specified syntax to
specify output type and format.

Author: Nikita Glukhov <n(dot)gluhov(at)postgrespro(dot)ru>
Author: Teodor Sigaev <teodor(at)sigaev(dot)ru>
Author: Oleg Bartunov <obartunov(at)gmail(dot)com>
Author: Alexander Korotkov <aekorotkov(at)gmail(dot)com>
Author: Amit Langote <amitlangote09(at)gmail(dot)com>

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/CAF4Au4w2x-5LTnN_bxky-mq4=WOqsGsxSpENCzHRAzSnEd8+WQ@mail.gmail.com
Discussion: https://postgr.es/m/cd0bb935-0158-78a7-08b5-904886deac4b@postgrespro.ru
Discussion: https://postgr.es/m/20220616233130.rparivafipt6doj3@alap3.anarazel.de
Discussion: https://postgr.es/m/abd9b83b-aa66-f230-3d6d-734817f0995d%40postgresql.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/7081ac46ace8c459966174400b53418683c9fe5c

Modified Files
--------------
doc/src/sgml/func.sgml | 286 +++++++-
src/backend/executor/execExpr.c | 91 +++
src/backend/executor/execExprInterp.c | 50 ++
src/backend/jit/llvm/llvmjit_expr.c | 6 +
src/backend/jit/llvm/llvmjit_types.c | 1 +
src/backend/nodes/makefuncs.c | 69 ++
src/backend/nodes/nodeFuncs.c | 221 ++++++
src/backend/optimizer/util/clauses.c | 55 ++
src/backend/parser/gram.y | 257 ++++++-
src/backend/parser/parse_expr.c | 770 +++++++++++++++++++++
src/backend/parser/parse_target.c | 18 +
src/backend/parser/parser.c | 26 +
src/backend/utils/adt/json.c | 434 ++++++++++--
src/backend/utils/adt/jsonb.c | 236 +++++--
src/backend/utils/adt/jsonb_util.c | 56 +-
src/backend/utils/adt/ruleutils.c | 275 +++++++-
src/include/catalog/catversion.h | 2 +-
src/include/catalog/pg_aggregate.dat | 22 +
src/include/catalog/pg_proc.dat | 74 ++
src/include/executor/execExpr.h | 26 +
src/include/nodes/makefuncs.h | 6 +
src/include/nodes/parsenodes.h | 107 +++
src/include/nodes/primnodes.h | 85 +++
src/include/parser/kwlist.h | 8 +
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 | 22 +
src/interfaces/ecpg/test/ecpg_schedule | 1 +
src/interfaces/ecpg/test/expected/sql-sqljson.c | 203 ++++++
.../ecpg/test/expected/sql-sqljson.stderr | 69 ++
.../ecpg/test/expected/sql-sqljson.stdout | 6 +
src/interfaces/ecpg/test/sql/Makefile | 1 +
src/interfaces/ecpg/test/sql/meson.build | 1 +
src/interfaces/ecpg/test/sql/sqljson.pgc | 44 ++
src/test/regress/expected/json.out | 11 +-
src/test/regress/expected/opr_sanity.out | 6 +-
src/test/regress/expected/sqljson.out | 756 ++++++++++++++++++++
src/test/regress/parallel_schedule | 2 +-
src/test/regress/sql/opr_sanity.sql | 6 +-
src/test/regress/sql/sqljson.sql | 284 ++++++++
src/tools/pgindent/typedefs.list | 1 +
42 files changed, 4470 insertions(+), 141 deletions(-)

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2023-03-29 13:17:05 pgsql: Remove empty function BufmgrCommit().
Previous Message Peter Eisentraut 2023-03-29 09:37:06 pgsql: Fix some section numbers in information_schema.sql