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 1ur7Zd-000zaf-9b for pgsql-hackers@arkaria.postgresql.org; Wed, 27 Aug 2025 04:15:50 +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 1ur7Za-00CUPv-9u for pgsql-hackers@arkaria.postgresql.org; Wed, 27 Aug 2025 04:15:46 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ur7ZZ-00CUPn-UA for pgsql-hackers@lists.postgresql.org; Wed, 27 Aug 2025 04:15:46 +0000 Received: from mail-ua1-x92c.google.com ([2607:f8b0:4864:20::92c]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1ur7ZY-001xI9-0P for pgsql-hackers@postgresql.org; Wed, 27 Aug 2025 04:15:45 +0000 Received: by mail-ua1-x92c.google.com with SMTP id a1e0cc1a2514c-89242f1cee0so2467379241.1 for ; Tue, 26 Aug 2025 21:15:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1756268143; x=1756872943; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=bkFCKe9BfXMiKq54aSOLMQJgc4jbzMV7DyRrHVMQtsQ=; b=c2B3j9g6S1lSkdCtjWxqjoyrWjZlG0biSYF+ZgIr3rMco6VNvsMwwB3zLMV9IM09Ml 3W/61JxxBMZZeYh33EczYV1ODlE5uuwQbTCwaH1MvjNQqHvtJfbGEEDyiaPfskn1xnPX PEMDbikZOftyhaVKQrwmlz9RLmDz2Yd+R7c7kkLb10yIwAuiYfK28YZcY0t0CJ5nC0TK wiXvDYfYeROIFTZCNO3bUMJRVpQfYKbAXeefgfsSdv6zCwdFwXBkVNgrAB0Il+PtAvAb DFDq3poLviVARK/o/tZc96B1Xiaa/zxp4Tn7jBLzJCpP+WNi7wyW/+L+uM9fYxjUsmAj hr2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756268143; x=1756872943; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bkFCKe9BfXMiKq54aSOLMQJgc4jbzMV7DyRrHVMQtsQ=; b=jXtYxU1EDM9SdluepLNwzFMCipLjqu5yciGejO2oTv1enwuJmF+1EU0LG9zpnCuOiu edUxRwigbMOxWGL6K6w12gF/EN5zg5yP3wMbedjqeoRvjTBMwyY0u/Nd1nJgecyRmcAw fyyJMrsXWcdapFn4gakeLttOkYUjTH3Ev4whHHVUaYeklSq7O2462zC0vNelUrQ6VqVO JTrS5/s5vl6DlYypvqjwNyAQA95sYnJLlId14WLDVCS0VUNBa2XgFKChdy3C5EmSSfMP IT2tY8YQIGysuh7L6M+0V3t4tcWFttIo0Bctk8TREbpR1QKz26Sn7SsCiia5XiarPSOa 5Q6A== X-Forwarded-Encrypted: i=1; AJvYcCWUFqVMpnU/JTELs75REY5y4icAj8QJkHggpj41mYBk+0gA5RKJXNo5DguSvBNc7rAfuj67WwZOIXy/AaGo@postgresql.org X-Gm-Message-State: AOJu0YymBo4Rqy+/XxUi3easEwHk6fsEhcEUY5cVg65ea98PIFoclI76 EPHOezz9HBIKGiPbeZBQr+lyoFhLPyk7OY5JTOO2gaGO2O+uaeNH0OjmmanbYYyg3zUKCARkCxM XcMjfJHFw9ORXRMV0pgPSZTEoC313yGo= X-Gm-Gg: ASbGncuM7emE9OJgpWtF13faiIp5nTvQKdgxuh41HFZIDLtAjlTM0Lk+VJFDlg6tERZ 20KEBaYkWzEjQqDE0Ym5uk6DkPwdB6ngKM1h9T0ui4Nq8Ke6dEUXPJ307E2OdllQ2dRWOws6jru lKvsTiPyjxgxNeohGjwmPRE7GCn0youTUqQwk518fQ2dNL6p9YgQ5g37IKOj/VJosPx9gHKxWy7 JnwIv98iazRbxOmHU2x1ymnmeIk5Yok++x0SRKPDqU1pbR8hO/GR2PoFjTBQFO2k4vKKEk= X-Google-Smtp-Source: AGHT+IGQw66xX1BRNMkGEzjdp8gCC7Tn64dN/cOkMO+UzI4C8DXjYeEEjwnyVrQ+NgxdJRM4/ejPt1OQhKuZ4SAFvys= X-Received: by 2002:a05:6102:4b88:b0:519:534a:6c44 with SMTP id ada2fe7eead31-51d0f702360mr6050165137.30.1756268143191; Tue, 26 Aug 2025 21:15:43 -0700 (PDT) MIME-Version: 1.0 References: <21fa36b4-6d56-4556-b524-9e3955b922c8@eisentraut.org> In-Reply-To: From: jian he Date: Wed, 27 Aug 2025 12:15:06 +0800 X-Gm-Features: Ac12FXyvg-4xoshKNyFvRmfYVkY_u7_oSp9aHgKrsYSVkeNSr3keIrfsgWwUdMY Message-ID: Subject: Re: SQL:2023 JSON simplified accessor support To: Alexandra Wang Cc: Nikita Malakhov , Vik Fearing , Mark Dilger , Matheus Alcantara , Peter Eisentraut , Andrew Dunstan , Nikita Glukhov , PostgreSQL Hackers , "David E. Wheeler" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Aug 26, 2025 at 11:53=E2=80=AFAM Alexandra Wang wrote: > > Hi Jian, > > I=E2=80=99ve attached v14, which includes only indentation and comment ch= anges > 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 e= xprs 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 populate= s + * the following fields of the given SubscriptingRef: + * - refjsonbpath: the generated JsonPath + * - refupperindexpr: upper index expressions (object keys or array indexe= s) + * - 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").