Re: SQL:2023 JSON simplified accessor support

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: Alexandra Wang <alexandra(dot)wang(dot)oss(at)gmail(dot)com>
Cc: Nikita Malakhov <hukutoc(at)gmail(dot)com>, Vik Fearing <vik(at)postgresfriends(dot)org>, Mark Dilger <mark(dot)dilger(at)enterprisedb(dot)com>, Matheus Alcantara <matheusssilv97(at)gmail(dot)com>, Peter Eisentraut <peter(at)eisentraut(dot)org>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Nikita Glukhov <glukhov(dot)n(dot)a(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, "David E(dot) Wheeler" <david(at)justatheory(dot)com>
Subject: Re: SQL:2023 JSON simplified accessor support
Date: 2025-06-25 07:40:50
Message-ID: CACJufxGPUKL39f7GX9PDRsUAHGZvtOGTuiUWVrMSP63FAgVVGA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Jun 25, 2025 at 1:56 PM jian he <jian(dot)universality(at)gmail(dot)com> wrote:
>
> hi.

CREATE TABLE test_jsonb_dot_notation AS
SELECT '{"a": [1, 2, {"b": "c"}, {"b": "d", "e": "f", "x": {"y":
"yyy", "z": "zzz"}}], "b": [3, 4, {"b": "g", "x": {"y": "YYY", "z":
"ZZZ"}}]}'::jsonb jb;
CREATE VIEW v1 AS SELECT (jb).a[3].x.y FROM test_jsonb_dot_notation;
CREATE VIEW v2 AS SELECT (jb).a[3:].x.y[:-1] FROM test_jsonb_dot_notation;
CREATE VIEW v3 AS SELECT (jb).a[:3].x.y[-1:] FROM test_jsonb_dot_notation;

\sv v2
\sv v3
will trigger segment fault.

also do we need ban subscript slicing, when upper bound is less than
lower bound,
for example:
SELECT (jb).a[3:].x.y[0:'-1'::integer] AS y FROM test_jsonb_dot_notation;

please check the attached minor refactoring, which addresses the above issue
based on patches v11-0001 through v11-0006.

Attachment Content-Type Size
v11-0001-misc-refactoring-SubscriptingRef-deparsing.no-cfbot application/octet-stream 3.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andy Fan 2025-06-25 07:47:27 Remove HeapTupleheaderSetXmin{Committed,Invalid} functions
Previous Message Sutou Kouhei 2025-06-25 07:35:47 Re: Make COPY format extendable: Extract COPY TO format implementations