pgsql: SQL JSON functions

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: SQL JSON functions
Date: 2022-03-30 20:30:51
Message-ID: E1nZexv-0003BZ-1w@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

SQL JSON functions

This Patch introduces three SQL standard JSON functions:

JSON() (incorrectly mentioned in my commit message for f4fb45d15c)
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.

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/606948b058dc16bce494270eea577011a602810e

Modified Files
--------------
doc/src/sgml/keywords/sql2016-02-reserved.txt | 3 +
src/backend/executor/execExpr.c | 45 +++++
src/backend/executor/execExprInterp.c | 42 +++-
src/backend/nodes/copyfuncs.c | 53 +++++
src/backend/nodes/equalfuncs.c | 38 ++++
src/backend/nodes/nodeFuncs.c | 14 ++
src/backend/parser/gram.y | 56 +++++-
src/backend/parser/parse_expr.c | 152 +++++++++++++--
src/backend/parser/parse_target.c | 9 +
src/backend/utils/adt/format_type.c | 4 +
src/backend/utils/adt/json.c | 51 +++--
src/backend/utils/adt/jsonb.c | 64 +++---
src/backend/utils/adt/ruleutils.c | 13 +-
src/include/executor/execExpr.h | 5 +
src/include/nodes/nodes.h | 3 +
src/include/nodes/parsenodes.h | 35 ++++
src/include/nodes/primnodes.h | 5 +-
src/include/parser/kwlist.h | 4 +-
src/include/utils/json.h | 21 +-
src/include/utils/jsonb.h | 21 ++
src/test/regress/expected/sqljson.out | 267 ++++++++++++++++++++++++++
src/test/regress/sql/sqljson.sql | 57 ++++++
22 files changed, 880 insertions(+), 82 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Robert Haas 2022-03-30 21:44:55 Re: pgsql: Add 'basebackup_to_shell' contrib module.
Previous Message Tom Lane 2022-03-30 20:22:03 Re: pgsql: Add 'basebackup_to_shell' contrib module.