SQL/JSON: add standard JSON constructor functions
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Wed, 29 Mar 2023 10:11:36 +0000 (12:11 +0200)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Wed, 29 Mar 2023 10:11:36 +0000 (12:11 +0200)
commit7081ac46ace8c459966174400b53418683c9fe5c
tree52590ea33eb07a2d7acf4a1461101932c3c88757
parent38b7437b9088b4859e4489a1a1a9ab7066f5b320
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.gluhov@postgrespro.ru>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Oleg Bartunov <obartunov@gmail.com>
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Amit Langote <amitlangote09@gmail.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
42 files changed:
doc/src/sgml/func.sgml
src/backend/executor/execExpr.c
src/backend/executor/execExprInterp.c
src/backend/jit/llvm/llvmjit_expr.c
src/backend/jit/llvm/llvmjit_types.c
src/backend/nodes/makefuncs.c
src/backend/nodes/nodeFuncs.c
src/backend/optimizer/util/clauses.c
src/backend/parser/gram.y
src/backend/parser/parse_expr.c
src/backend/parser/parse_target.c
src/backend/parser/parser.c
src/backend/utils/adt/json.c
src/backend/utils/adt/jsonb.c
src/backend/utils/adt/jsonb_util.c
src/backend/utils/adt/ruleutils.c
src/include/catalog/catversion.h
src/include/catalog/pg_aggregate.dat
src/include/catalog/pg_proc.dat
src/include/executor/execExpr.h
src/include/nodes/makefuncs.h
src/include/nodes/parsenodes.h
src/include/nodes/primnodes.h
src/include/parser/kwlist.h
src/include/utils/json.h
src/include/utils/jsonb.h
src/interfaces/ecpg/preproc/parse.pl
src/interfaces/ecpg/preproc/parser.c
src/interfaces/ecpg/test/ecpg_schedule
src/interfaces/ecpg/test/expected/sql-sqljson.c [new file with mode: 0644]
src/interfaces/ecpg/test/expected/sql-sqljson.stderr [new file with mode: 0644]
src/interfaces/ecpg/test/expected/sql-sqljson.stdout [new file with mode: 0644]
src/interfaces/ecpg/test/sql/Makefile
src/interfaces/ecpg/test/sql/meson.build
src/interfaces/ecpg/test/sql/sqljson.pgc [new file with mode: 0644]
src/test/regress/expected/json.out
src/test/regress/expected/opr_sanity.out
src/test/regress/expected/sqljson.out [new file with mode: 0644]
src/test/regress/parallel_schedule
src/test/regress/sql/opr_sanity.sql
src/test/regress/sql/sqljson.sql [new file with mode: 0644]
src/tools/pgindent/typedefs.list