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 1v1J8i-006ztx-Ae for pgsql-hackers@arkaria.postgresql.org; Wed, 24 Sep 2025 06:38:08 +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 1v1J8g-00AlcR-W5 for pgsql-hackers@arkaria.postgresql.org; Wed, 24 Sep 2025 06:38:07 +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 1v1J8g-00Albl-L5 for pgsql-hackers@lists.postgresql.org; Wed, 24 Sep 2025 06:38:06 +0000 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1v1J8c-002ZSx-26 for pgsql-hackers@postgresql.org; Wed, 24 Sep 2025 06:38:06 +0000 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-25669596955so57497205ad.0 for ; Tue, 23 Sep 2025 23:38:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1758695881; x=1759300681; 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=BTEGr3tEYx8xDS5PCUQ4wJaejG5WcF7VdjBMEqgt52Q=; b=BM9KjOrK07DncfAYlSgioGYYw+7U154tL2EYmw13lll/BxoKL2LR/WkCfHj/2ZEMJZ BdQSuAXS6/cIx0NBbWAINawJ7rxjnr9szzwN1GvA0ahvtKEqzHhjufffbDYSewBZpceC mlAui6yna+t9R3aWen5KDRRZxtwTso10Xs49jRNGZBIzF1gXjpp4ZxtR3BvHvaGlSPp5 NYcLl6jSVz54IH38eCf5aVAoy6AYJAQlI+O1+4RE0NWyM26f1NntPyxOkkgVciA/22/E 30eQSn9yx/CrpXDQj9M5Q6MwI+UcfBTFoYzNpiB91FcYdb7cd2O8lrPcBUUmZJHsjfVZ wdUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758695881; x=1759300681; 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=BTEGr3tEYx8xDS5PCUQ4wJaejG5WcF7VdjBMEqgt52Q=; b=m0IWZDCO7+Iw7Wd1QX3oNK6dbKzsRJQeAwrGpCV1jaoXlpjtv718IwSP29bO/0YeEq /tiGkn1l9mPKN3ohAjAfa1r0y9f8AwO7c6X0gtP82kne3pV7dSQy/R3e9t8lVyOyg6S0 WQsBQZMyFxQhDvNQKs/+5CZ2/KVz62vew6btBqvFGFiyg54mrJmHgwxtXmKecFnhfUvr 6ii8Z0GVTKdiONGRXKdYoZaqxK5Phwd/MqKXMHxHOwy1sfnWkK1Dt9ZQowxWMdZsNWM9 rJiPeAyeV5aO58dhfsaMObhwzZLqi66KmH22KF0uihKOZJiSqIo6xtVD+E7rxr7eJta1 lk8w== X-Gm-Message-State: AOJu0Yx2vnuMq2bNWQFLrlZ23KpsA/L4sY8aRG/AxLDFB7+TF6v7pcCo 90ciUPkvw1+fs/DrMJkBPxhtYt9gF+FaqLACj9ayTuhQIa7wat6CWw34IWGn3j5X5Hh4CQ== X-Gm-Gg: ASbGnctIuxfFk+B7/b/jDYScU2/8Xa1hEXDfvs9w9NN+vuvGqUU8gP7BSJScKciMLYw rE6OJ2298yfDi/zssn/h2AQuGjlRMgAF0pPhrgtmsPJXdCBu6Sfbb4OoPe5dO2salJ7/qVd/RXv 5JFXBm2lPhZQNIBWMhWNiLciho5XU2lQchYUEGtzl5leFDZHiVQh4DHqdEMhzV6hnbsdcq6JNYC DDkBqHsHm7zrzR8crctkQreEwNRtujRQNHof3o5HZ7BaveNq0RlpkrYlqDe/5MOv3cidtoDBB2d VKD6YbTM8j50QFID9v/KTugEL2BfhhrQ2ZR11fWdTOHJFIM4tvdGIrneHOqzxqBcMW7sHkr/tsq BSYmzcvQQyoEXm7riSkgar6tWOvWL7NIc X-Google-Smtp-Source: AGHT+IFe5OUxal2EO9B/tjO4OVx+1ShboOlIFkZ94C+CiDkaM2haB5zZfBlbFg2h64W4XPp4FSsf4g== X-Received: by 2002:a17:902:c94d:b0:268:1623:f8ce with SMTP id d9443c01a7336-27cc1572011mr62432105ad.10.1758695880763; Tue, 23 Sep 2025 23:38:00 -0700 (PDT) Received: from smtpclient.apple ([142.171.105.12]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2699363989fsm173882515ad.92.2025.09.23.23.37.56 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Sep 2025 23:38:00 -0700 (PDT) From: Chao Li Message-Id: Content-Type: multipart/alternative; boundary="Apple-Mail=_F4D838B2-C2C3-4E20-A80D-853BF35CEA2F" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.700.81\)) Subject: Re: SQL:2023 JSON simplified accessor support Date: Wed, 24 Sep 2025 14:37:43 +0800 In-Reply-To: Cc: PostgreSQL Hackers , Nikita Glukhov , jian he , Nikita Malakhov , Vik Fearing , Mark Dilger , Matheus Alcantara , Peter Eisentraut , Andrew Dunstan , "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> <052E941B-C905-448F-AE3A-753C12AAC938@gmail.com> <8CB9A1EC-2D14-44FF-A600-6669353A14C2@gmail.com> <826F61C4-AE01-4070-8F78-CEE8781EACEB@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=_F4D838B2-C2C3-4E20-A80D-853BF35CEA2F Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Sep 24, 2025, at 09:05, Alexandra Wang = wrote: >=20 > This is the expected behavior for array subscripting, and my patch > doesn't change that. I don't think this is a problem. With or without > my patch, you can avoid the ERROR by adding parentheses: >=20 > test=3D# select ((p).meta[1])['a'] from people; meta ------ 30 (1 row) >=20 Okay, make sense. >> 2 - 0002 >> ``` >> + /* Collect leading A_Indices subscripts */ >> + foreach(lc, indirection) >> + { >> + Node *n =3D lfirst(lc); >> + >> + if (IsA(n, A_Indices)) >> + { >> + A_Indices *ai =3D (A_Indices *) n; >> + >> + subscriptlist =3D lappend(subscriptlist, = n); >> + if (ai->is_slice) >> + isSlice =3D true; >> + } >> + else >> + break; >> ``` >>=20 >> We can break after =E2=80=9CisSlice=3Dtrue=E2=80=9D. >=20 > Why? We still want to get the whole prefix list of A_Indices.=20 Ah, I just realized the main goal of the foreach loop is to build a new = =E2=80=9Csubscrptlist=E2=80=9D. In that case, it should not break. Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/ --Apple-Mail=_F4D838B2-C2C3-4E20-A80D-853BF35CEA2F Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

On Sep 24, 2025, at 09:05, Alexandra Wang = <alexandra.wang.oss@gmail.com> wrote:

This is the expected behavior for array = subscripting, and my patch
doesn't change that. I don't think this is = a problem. With or without
my patch, you can avoid the ERROR by = adding parentheses:

test=3D# select = ((p).meta[1])['a'] from people; meta ------ 30 (1 = row)

Okay, make sense.


2 - 0002
```
+ /* Collect = leading A_Indices subscripts */
+ foreach(lc, indirection)
+ = {
+ = Node    *n =3D = lfirst(lc);
+
+ if (IsA(n, = A_Indices))
+ = {
+ = A_Indices  *ai =3D (A_Indices *) = n;
+
+ = subscriptlist =3D lappend(subscriptlist, = n);
+ = if (ai->is_slice)
+ isSlice =3D = true;
+ = }
+ = else
+ = break;
```

We = can break after = =E2=80=9CisSlice=3Dtrue=E2=80=9D.

Why? We still want to get the whole prefix list of = A_Indices. 

A= h, I just realized the main goal of the foreach loop is to build a new = =E2=80=9Csubscrptlist=E2=80=9D. In that case, it should not = break.

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




= --Apple-Mail=_F4D838B2-C2C3-4E20-A80D-853BF35CEA2F--