Re: ❓ JSON Path Dot Precedence - Mailing list pgsql-hackers

From David E. Wheeler
Subject Re: ❓ JSON Path Dot Precedence
Date
Msg-id 1B2C549C-429E-402F-9E43-377E7408B831@justatheory.com
Whole thread Raw
In response to Re: ❓ JSON Path Dot Precedence  (Erik Wienhold <ewie@ewie.name>)
List pgsql-hackers
On Apr 7, 2024, at 15:46, Erik Wienhold <ewie@ewie.name> wrote:

> I guess jsonpath assumes that hex, octal, and binary literals are
> integers.  So there's no ambiguity about any fractional part that might
> follow.

Yeah, that’s what the comment in the flex file says:

https://github.com/postgres/postgres/blob/b4a71cf/src/backend/utils/adt/jsonpath_scan.l#L102-L105


> Also, is there even a use case for path "0x2.p10"?  The path has to
> start with "$" or ("@" in case of a filter expression), doesn't it?  And
> it that case it doesn't parse:
>
>    test=# select '$.0x2.p10'::jsonpath;
>    ERROR:  trailing junk after numeric literal at or near ".0x" of jsonpath input
>    LINE 1: select '$.0x2.p10'::jsonpath;
>
> Even with extra whitespace:
>
>    test=# select '$ . 0x2 . p10'::jsonpath;
>    ERROR:  syntax error at or near "0x2" of jsonpath input
>    LINE 1: select '$ . 0x2 . p10'::jsonpath;
>
> Or should it behave like an array accessor?  Similar to:
>
>    test=# select jsonb_path_query('[0,1,{"p10":42},3]', '$[0x2].p10'::jsonpath);
>     jsonb_path_query
>    ------------------
>     42
>    (1 row)

I too am curious why these parse successfully, but don’t appear to be useful.

Best,

David




pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: Use streaming read API in ANALYZE
Next
From: Andres Freund
Date:
Subject: Re: Streaming read-ready sequential scan code