Re: SQL:2023 JSON simplified accessor support

Поиск
Список
Период
Сортировка
От jian he
Тема Re: SQL:2023 JSON simplified accessor support
Дата
Msg-id CACJufxFg0Li_skG2NCFg=EneaqhnPBrVDLeAm6yVFWkdoY3y5w@mail.gmail.com
обсуждение исходный текст
Ответ на Re: SQL:2023 JSON simplified accessor support  (Alexandra Wang <alexandra.wang.oss@gmail.com>)
Список pgsql-hackers
On Tue, Aug 26, 2025 at 11:53 AM Alexandra Wang
<alexandra.wang.oss@gmail.com> wrote:
>
> Hi Jian,
>
> I’ve attached v14, which includes only indentation and comment changes
> from v13.
>

hi.
still reviewing v14-0001 to v14-0005.

I am confused by the comments in jsonb_subscript_transform
""
     * (b) jsonb_subscript_make_jsonpath() examined the first indirection
     * element but could not turn it into a JsonPath component (for example,
     * ['a']).
"""
CREATE TABLE ts2 AS SELECT '{"a": "b"}' ::jsonb jb;
SELECT (jb)['a'] FROM ts2;
SELECT (jb).a['a'] FROM ts2;
in these two cases, ['a'], it won't reach jsonb_subscript_make_jsonpath,
because jsonb_check_jsonpath_needed will return false.

maybe I am missing something,
for the above point b, can you use some SQL example to explain it?


make_jsonpath_item_expr(ParseState *pstate, Node *expr, List **exprs)
if expr satisfies the condition, then append the transformed expr to List exprs
if not returns NULL.
The list append logic is within make_jsonpath_item_int.
seems not that intuitive (another level of indirection)
maybe we don't need make_jsonpath_item_int.

Another reason would be in make_jsonpath_item_int it's not easy found
out that exprs actually refers to SubscriptingRef->refupperindexpr

also v14-0006-Implement-Jsonb-subscripting-with-slicing.patch also doesn't use
make_jsonpath_item_int that much frequently.
--------------------------------
in v14-0005-Implement-read-only-dot-notation-for-jsonb.patch

+ * In addition to building the JsonPath expression, this function populates
+ * the following fields of the given SubscriptingRef:
+ * - refjsonbpath: the generated JsonPath
+ * - refupperindexpr: upper index expressions (object keys or array indexes)
+ * - reflowerindexpr: lower index expressions, remains NIL as slices
are not yet supported.

"reflowerindexpr" changed in v14-0006, so "reflowerindexpr" comments
in v14-0006 need to change.
but "reflowerindexpr" we didn't touch in v14-0005, so the
"reflowerindexpr" comments look weird.


+SELECT (jb).a['b'] FROM test_jsonb_dot_notation; -- returns NULL due
to strict mode
we can not specify strict just like,  ``select 'strict $'::jsonpath;``
all the patches in here are default to lax mode.
so I am confused by this comment. ("strict mode").



В списке pgsql-hackers по дате отправления: