pgsql: Add more SQL/JSON constructor functions - Mailing list pgsql-committers

From Amit Langote
Subject pgsql: Add more SQL/JSON constructor functions
Date
Msg-id E1qOZaa-001PJD-4z@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
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 <n.gluhov@postgrespro.ru>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Oleg Bartunov <obartunov@gmail.com>
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Andrew Dunstan <andrew@dunslane.net>
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, Álvaro Herrera,
Peter Eisentraut

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
Discussion: https://postgr.es/m/CA+HiwqE4XTdfb1nW=Ojoy_tQSRhYt-q_kb6i5d4xcKyrLC1Nbg@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/03734a7fed7d924679770adb78a7db8a37d14188

Modified Files
--------------
doc/src/sgml/func.sgml                             |  66 ++++
src/backend/executor/execExpr.c                    |  30 ++
src/backend/executor/execExprInterp.c              |  41 +++
src/backend/nodes/nodeFuncs.c                      |  30 ++
src/backend/parser/gram.y                          |  49 ++-
src/backend/parser/parse_expr.c                    | 225 +++++++++++++-
src/backend/parser/parse_target.c                  |  12 +
src/backend/utils/adt/format_type.c                |   4 +
src/backend/utils/adt/jsonb.c                      |  15 +-
src/backend/utils/adt/ruleutils.c                  |  16 +-
src/include/catalog/catversion.h                   |   2 +-
src/include/nodes/parsenodes.h                     |  37 +++
src/include/nodes/primnodes.h                      |   5 +-
src/include/parser/kwlist.h                        |   4 +-
src/include/utils/jsonfuncs.h                      |   2 +-
src/interfaces/ecpg/test/expected/sql-sqljson.c    | 204 ++++++++++++-
.../ecpg/test/expected/sql-sqljson.stderr          | 201 ++++++++++++-
.../ecpg/test/expected/sql-sqljson.stdout          |  16 +
src/interfaces/ecpg/test/sql/sqljson.pgc           |  60 ++++
src/test/regress/expected/sqljson.out              | 332 +++++++++++++++++++++
src/test/regress/sql/sqljson.sql                   |  85 ++++++
src/tools/pgindent/typedefs.list                   |   3 +
22 files changed, 1397 insertions(+), 42 deletions(-)


pgsql-committers by date:

Previous
From: Masahiko Sawada
Date:
Subject: pgsql: Fix crash with RemoveFromWaitQueue() when detecting a deadlock.
Next
From: Nathan Bossart
Date:
Subject: pgsql: Adjust extra lines generated by psql to be valid SQL comments.