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 1uU3jM-00EpM9-Kg for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Jun 2025 13:30:32 +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 1uU3jK-00CJWY-Jc for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Jun 2025 13:30:31 +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 1uU3jK-00CJWQ-AG for pgsql-hackers@lists.postgresql.org; Tue, 24 Jun 2025 13:30:30 +0000 Received: from mail-vs1-xe34.google.com ([2607:f8b0:4864:20::e34]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uU3jI-003jaF-2j for pgsql-hackers@postgresql.org; Tue, 24 Jun 2025 13:30:29 +0000 Received: by mail-vs1-xe34.google.com with SMTP id ada2fe7eead31-4e7f7d0f7baso3499553137.0 for ; Tue, 24 Jun 2025 06:30:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750771828; x=1751376628; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=cclOeb6vEx4jC5EBkr+C8VoBVxKYmpqy15Wllj5OBkE=; b=awu7opeancfwf9rFXK8+alrBQUajiA/XiTE/Rf3ByRAUz2R9/rEo8NoobXTVEqUg2S 9/aPZsXqlKTMua257+d0EksDOhva/lBd3eTTY/c9AnwLw/ivjJKbcpsbmE8o3i+8NpfA 2a4i4cJMlki5dhiG4q0xnkp9w93S7cZ9TiEDUNjcG0X4ThoC0Kmk+ys+AnjYhPrLNATJ 47zEDPZDH042+c2DE1/ygpbZLT+RdTtrryBcV8PyRC4JG/8T2E89BqZNpfXESbHwL7bt Np/XKj3tthKhUVP2YdVAz5ntZfWnJ/NT10Utcx/CV6ssxMcPXu6ei3qm3ahEoRW62s+/ Grdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750771828; x=1751376628; h=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=cclOeb6vEx4jC5EBkr+C8VoBVxKYmpqy15Wllj5OBkE=; b=JenKQcTRnG1vmSkyheaQ4r/3K8xmBkCkE2vyTNeVShTA3NfbSeCXud30/cZe3MWDar iqkNHeAlBphCmLDWs7DeI8JS81J6nZrFDu8Kg1KCkpKxCx01OZLXfTYOaUEfA5aOjzN/ 4oYeHo+uX4kuLjbUF5+DDF1XrbPqD4GgLnp0FMbaOkDKArHJVSQKZPtgci/Vafi4ZUy8 xLmUmgCK0YW96bcRpVz6oXzbS4ce9r6nFECxH5JtVOlHUXdyYQJgRjWHdMfskH326fyq QPzVqwpMPjzFwWbLBOxacgDVPPtK9bNS8JZNj269uCLAFMc4Q+LeCOJTeKfKt7TW2TzS 1JrA== X-Forwarded-Encrypted: i=1; AJvYcCXMMYbgfLsVtu+eA7oS1bSgAJyejyOUQToPncohJBrLL5qNgSNw4UiOoOACSUEOV3Dd3Qr5/vIK8FoWZswt@postgresql.org X-Gm-Message-State: AOJu0Yzg/vMHKXRYqxEOX8niPdtCaJofOHkfwSAhscLV/9GXZ1kPRwGk Z5Epl6I7BUjAe6mdDSBwDMaKK4yMtYq41R7zFb6dE9d3FjU9N34aAA4MwMi/G3p/XdVmVguQ5Gw g+omVDyuUy3Q9ZiiK5mcJk1bqV0SXkZs= X-Gm-Gg: ASbGncsvNhAz85dwPqI7AtpbwVYeQQbubu5F/wmoydNI7KwktDMt2YKvjzbxzLwkl+D mj+zrSvawrfD6BqJlvMKFoqdh6Bf9EsPQ1uQnXGe3y4+2z7HC1Ume5Y+7THE4STK238oMXagkNX A89yaLhVnqQi/dXHzhi9cN/mUD1P1bCkcxzaaGzNLyFtHMk42nAWGQmaDQ1nHUPcE5r6/dtD97R A== X-Google-Smtp-Source: AGHT+IFpxkJ+wyDQYfP/VPOOd96/Fsizkoh14ka67N9YxCqBIhffMcOyY2HjhF6P3t0C7aL7AtZduY+ESQibFg5YMrI= X-Received: by 2002:a05:6102:3ece:b0:4e1:5132:67c9 with SMTP id ada2fe7eead31-4eb52963e7amr1890561137.0.1750771827711; Tue, 24 Jun 2025 06:30:27 -0700 (PDT) MIME-Version: 1.0 References: <21fa36b4-6d56-4556-b524-9e3955b922c8@eisentraut.org> In-Reply-To: From: jian he Date: Tue, 24 Jun 2025 21:29:51 +0800 X-Gm-Features: Ac12FXy4hhqaGiBNwDmTmMF2xOdt5jFvzTAiVOgmHaj3Cl4llFGvcoz5pEqXK2s 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" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk hi. I have applied for 0001 to 0006. static void jsonb_subscript_transform(SubscriptingRef *sbsref, List **indirection, ParseState *pstate, bool isSlice, bool isAssignment) { List *upperIndexpr = NIL; ListCell *idx; sbsref->refrestype = JSONBOID; sbsref->reftypmod = -1; if (jsonb_check_jsonpath_needed(*indirection)) { sbsref->refjsonbpath = jsonb_subscript_make_jsonpath(pstate, indirection, &sbsref->refupperindexpr, &sbsref->reflowerindexpr); return; } foreach(idx, *indirection) { Node *i = lfirst(idx); A_Indices *ai; Node *subExpr; Assert(IsA(i, A_Indices)); ai = castNode(A_Indices, i); if (isSlice) { Node *expr = ai->uidx ? ai->uidx : ai->lidx; ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), errmsg("jsonb subscript does not support slices"), parser_errposition(pstate, exprLocation(expr)))); } I am confused by the above error handling: errmsg("jsonb subscript does not support slices"). we can do select (jsonb '[1,2,3]')[0:1]; or SELECT (jb).a[2:3].b FROM test_jsonb_dot_notation; this is by definition, "slices"? Anyway, I doubt this error handling will ever be reachable. jsonb_check_jsonpath_needed checks whether the indirection contains is_slice, but jsonb_subscript_transform already takes isSlice as an argument. Maybe we can refactor it somehow. T_String is a primitive node type with no subnodes. typedef struct String { pg_node_attr(special_read_write) NodeTag type; char *sval; } String; then in src/backend/nodes/nodeFuncs.c: if (expr && !IsA(expr, String) && WALK(expr)) return true; we can change it to if (WALK(expr)) return true; but in function expression_tree_walker_impl we have to change it as case T_MergeSupportFunc: case T_String: /* primitive node types with no expression subnodes */ break;