Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1urAYC-001h5s-Ga for pgsql-hackers@arkaria.postgresql.org; Wed, 27 Aug 2025 07:26:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1urAYB-00D8bz-Sr for pgsql-hackers@arkaria.postgresql.org; Wed, 27 Aug 2025 07:26:32 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1urAYB-00D8Zv-FX for pgsql-hackers@lists.postgresql.org; Wed, 27 Aug 2025 07:26:32 +0000 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1urAY9-0026MU-0S for pgsql-hackers@postgresql.org; Wed, 27 Aug 2025 07:26:31 +0000 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-770593ba164so2935496b3a.3 for ; Wed, 27 Aug 2025 00:26:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1756279587; x=1756884387; darn=postgresql.org; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=8YZi731pMkpSALfqr8t2xYRABcicQffC3A5MdHBUHSA=; b=I+f98zUT5+PCdbrBuGDPQE/FVtWFQEK32Puv4/gLvvETI81z0RlIeWGN0q2Z1Us8s7 SvD3ZL5fy18o4OZfYIHiFqjASqEv8MvlzrFwYfPVPiFxVZjWBM6vZe/JaORNevNM6Vr2 +joxgclE1qo3n8sIi0F/K2LWd2IpeEU1Qy8c0Wx8ZjkSdJv0NpyuLTpogujCZGjzZkGj pcNFiO1ZznMazvpzE8wAjYYv6QV2vSSXqjsHLwqzEVT/qTI6x9PL4qZmM/3B3J6dZXCz yzmMfZeUh8X/qxRvjCOGWBK+iaLN+qmOwLyqHZ1mNjocCnUxaP3nJVmGKnUBJLD2a0Rx R/AA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756279587; x=1756884387; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=8YZi731pMkpSALfqr8t2xYRABcicQffC3A5MdHBUHSA=; b=X7AGqzVl8EDFh0PXHCF+OapCZ7igwMus3+jZvn8b+0JPTC9S8Sjvg5nuR02dfEMJLf FunAtneOtAs3m5CFaNr028i2X/8nUd3aS77YRtatA7WOssyeWJrU//I6oqrU8Ng9h5Kt gJTk1sarjdwAeRtxGQduMEO1WdUEaSrmOo02LTkqQj9cOLjkvAmp9yj92C2Fj3SfBAm4 ziTrBq76Ud1qG8Bttnh5+lEFL0pLu3nNknA5GEezH06z6w3Ht3Z5pMXbk6W1sQM4GcFA mgWqneLw98/EZiMymGnElmaXxomJ2H5kQjLQNabbu/BzZQSp1dqLIDYpmQbHrihNoaPX HOjw== X-Forwarded-Encrypted: i=1; AJvYcCW0+QvQn5xiBOG0sY9zpHlNkctuFYHsNHluKVcRoLNJwMg0RmsgVxbL/CDwh4sph81FKyeqakl8Ck+A5z/f@postgresql.org X-Gm-Message-State: AOJu0Yxd1ysovfQSnpqzMJODuEmxYRPDkUkh9YQjNHssUblErBVtumpk +BRODqFqUy63nqNuaRkbyBoGI7KKB94BRH4E3ZRUQhJteEPky5Uqgm6M X-Gm-Gg: ASbGncvr01Tn0glHZm7v6ECB0kpX9rWnGYjJR5vANdkbgcBS76gKhPTpEZnNrciVvlt EigGcMeNoF/yon0YnYaJUhSPk5zYuR5+T32RwGj9l0WSOVrgKSug2GoPVkWItk6wBijprqMyaci WjesvJwKcdFeWlxs8IRu4/HVI/HkHRvr1riQfKYV986oYY04huO9WMWT+5eBWvZWPYDGoMQMHNa 5uFG7R8TFLHUJDDAveO2B/1WNSTWalVFieHqybkj3i3btdD53bHM32I5qAb0rvoyT5k+J5gK3ck Qrz60x6cyPWR/3CJsmuUatjZsLXBcqG4DKO9BQkdTYfFSrAf21uDaz7eqwL7yTBlscGmsbnFnwW sL4JlZr0Kbd6igFRyhaRapSEgVwq/59qv4EQElOLMSbs= X-Google-Smtp-Source: AGHT+IGCs2JqyRe21brTKxE9AgAMzQDEaH8kvJRaP76/IcdaeFBsz9wrUHf86imyIrn7lsF0kCNeQA== X-Received: by 2002:a05:6a21:33a2:b0:240:1dca:d13d with SMTP id adf61e73a8af0-24340d4407dmr29503720637.43.1756279586562; Wed, 27 Aug 2025 00:26:26 -0700 (PDT) Received: from smtpclient.apple ([142.171.105.12]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-b49d4ffc22esm9403330a12.34.2025.08.27.00.26.22 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Aug 2025 00:26:25 -0700 (PDT) From: Chao Li Message-Id: <263CAF0D-7776-4349-93CA-CC1AB15384CA@gmail.com> Content-Type: multipart/alternative; boundary="Apple-Mail=_A439B88B-C838-409E-A581-BE4F25C7D328" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.700.81\)) Subject: Re: SQL:2023 JSON simplified accessor support Date: Wed, 27 Aug 2025 15:26:08 +0800 In-Reply-To: Cc: jian he , Nikita Malakhov , Vik Fearing , Mark Dilger , Matheus Alcantara , Peter Eisentraut , Andrew Dunstan , Nikita Glukhov , PostgreSQL Hackers , "David E. Wheeler" To: Alexandra Wang References: <21fa36b4-6d56-4556-b524-9e3955b922c8@eisentraut.org> X-Mailer: Apple Mail (2.3826.700.81) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail=_A439B88B-C838-409E-A581-BE4F25C7D328 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Aug 26, 2025, at 11:52, Alexandra Wang = wrote: >=20 > Best, > Alex > = I just started with 0001, I just got a comment: diff --git a/src/include/parser/parse_node.h = b/src/include/parser/parse_node.h index f7d07c84542..58a4b9df157 100644 --- a/src/include/parser/parse_node.h +++ b/src/include/parser/parse_node.h @@ -361,7 +361,7 @@ extern SubscriptingRef = *transformContainerSubscripts(ParseState *pstate, = Node *containerBase, = Oid containerType, = int32 containerTypMod, - = List *indirection, + = List **indirection, = bool isAssignment); Here we change =E2=80=9Cindirection=E2=80=9D from * to **, I guess the = reason is to indicate if the indirection list is fully processed. In = case of fully processed, set it to NULL, then caller gets NULL via **. As =E2=80=9Cindirection=E2=80=9D is of type =E2=80=9CList *=E2=80=9D, = can we just set =E2=80=9Cindirection->length =3D 0=E2=80=9D? I checked = pg_list.h, there is not a function or macro to cleanup a list (free = elements and reset length to 0). There is a =E2=80=9Clist_free(List = *list)=E2=80=9D, but it will free =E2=80=9Clist=E2=80=9D itself as well. = Maybe we can add a new function, say =E2=80=9Clist_reset(List *list)=E2=80= =9D or =E2=80=9Clist_cleanup(List *list)=E2=80=9D. This way will keep = the function interface unchanged, and less changes would be involved. diff --git a/src/backend/parser/parse_expr.c = b/src/backend/parser/parse_expr.c index d66276801c6..e1565e11d09 100644 --- a/src/backend/parser/parse_expr.c +++ b/src/backend/parser/parse_expr.c @@ -466,14 +466,13 @@ transformIndirection(ParseState *pstate, = A_Indirection *ind) Assert(IsA(n, String)); /* process subscripts before this field = selection */ - if (subscripts) + while (subscripts) result =3D (Node *) = transformContainerSubscripts(pstate, Changing =E2=80=9Cif=E2=80=9D to =E2=80=9Cwhile=E2=80=9D in 0001 is a = little confusing. Because the impression is that, transform will stop = when it cannot handle next indirection, so that transform again will = also fail. Maybe my impression is wrong, can you add some comments here = to explain why change =E2=80=9Cif=E2=80=9D to =E2=80=9Cwhile=E2=80=9D. Regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/ --Apple-Mail=_A439B88B-C838-409E-A581-BE4F25C7D328 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

On Aug 26, 2025, at 11:52, Alexandra Wang = <alexandra.wang.oss@gmail.com> wrote:

Best,
Alex
<v14-0002-Allow-Generic-Type-Subscripting-to-Acc= ept-Dot-No.patch><v14-0003-Export-jsonPathFromParseResult.patch&g= t;<v14-0001-Allow-transformation-of-only-a-sublist= -of-subscr.patch><v14-0005-Implement-read-only-dot-notation-for-j= sonb.patch><v14-0007-Implement-jsonb-wildcard-member-access= or.patch><v14-0006-Implement-Jsonb-subscripting-with-slic= ing.patch><v14-0004-Extract-coerce_jsonpath_subscript.patc= h>

I just started = with 0001, I just got a comment:

diff = --git a/src/include/parser/parse_node.h = b/src/include/parser/parse_node.h
index = f7d07c84542..58a4b9df157 100644
--- = a/src/include/parser/parse_node.h
+++ = b/src/include/parser/parse_node.h
@@ -361,7 +361,7 @@ extern = SubscriptingRef *transformContainerSubscripts(ParseState = *pstate,
              =                     =                     =                     =                     =            Node = *containerBase,
            =                     =                     =                     =                     =              Oid = containerType,
            =                     =                     =                     =                     =              int32 = containerTypMod,
-             =                     =                     =                     =                     =            List *indirection,
+ =                     =                     =                     =                     =                     =    List **indirection,
        =                     =                     =                     =                     =                  bool = isAssignment);

Here we change = =E2=80=9Cindirection=E2=80=9D from * to **, I guess the reason is to = indicate if the indirection list is fully processed. In case of fully = processed, set it to NULL, then caller gets NULL via = **.

As =E2=80=9Cindirection=E2=80=9D is of type = =E2=80=9CList *=E2=80=9D, can we just set =E2=80=9Cindirection->length = =3D 0=E2=80=9D? I checked pg_list.h, there is not a function or macro to = cleanup a list (free elements and reset length to 0). There is a = =E2=80=9Clist_free(List *list)=E2=80=9D, but it will free =E2=80=9Clist=E2= =80=9D itself as well. Maybe we can add a new function, say = =E2=80=9Clist_reset(List *list)=E2=80=9D or =E2=80=9Clist_cleanup(List = *list)=E2=80=9D. This way will keep the function interface unchanged, = and less changes would be involved.

diff = --git a/src/backend/parser/parse_expr.c = b/src/backend/parser/parse_expr.c
index = d66276801c6..e1565e11d09 100644
--- = a/src/backend/parser/parse_expr.c
+++ = b/src/backend/parser/parse_expr.c
@@ -466,14 +466,13 @@ = transformIndirection(ParseState *pstate, A_Indirection = *ind)
                =         Assert(IsA(n, = String));

          =               /* process subscripts = before this field selection */
-         =               if = (subscripts)
+             =           while (subscripts)
  =                     =           result =3D (Node *) = transformContainerSubscripts(pstate,

Changi= ng =E2=80=9Cif=E2=80=9D to =E2=80=9Cwhile=E2=80=9D in 0001 is a little = confusing. Because the impression is that, transform will stop when it = cannot handle next indirection, so that transform again will also fail. = Maybe my impression is wrong, can you add some comments here to explain = why change =E2=80=9Cif=E2=80=9D to = =E2=80=9Cwhile=E2=80=9D.

Regards,
--
Chao Li (Evan)
HighGo Software = Co., = Ltd.
https://www.highgo.com/

= --Apple-Mail=_A439B88B-C838-409E-A581-BE4F25C7D328--