IS JSON predicate

Enterprise / PostgreSQL - Andrew Dunstan [dunslane.net] - 28 March 2022 19:37 UTC

This patch intrdocuces the SQL standard . It operates on text and bytea values representing JSON as well as on the json and jsonb types. Each test has an IS and IS NOT variant. The tests are:

IS JSON [VALUE] IS JSON ARRAY IS JSON OBJECT IS JSON SCALAR IS JSON WITH | WITHOUT UNIQUE KEYS

These are mostly self-explanatory, but note that IS JSON WITHOUT UNIQUE KEYS is true whenever IS JSON is true, and IS JSON WITH UNIQUE KEYS is true whenever IS JSON is true except it IS JSON OBJECT is true and there are duplicate keys (which is never the case when applied to jsonb values).

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

33a377608f IS JSON predicate
src/backend/executor/execExpr.c | 13 +++
src/backend/executor/execExprInterp.c | 95 ++++++++++++++++
src/backend/jit/llvm/llvmjit_expr.c | 6 ++
src/backend/jit/llvm/llvmjit_types.c | 1 +
src/backend/nodes/copyfuncs.c | 20 ++++
src/backend/nodes/equalfuncs.c | 15 +++
src/backend/nodes/makefuncs.c | 19 ++++
src/backend/nodes/nodeFuncs.c | 26 +++++
src/backend/nodes/outfuncs.c | 14 +++
src/backend/nodes/readfuncs.c | 18 ++++
src/backend/parser/gram.y | 63 ++++++++++-
src/backend/parser/parse_expr.c | 76 +++++++++++++
src/backend/utils/adt/json.c | 105 +++++++++++++++---
src/backend/utils/adt/jsonfuncs.c | 20 ++++
src/backend/utils/adt/ruleutils.c | 35 ++++++
src/backend/utils/misc/queryjumble.c | 10 ++
src/include/executor/execExpr.h | 8 ++
src/include/nodes/makefuncs.h | 3 +
src/include/nodes/nodes.h | 1 +
src/include/nodes/primnodes.h | 26 +++++
src/include/parser/kwlist.h | 1 +
src/include/utils/json.h | 1 +
src/include/utils/jsonfuncs.h | 3 +
src/test/regress/expected/sqljson.out | 198 ++++++++++++++++++++++++++++++++++
src/test/regress/sql/sqljson.sql | 96 +++++++++++++++++
25 files changed, 856 insertions(+), 17 deletions(-)

Upstream: git.postgresql.org


  • Share