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 1utheQ-00CwZ6-FT for pgsql-hackers@arkaria.postgresql.org; Wed, 03 Sep 2025 07:11:27 +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 1utheP-007jln-Lx for pgsql-hackers@arkaria.postgresql.org; Wed, 03 Sep 2025 07:11:26 +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 1utheP-007jlf-BX for pgsql-hackers@lists.postgresql.org; Wed, 03 Sep 2025 07:11:25 +0000 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1utheL-000JD1-3A for pgsql-hackers@postgresql.org; Wed, 03 Sep 2025 07:11:25 +0000 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-7723bf02181so2840725b3a.1 for ; Wed, 03 Sep 2025 00:11:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1756883481; x=1757488281; 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=N3ApKN9VDPJin1CVsRuyl47sVThEHl3jAGQeh7sJzqI=; b=Z4Ypefsp6IQX3Dw4AYW4SI+gnx5TbucxeIslB11Jpq6cWBSeJSTkzMc6YIkF9j7E74 tSZazcoTWd9FBObEBO90c1bhZ9lOOP/dg/+97AcLaBD5gabnkjdRIlwbYqk29BUc7NOo y5pt1+zaRthIR6SeaqiGlFJRk8L6ZIsJzjJwKebAJLh3JT8aTOxGj0MNeWZSVzl6M/1A nMFa7Iif+Y7Io3Wsp6kGEEFJcql61zjmdUYCvfciCwzPeQJ9TuXbh1CeksQx1R62JFRZ VRZayORYo7H+yxxAt0qq9lEK6BAqugsS1L0hB3R8B3YjEpyFwAqa3s+bdUajvmCY57QG 3png== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756883481; x=1757488281; 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=N3ApKN9VDPJin1CVsRuyl47sVThEHl3jAGQeh7sJzqI=; b=YZ1fq+WgKXYwkwcWQ6IKCqvN/YLKnV47JViE+6qBFpCtoYi8GEZejqEuP8QhJXBZx6 nwLLPxqaaFN7W22aET8n6BdIKWDN7ebst1neL/IBBK3yBdrjIT8AIUuE1n63U+FaMewL MsVlH0FiIh+OA2DzWnY+4/CW4tewItU9gJ1gRCBkczE799pxh3/+B2tmpEmwQypFbPet UshqnD1kKdd8obo/3XFRRSrJhu7HH5I6Ry3Y3tRD2IxclpbqyfdcBrXRNwCpZ16oaGAD 3gcjP0MFBtaQ3J58Isn/2v7irzVGDf0uMYN1vmgIIQnokG72QswvQfsulMebyiCztEQU D6Kw== X-Forwarded-Encrypted: i=1; AJvYcCW1bJDj5ywnwiXstNjVNqE3YOkl60oBvsZFUWGb80UgLoVYdUFzKsoCGrRZcLmrejdGZmdMLSOvbnwBMbfB@postgresql.org X-Gm-Message-State: AOJu0Yw7rE+UTzF9IA4ZzR+Ri3Aqe7u8CVnOA8mzhMDNxJA+vg+Ppu+C yJBtGyYBErQKL8W7b+IeG8zti72A63JqmeRuBkV72/ycYY3Nd4QHE9TU X-Gm-Gg: ASbGncucRCgo4bCUorX7BYFwNNq6Ts6G0wj2giCuY4i/HOeJoR4hInLtWb1IZ/+jdN/ N4RC01nlrr6pHI2RPi+iuhlKkRfG+jUy+JBNIJf7UBOO2gZdSKWAB8NZ2o8sabiPzOBm6uoOUSU T+4SbFIXFL4jpF6UDlOlbP0VU+wlRMmAaSVc42j6trJ+yjzkIfNJm6Uqn9py0H1Lmug9Qw1oYoq qzPO28NGPXvDlu5G+x/r/1K3cUn3O7es6j9mo2ySme4/NttPA8aporgjp4/LTOlyiqnCanIMpNs VWkysHWbgoHkoRtscpRvOMRJjYOYVL4/DBTzZs2OetM18Y2X6Zv4Je64K8QW9ONDHWKksGBIcTQ IfivemPVNUYc/0NF1lA/aFqQEyOWj0E7F X-Google-Smtp-Source: AGHT+IHhJlHooHKtFQnFx0X+bAbXuypOrZpYKgY+re4WDvWHeXk7QEEVAQv5BSGyn4sdB2oiWNlrWw== X-Received: by 2002:a05:6a00:2189:b0:772:295b:e6a with SMTP id d2e1a72fcca58-7723e3a153cmr16772832b3a.31.1756883480953; Wed, 03 Sep 2025 00:11:20 -0700 (PDT) Received: from smtpclient.apple ([142.171.105.12]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7722a4bd6b2sm15833695b3a.64.2025.09.03.00.11.16 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Sep 2025 00:11:20 -0700 (PDT) From: Chao Li Message-Id: Content-Type: multipart/alternative; boundary="Apple-Mail=_106CE5BF-C566-4E03-938D-484FC3E8E9A9" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.700.81\)) Subject: Re: SQL:2023 JSON simplified accessor support Date: Wed, 3 Sep 2025 15:11:03 +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> <290418A2-3A9B-4304-AAAD-4A40CFF1CB93@gmail.com> <98C6F445-773B-4C82-8198-7F5CD56D5252@gmail.com> 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=_106CE5BF-C566-4E03-938D-484FC3E8E9A9 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Sep 3, 2025, at 10:16, Alexandra Wang = wrote: >=20 >=20 > = I have a few more other small comments: 1 - 0002 ``` diff --git a/src/backend/parser/parse_expr.c = b/src/backend/parser/parse_expr.c index 6e8fd42c612..ff104c95311 100644 --- a/src/backend/parser/parse_expr.c +++ b/src/backend/parser/parse_expr.c @@ -441,8 +441,9 @@ transformIndirection(ParseState *pstate, = A_Indirection *ind) ListCell *i; =20 /* - * We have to split any field-selection operations apart from - * subscripting. Adjacent A_Indices nodes have to be treated as = a single + * Combine field names and subscripts into a single indirection = list, as + * some subscripting containers, such as jsonb, support field = access using + * dot notation. Adjacent A_Indices nodes have to be treated as = a single * multidimensional subscript operation. */ foreach(i, ind->indirection) @@ -460,19 +461,43 @@ transformIndirection(ParseState *pstate, = A_Indirection *ind) } else { - Node *newresult; - Assert(IsA(n, String)); + subscripts =3D lappend(subscripts, n); + } + } ``` I raised this comment in my previous email, I guess you missed this one. With this change, the 3 clauses are quite similar, the if-elseif-else = can be simplified as: If (!IsA(n, A_Indices) && !Is_A(n, A_Start)) Assert(IsA(n, String)); subscripts =3D lappend(subscripts, n) 2 - 0001 ``` diff --git a/src/include/nodes/subscripting.h = b/src/include/nodes/subscripting.h index 234e8ad8012..5d576af346f 100644 --- a/src/include/nodes/subscripting.h +++ b/src/include/nodes/subscripting.h @@ -71,6 +71,11 @@ struct SubscriptExecSteps; * does not care to support slicing, it can just throw an error if = isSlice.) * See array_subscript_transform() for sample code. * + * The transform method receives a pointer to a list of raw = indirections. + * This allows the method to parse a sublist of the indirections = (typically + * the prefix) and modify the original list in place, enabling the = caller to + * either process the remaining indirections differently or raise an = error. + * * The transform method is also responsible for identifying the result = type ``` This is nit comment about the wording. =E2=80=9CThis allows the method = to parse a sublist..." sounds like more from the patch perspective. = It=E2=80=99s more suitable for git commit comments, but code comment, I = feel it=E2=80=99s better to be more general, for example: * The transform method receives a pointer to a list of raw indirections. * It can parse a sublist (typically the prefix) of these indirections = and * modify the original list in place, allowing the caller to either = handle * the remaining indirections differently or raise an error. 3 - 0005 ``` diff --git a/src/backend/executor/execExpr.c = b/src/backend/executor/execExpr.c index f1569879b52..eac31b097e4 100644 --- a/src/backend/executor/execExpr.c +++ b/src/backend/executor/execExpr.c @@ -3320,50 +3320,54 @@ ExecInitSubscriptingRef(ExprEvalStep *scratch, = SubscriptingRef *sbsref, = state->steps_len - 1); } =20 + /* When slicing, individual subscript bounds can = be omitted */ + if (!e) + { + sbsrefstate->upperprovided[i] =3D false; + sbsrefstate->upperindexnull[i] =3D true; + } + else { + sbsrefstate->upperprovided[i] =3D true; ``` This is also a nit comment about code format. =E2=80=9C{" should be put = to the next line of =E2=80=9Celse=E2=80=9D according to other existing = code. Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/ --Apple-Mail=_106CE5BF-C566-4E03-938D-484FC3E8E9A9 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

On Sep 3, 2025, at 10:16, Alexandra Wang = <alexandra.wang.oss@gmail.com> wrote:


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

I have a few more other small = comments:

1 - = 0002
```
diff --git = a/src/backend/parser/parse_expr.c = b/src/backend/parser/parse_expr.c
index = 6e8fd42c612..ff104c95311 100644
--- = a/src/backend/parser/parse_expr.c
+++ = b/src/backend/parser/parse_expr.c
@@ -441,8 +441,9 @@ = transformIndirection(ParseState *pstate, A_Indirection = *ind)
  ListCell   = *i;
 
  /*
- * We = have to split any field-selection operations apart from
- * = subscripting.  Adjacent A_Indices nodes have to be treated as a = single
+ * Combine field names and = subscripts into a single indirection list, as
+ * some = subscripting containers, such as jsonb, support field access = using
+= * dot notation. Adjacent A_Indices nodes have to be = treated as a single
  * multidimensional subscript = operation.
  */
  = foreach(i, ind->indirection)
@@ -460,19 +461,43 @@ = transformIndirection(ParseState *pstate, A_Indirection = *ind)
  }
  = else
  {
- = Node =   *newresult;
-
  = Assert(IsA(n, String));
+ subscripts =3D = lappend(subscripts, n);
+ }
+ = }
```

I raised this = comment in my previous email, I guess you missed this = one.

With this change, the 3 clauses are quite = similar, the if-elseif-else can be simplified = as:

     If (!IsA(n, A_Indices) = && !Is_A(n, A_Start))
        =   Assert(IsA(n, String));
     subscripts = =3D lappend(subscripts, n)

2 - = 0001
```
diff --git = a/src/include/nodes/subscripting.h = b/src/include/nodes/subscripting.h
index = 234e8ad8012..5d576af346f 100644
--- = a/src/include/nodes/subscripting.h
+++ = b/src/include/nodes/subscripting.h
@@ -71,6 +71,11 @@ struct = SubscriptExecSteps;
  * does not care to support slicing, = it can just throw an error if isSlice.)
  * See = array_subscript_transform() for sample code.
  = *
+ * The transform method receives a pointer to a list of raw = indirections.
+ * This allows the method to parse a sublist of = the indirections (typically
+ * the prefix) and modify the = original list in place, enabling the caller to
+ * either = process the remaining indirections differently or raise an = error.
+ *
  * The transform method is also = responsible for identifying the result = type
```

This is nit comment about = the wording. =E2=80=9CThis allows the method to parse a sublist..." = sounds like more from the patch perspective. It=E2=80=99s more suitable = for git commit comments, but code comment, I feel it=E2=80=99s better to = be more general, for = example:

* The transform meth= od receives a pointer to a list of = ;raw indirections.
 * It can parse a = ;sublist (typically the prefix) of these ind= irections and
 * modify the original list=  in place, allowing the caller to eithe= r handle
 * the remaining indirections di= fferently or raise an error.

3 - 0005
```
diff --git = a/src/backend/executor/execExpr.c = b/src/backend/executor/execExpr.c
index = f1569879b52..eac31b097e4 100644
--- = a/src/backend/executor/execExpr.c
+++ = b/src/backend/executor/execExpr.c
@@ -3320,50 +3320,54 @@ = ExecInitSubscriptingRef(ExprEvalStep *scratch, SubscriptingRef = *sbsref,
  =   state->steps_len - 1);
  = }
 
+ /* When slicing, = individual subscript bounds can be omitted */
+ = if (!e)
+ = {
+ = sbsrefstate->upperprovided[i] =3D false;
+ = sbsrefstate->upperindexnull[i] =3D true;
+ = }
+ else = {
+ = sbsrefstate->upperprovided[i] =3D = true;
```

This is also a nit = comment about code format. =E2=80=9C{" should be put to the next line of = =E2=80=9Celse=E2=80=9D according to other existing = code.

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




= --Apple-Mail=_106CE5BF-C566-4E03-938D-484FC3E8E9A9--