IS JSON predicate
authorAndrew Dunstan <[email protected]>
Thu, 3 Mar 2022 18:02:53 +0000 (13:02 -0500)
committerAndrew Dunstan <[email protected]>
Mon, 28 Mar 2022 19:37:08 +0000 (15:37 -0400)
commit33a377608fc29cdd1f6b63be561eab0aee5c81f0
tree47abccafdaeae1c4466c917bbd85912f39558360
parent6198420ad8a72e37f4fe4964616b17e0fd33b808
IS JSON predicate

This patch intrdocuces the SQL standard IS JSON predicate. 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
25 files changed:
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/copyfuncs.c
src/backend/nodes/equalfuncs.c
src/backend/nodes/makefuncs.c
src/backend/nodes/nodeFuncs.c
src/backend/nodes/outfuncs.c
src/backend/nodes/readfuncs.c
src/backend/parser/gram.y
src/backend/parser/parse_expr.c
src/backend/utils/adt/json.c
src/backend/utils/adt/jsonfuncs.c
src/backend/utils/adt/ruleutils.c
src/backend/utils/misc/queryjumble.c
src/include/executor/execExpr.h
src/include/nodes/makefuncs.h
src/include/nodes/nodes.h
src/include/nodes/primnodes.h
src/include/parser/kwlist.h
src/include/utils/json.h
src/include/utils/jsonfuncs.h
src/test/regress/expected/sqljson.out
src/test/regress/sql/sqljson.sql