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