pg.ddx.io pgsql-committers@postgresql.org mailing list archive
help / color / mirror / Atom feedpgsql: SQL/JSON query functions
4+ messages / 3 participants
[nested] [flat]
* pgsql: SQL/JSON query functions
@ 2022-03-29 20:57 Andrew Dunstan <andrew@dunslane.net>
0 siblings, 1 reply; 4+ messages in thread
From: Andrew Dunstan @ 2022-03-29 20:57 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
SQL/JSON query functions
This introduces the SQL/JSON functions for querying JSON data using
jsonpath expressions. The functions are:
JSON_EXISTS()
JSON_QUERY()
JSON_VALUE()
All of these functions only operate on jsonb. The workaround for now is
to cast the argument to jsonb.
JSON_EXISTS() tests if the jsonpath expression applied to the jsonb
value yields any values. JSON_VALUE() must return a single value, and an
error occurs if it tries to return multiple values. JSON_QUERY() must
return a json object or array, and there are various WRAPPER options for
handling scalar or multi-value results. Both these functions have
options for handling EMPTY and ERROR conditions.
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/1a36bc9dba8eae90963a586d37b6457b32b2fed4
Modified Files
--------------
src/backend/executor/execExpr.c | 206 ++++--
src/backend/executor/execExprInterp.c | 543 ++++++++++++++
src/backend/jit/llvm/llvmjit_expr.c | 6 +
src/backend/jit/llvm/llvmjit_types.c | 1 +
src/backend/nodes/copyfuncs.c | 150 ++++
src/backend/nodes/equalfuncs.c | 127 ++++
src/backend/nodes/makefuncs.c | 15 +
src/backend/nodes/nodeFuncs.c | 186 ++++-
src/backend/nodes/outfuncs.c | 70 ++
src/backend/nodes/readfuncs.c | 86 +++
src/backend/optimizer/path/costsize.c | 3 +-
src/backend/optimizer/util/clauses.c | 32 +
src/backend/parser/gram.y | 333 ++++++++-
src/backend/parser/parse_collate.c | 4 +
src/backend/parser/parse_expr.c | 490 ++++++++++++-
src/backend/parser/parse_target.c | 15 +
src/backend/utils/adt/formatting.c | 45 +-
src/backend/utils/adt/jsonb.c | 62 ++
src/backend/utils/adt/jsonfuncs.c | 50 +-
src/backend/utils/adt/jsonpath.c | 257 +++++++
src/backend/utils/adt/jsonpath_exec.c | 350 +++++++--
src/backend/utils/adt/ruleutils.c | 135 ++++
src/backend/utils/misc/queryjumble.c | 21 +
src/include/executor/execExpr.h | 54 ++
src/include/executor/executor.h | 2 +
src/include/nodes/makefuncs.h | 1 +
src/include/nodes/nodes.h | 7 +
src/include/nodes/parsenodes.h | 59 ++
src/include/nodes/primnodes.h | 109 +++
src/include/parser/kwlist.h | 11 +
src/include/utils/formatting.h | 4 +
src/include/utils/jsonb.h | 3 +
src/include/utils/jsonfuncs.h | 4 +
src/include/utils/jsonpath.h | 33 +
src/test/regress/expected/json_sqljson.out | 15 +
src/test/regress/expected/jsonb_sqljson.out | 1018 +++++++++++++++++++++++++++
src/test/regress/parallel_schedule | 2 +-
src/test/regress/sql/json_sqljson.sql | 11 +
src/test/regress/sql/jsonb_sqljson.sql | 317 +++++++++
39 files changed, 4716 insertions(+), 121 deletions(-)
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: pgsql: SQL/JSON query functions
@ 2022-04-02 03:15 Michael Paquier <michael@paquier.xyz>
parent: Andrew Dunstan <andrew@dunslane.net>
0 siblings, 1 reply; 4+ messages in thread
From: Michael Paquier @ 2022-04-02 03:15 UTC (permalink / raw)
To: Andrew Dunstan <andrew@dunslane.net>; +Cc: pgsql-committers@lists.postgresql.org
Hi Andrew,
On Tue, Mar 29, 2022 at 08:57:37PM +0000, Andrew Dunstan wrote:
> SQL/JSON query functions
>
> This introduces the SQL/JSON functions for querying JSON data using
> jsonpath expressions. The functions are:
>
> JSON_EXISTS()
> JSON_QUERY()
> JSON_VALUE()
>
> All of these functions only operate on jsonb. The workaround for now is
> to cast the argument to jsonb.
>
> JSON_EXISTS() tests if the jsonpath expression applied to the jsonb
> value yields any values. JSON_VALUE() must return a single value, and an
> error occurs if it tries to return multiple values. JSON_QUERY() must
> return a json object or array, and there are various WRAPPER options for
> handling scalar or multi-value results. Both these functions have
> options for handling EMPTY and ERROR conditions.
Some of the tests introduced in this commit are a bit unstable when
run through a primary/standby setup. conchuela has showed one failure
today:
https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=conchuela&dt=2022-04-02%2002%3A36%3A03
Thanks,
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: pgsql: SQL/JSON query functions
@ 2022-04-02 05:20 Tom Lane <tgl@sss.pgh.pa.us>
parent: Michael Paquier <michael@paquier.xyz>
0 siblings, 1 reply; 4+ messages in thread
From: Tom Lane @ 2022-04-02 05:20 UTC (permalink / raw)
To: Michael Paquier <michael@paquier.xyz>; +Cc: Andrew Dunstan <andrew@dunslane.net>; pgsql-committers@lists.postgresql.org
Michael Paquier <michael@paquier.xyz> writes:
> On Tue, Mar 29, 2022 at 08:57:37PM +0000, Andrew Dunstan wrote:
>> SQL/JSON query functions
> Some of the tests introduced in this commit are a bit unstable when
> run through a primary/standby setup.
Yeah, looks like some of these queries need an ORDER BY.
regards, tom lane
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: pgsql: SQL/JSON query functions
@ 2022-04-02 14:06 Andrew Dunstan <andrew@dunslane.net>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 4+ messages in thread
From: Andrew Dunstan @ 2022-04-02 14:06 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; Michael Paquier <michael@paquier.xyz>; +Cc: pgsql-committers@lists.postgresql.org
On 4/2/22 01:20, Tom Lane wrote:
> Michael Paquier <michael@paquier.xyz> writes:
>> On Tue, Mar 29, 2022 at 08:57:37PM +0000, Andrew Dunstan wrote:
>>> SQL/JSON query functions
>> Some of the tests introduced in this commit are a bit unstable when
>> run through a primary/standby setup.
> Yeah, looks like some of these queries need an ORDER BY.
>
>
Done.
cheers
andrew
--
Andrew Dunstan
EDB: https://www.enterprisedb.com
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2022-04-02 14:06 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-03-29 20:57 pgsql: SQL/JSON query functions Andrew Dunstan <andrew@dunslane.net>
2022-04-02 03:15 ` Michael Paquier <michael@paquier.xyz>
2022-04-02 05:20 ` Tom Lane <tgl@sss.pgh.pa.us>
2022-04-02 14:06 ` Andrew Dunstan <andrew@dunslane.net>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox