Add more SQL/JSON constructor functions
authorAmit Langote <[email protected]>
Thu, 20 Jul 2023 13:21:43 +0000 (22:21 +0900)
committerAmit Langote <[email protected]>
Wed, 26 Jul 2023 08:08:33 +0000 (17:08 +0900)
commit03734a7fed7d924679770adb78a7db8a37d14188
treef6f85a40bf1a673f87a973bfdf989e2890cee0c8
parent254ac5a7c31f7e6d3908c057461db5401d2110b0
Add more SQL/JSON constructor functions

This Patch introduces three SQL standard JSON functions:

JSON()
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.

Catversion bumped as this changes ruleutils.c.

Author: Nikita Glukhov <[email protected]>
Author: Teodor Sigaev <[email protected]>
Author: Oleg Bartunov <[email protected]>
Author: Alexander Korotkov <[email protected]>
Author: Andrew Dunstan <[email protected]>
Author: Amit Langote <[email protected]>

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, Álvaro Herrera,
Peter Eisentraut

Discussion: https://postgr.es/m/cd0bb935-0158-78a7-08b5-904886deac4b@postgrespro.ru
Discussion: https://postgr.es/m/20220616233130[email protected]
Discussion: https://postgr.es/m/abd9b83b-aa66-f230-3d6d-734817f0995d%40postgresql.org
Discussion: https://postgr.es/m/CA+HiwqE4XTdfb1nW=Ojoy_tQSRhYt-q_kb6i5d4xcKyrLC1Nbg@mail.gmail.com
22 files changed:
doc/src/sgml/func.sgml
src/backend/executor/execExpr.c
src/backend/executor/execExprInterp.c
src/backend/nodes/nodeFuncs.c
src/backend/parser/gram.y
src/backend/parser/parse_expr.c
src/backend/parser/parse_target.c
src/backend/utils/adt/format_type.c
src/backend/utils/adt/jsonb.c
src/backend/utils/adt/ruleutils.c
src/include/catalog/catversion.h
src/include/nodes/parsenodes.h
src/include/nodes/primnodes.h
src/include/parser/kwlist.h
src/include/utils/jsonfuncs.h
src/interfaces/ecpg/test/expected/sql-sqljson.c
src/interfaces/ecpg/test/expected/sql-sqljson.stderr
src/interfaces/ecpg/test/expected/sql-sqljson.stdout
src/interfaces/ecpg/test/sql/sqljson.pgc
src/test/regress/expected/sqljson.out
src/test/regress/sql/sqljson.sql
src/tools/pgindent/typedefs.list