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.96) (envelope-from ) id 1vpe4U-00Cg7K-0Q for pgsql-hackers@arkaria.postgresql.org; Tue, 10 Feb 2026 03:05:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vpe4R-00DcNW-0a for pgsql-hackers@arkaria.postgresql.org; Tue, 10 Feb 2026 03:05:47 +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.96) (envelope-from ) id 1vpe4Q-00DcN9-2b for pgsql-hackers@lists.postgresql.org; Tue, 10 Feb 2026 03:05:46 +0000 Received: from mail-ua1-x935.google.com ([2607:f8b0:4864:20::935]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vpe4O-00000001My6-2uBs for pgsql-hackers@lists.postgresql.org; Tue, 10 Feb 2026 03:05:45 +0000 Received: by mail-ua1-x935.google.com with SMTP id a1e0cc1a2514c-948bfb6b6bcso1342903241.2 for ; Mon, 09 Feb 2026 19:05:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1770692744; cv=none; d=google.com; s=arc-20240605; b=dyh/gmtRantXfsHw4FdEct5zz5xVmJ2GSSE8pJx+ro/a3BpHwMo47cmhYKxTiAFLrX GOLakBPp4UbHOcKJyQvwqvK7boMWYB8CjRLMWtn2hANVWiZzUz0gUFu4PbYWeop0IDu7 rBZQaUCtYZ3qAf3rQlYM3DKwEgyUkN0iAXT/4pWDVLebYnCoSlZNIqUu8nPJ8z0akZPc aYqm8TFW9O/cZj//qJ6oXlggoDcHVtd3lroABBkSvi0rxmcLaMa7TdqZA7KSOIy+N1SE Uu5YNvBekB2X/WgY7No2+1JzEfZes0Sq5U8uC9zbIqkuhyia78KIzM87X3zVQL/T41Rh AyoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Ip9bt3wkqE585CtM6GXxBD/gGsQ+cOOzVsM6NEPjGQo=; fh=d6uxBmIkvpR8+/aZgcjobQBGPqtVyBIWcjIUjp2PQTY=; b=RFgch+7xsrJWcQej2siw9d5UjjCxgLJcFgtFokP43Kt/3FwInO7Sei0Tf2lNd8lqxI SOK7xBgNhcXfvN0o5FglW84lqclr0WePIpoEldTPoeT4j+GFZ0a9ARF38PqRahrVPx4I c+aOKY4uF+2iYHgV5IduuY4sIvySmd780aDnwuVxmHnmM+B1qQGdpV8SHKVUku85IXhi pufDoufZaozHZV2FGzFs4dMdbvdy4ko2WpfhXvt14NQ5vTyob+7XKdA0qbWDyR0Djybk zIAzRaglgw4y9ofgz6LhCxlHFaQ9qkTWmsNdlKESxTkqXOqgrDusIlMJyL8H2d0MTvKZ /mXA==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770692744; x=1771297544; darn=lists.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=Ip9bt3wkqE585CtM6GXxBD/gGsQ+cOOzVsM6NEPjGQo=; b=IuorgVy/n4Jh6EV87KwD3MJsMXOpdghHsvX49y3zsQTlNiuSuLU2c/WuCSRAod082q gHkrxrM1HmPapnw89OoLpLmx9hKgAPicA06AKYwS/q2QfIvdFwLogoWpaoLT0S1f9Jhp ecI1a5ZXds3BN+g6C+8oP59jdPSWEdPLIsIvO4JWB85BsksCGrwMMsGeKcLElv8stEL1 Q+FMde3fZchH/SKR1whQQlXFjA7t7X8jPoga+VHNM4mz/WV1uSAiombuRUgLkwBM2y7L t5UA7UmX7kMLkBdKunyq9nuwa5rxl26374Xd7N5j+0QDCA4jtrtY3R0utjXnX7xIhVf2 HTPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770692744; x=1771297544; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Ip9bt3wkqE585CtM6GXxBD/gGsQ+cOOzVsM6NEPjGQo=; b=GhBoPQTrsKuoskVeRfVoKAFRtEsNilasA5YFVe0WWNyZRfRzQz4S9OQ4/9zaLvX7KG iCjXGFnmlIjmmav79mJO8gSqCjo+0fYWJMo9KUIoDWy8wwA/goo+ePLW3U8Z0qwkIxeh FKDobVaFiCJoNtLA7B+EBDswTWKS0cXdKwFCJiTXx/nRA76ZCrpyN00vKr51cdV/Sr62 9HLG1ph2X4rIIKPilNrzmzl51gI4PKKq0Q0EjuTDC3wkYDYknXOdROX5Qjgwt3MAxKlf g/gzCwwZrjS6vjzWyR/3GP61x6uuoqA693CO3jAP6+cGc2gssENvoFt6qd9PRpoIN2gS 2tqQ== X-Forwarded-Encrypted: i=1; AJvYcCWexyC1MAbgvAPDxyl+/pNIZv3O4HgRO3rivGwCG7bZwIdQl0uO0F4IopHuGi+PZLN7rII9U9FykW84We/C@lists.postgresql.org X-Gm-Message-State: AOJu0YzaFofAu4NoMIt3v2cNqEvO2lIwkC8KYQvLE93JwadhqdF5h3bl I4tFJw/fxS0M5Bnko8KHWKbKxqjOnkMuHbXcqdqJBUFevoxSpu58LSZG4Yexw0v79NILnIutcnm KGxi3JF+MeJPdhaQRB4tligdDk5MbaVQ= X-Gm-Gg: AZuq6aLyhuiHxlRwIdX0rTAqkkCoILF9Gx2FChKX7wmoRO+0vUvBvUrRjcm2FHSW3ES GTKY+0LcPBIlKCUDp00WwiCc1WqbxcLsjlaT2z6OFiM3FgxPY5dHPUvph990wkh9uz6fN9vrEpB khKXV+Q4QciQ+l95otr626ajdOHDexAXeBJrikC6KZSrA0I718YoQisexX1F8d7SaD95AsTG2vt HG2HgyLCBlMJ271mjpEfbxSFSDM1TdiFDJvLWwULhOMVDGs+yfKimF+IgLKumEVbdR7MqFEDLRL tptm5vzuW4ovEnZs0odBw5Zhu8twOaZEoZEldWCMvA6dh4iaF3ernFdtR+scGnyrh7vJFOqNF55 2hcjQYHi6VsaTQtrwBhnwD1jIiU4IfvH1M57CyFStNcjggQjEyw4HF/fj4e+QQ7NG1Gdk0R/ZHU ZV4e8PF6dIVUyWYeMTlwQdeQ== X-Received: by 2002:a05:6102:162b:b0:5f7:293f:c3ae with SMTP id ada2fe7eead31-5fc48e6466dmr172480137.34.1770692743846; Mon, 09 Feb 2026 19:05:43 -0800 (PST) MIME-Version: 1.0 References: <2cc680c1-12a9-4152-ad31-a1385a9d6912@dunslane.net> In-Reply-To: From: jian he Date: Tue, 10 Feb 2026 11:05:07 +0800 X-Gm-Features: AZwV_Qj4iukHwPPUXcp1-7z3G3yq26eXWMWSLzGHXYDWwMMm5ylqGSTdzmN524o Message-ID: Subject: Re: jsonb subscripting vs SQL/JSON array accessor semantics (SQL:2023) To: Alexandra Wang Cc: Andrew Dunstan , PostgreSQL Hackers , Peter Eisentraut , Jelte Fennema-Nio , pavel.stehule@gmail.com 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, Feb 10, 2026 at 5:16=E2=80=AFAM Alexandra Wang wrote: > > The attached patches implement exactly this: > > 0001: Add numeric type support with truncation Subject: [PATCH v1 1/2] Support numeric type for jsonb subscripting Previously, using a numeric value as a jsonb subscript would error. Now numeric subscripts are accepted and truncated toward zero to produce an integer index. This matches the semantics of array access in json_query() per the SQL/JSON standard. Examples: SELECT ('["a","b","c"]'::jsonb)[1.7]; -- returns "b" (truncates to 1) SELECT ('["a","b","c"]'::jsonb)[-1.7]; -- returns "c" (truncates to first thing come to my mind would be special numeric value +inf, -inf, NaN SELECT ('{"NaN":"b"}'::jsonb)['inf'::numeric]; ERROR: cannot convert infinity to integer SELECT ('{"NaN":"b"}'::jsonb)['NaN'::numeric]; ERROR: cannot convert NaN to integer Is the above what we expected, or should just return NULL? Anyway, obviously we need to test these special numeric values. +select ('[1, "2", null]'::jsonb)[1.5::float8]; -- errors +ERROR: subscript type double precision is not supported +LINE 1: select ('[1, "2", null]'::jsonb)[1.5::float8]; + ^ +HINT: jsonb subscript must be coercible to either numeric or text. This errhint message appears to be incorrect? given that 1.5::float8 is coercible to numeric. -- jian https://www.enterprisedb.com/