Re: [PATCH] WIP: replace method for jsonpath

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Peter Eisentraut <peter(at)eisentraut(dot)org>, "David E(dot) Wheeler" <david(at)justatheory(dot)com>, Florents Tselai <florents(dot)tselai(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [PATCH] WIP: replace method for jsonpath
Date: 2024-09-18 12:47:21
Message-ID: 906fe018-6999-4ae9-9a76-650088450e4b@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On 2024-09-18 We 4:23 AM, Peter Eisentraut wrote:
> On 17.09.24 21:16, David E. Wheeler wrote:
>> On Sep 17, 2024, at 15:03, Florents Tselai
>> <florents(dot)tselai(at)gmail(dot)com> wrote:
>>
>>> Fallback scenario: make this an extension, but in a first pass I
>>> didn’t find any convenient hooks.
>>> One has to create a whole new scanner, grammar etc.
>>
>> Yeah, it got me thinking about the RFC-9535 JSONPath "Function
>> Extension" feature[1], which allows users to add functions. Would be
>> cool to have a way to register jsonpath functions somehow, but I
>> would imagine it’d need quite a bit of specification similar to
>> RFC-9535. Wouldn’t surprise me to see something like that appear in a
>> future version of the spec, with an interface something like CREATE
>> OPERATOR.
>
> Why can't we "just" call any suitable pg_proc-registered function from
> JSON path?  The proposed patch routes the example
> '$.replace("hello","bye")' internally to the internal implementation
> of the SQL function replace(..., 'hello', 'bye'). Why can't we do this
> automatically for any function call in a JSON path expression?
>
>
>

That might work. The thing that bothers me about the original proposal
is this: what if we add a new non-spec jsonpath method and then a new
version of the spec adds a method with the same name, but not compatible
with our method? We'll be in a nasty place. At the very least I think we
need to try hard to avoid that. Maybe we should prefix non-spec method
names with "pg_", or maybe use an initial capital letter.

cheers

andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message jian he 2024-09-18 13:06:00 attndims, typndims still not enforced, but make the value within a sane threshold
Previous Message Alexander Korotkov 2024-09-18 12:22:57 Re: May be BUG. Periodic burst growth of the checkpoint_req counter on replica.