pgsql: Add additional jsonpath string methods

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Add additional jsonpath string methods
Date: 2026-04-02 19:20:03
Message-ID: E1w8NaF-002eKx-0A@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Add additional jsonpath string methods

Add the following jsonpath methods:

* l/r/btrim()
* lower(), upper()
* initcap()
* replace()
* split_part()

Each simply dispatches to the standard string processing functions.
These depend on the locale, but since it's set at `initdb`, they can be
considered immutable and therefore allowed in any jsonpath expression.

Author: Florents Tselai <florents(dot)tselai(at)gmail(dot)com>
Co-authored-by: David E. Wheeler <david(at)justatheory(dot)com>
Reviewed-by: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Reviewed-by: Andrew Dunstan <andrew(at)dunslane(dot)net>
Discussion: https://postgr.es/m/CA+v5N40sJF39m0v7h=QN86zGp0CUf9F1WKasnZy9nNVj_VhCZQ@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/bd4f879a9cdd11b6b683cea0ea51d7c27a8f1153

Modified Files
--------------
doc/src/sgml/func/func-json.sgml | 140 +++++++++
src/backend/utils/adt/jsonpath.c | 117 ++++++-
src/backend/utils/adt/jsonpath_exec.c | 178 +++++++++++
src/backend/utils/adt/jsonpath_gram.y | 33 +-
src/backend/utils/adt/jsonpath_scan.l | 8 +
src/include/utils/jsonpath.h | 8 +
src/test/regress/expected/jsonb_jsonpath.out | 381 +++++++++++++++++++++++
src/test/regress/expected/jsonpath.out | 186 +++++++++++
src/test/regress/expected/sqljson_queryfuncs.out | 10 +-
src/test/regress/sql/jsonb_jsonpath.sql | 106 +++++++
src/test/regress/sql/jsonpath.sql | 41 +++
src/test/regress/sql/sqljson_queryfuncs.sql | 11 +-
12 files changed, 1212 insertions(+), 7 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Robert Haas 2026-04-02 19:56:26 Re: pgsql: Reduce log level of some logical decoding messages from LOG to D
Previous Message Masahiko Sawada 2026-04-02 18:35:19 pgsql: Add target_relid parameter to pg_get_publication_tables().