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 1wEYdo-0048r2-1d for pgsql-hackers@arkaria.postgresql.org; Sun, 19 Apr 2026 20:21:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wEYdm-00GEPm-2x for pgsql-hackers@arkaria.postgresql.org; Sun, 19 Apr 2026 20:21:14 +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.96) (envelope-from <9erthalion6@gmail.com>) id 1wEYdm-00GEPe-22 for pgsql-hackers@lists.postgresql.org; Sun, 19 Apr 2026 20:21:14 +0000 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from <9erthalion6@gmail.com>) id 1wEYdk-000000021OI-2ALV for pgsql-hackers@lists.postgresql.org; Sun, 19 Apr 2026 20:21:14 +0000 Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-b9c745e18a0so399500266b.1 for ; Sun, 19 Apr 2026 13:21:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776630071; x=1777234871; darn=lists.postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=UlGxmhTYJ2OF58Fs926CrhVM4+dxhiBvDfBUP7DymFs=; b=dKjj8G+P7tPeJWniLm9Lxq93B3E3wSOTXYJBNh+Y5J4SYblAxlWPVYI48pNL5bYR5q DN/NFI7NfLRFZ1Wdi+473nw/5jj5OBdXrFo78ZZZJ37bn5PT2PGXvDCxE23MFMFmWaJx 7W2uJK7A56bCz3nU4W3OCr0wISoidP95/w2XSh0wDpcfhgLVlDaf/ch4Rkja6d93G54s eJ/o2Fr4wG5579/r7ZA5rrNajoCWQtWjQiCbAW5cC42q3EzZ1Rm3wUr8q/Hjro3gmnO5 NNRV2kdNBnvnP9Y8nH5J2/7eARmPHpeN2GnzNV+LNVoFYCYQE2kVGPLQqexNJ4lQUUaK P2Fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776630071; x=1777234871; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UlGxmhTYJ2OF58Fs926CrhVM4+dxhiBvDfBUP7DymFs=; b=ZGFUj3nm+Qtdf9x4b1ck2PQtniL0milxiNFKRFnccn/aqX1doERqk3LNkvOmP1/WUn 2E1QWmiSTPOaPXbAE0VZMNkb0+0Ch427S5nWvvQNbERFbSZglzsNStYDKLjVxPeNIYpq eCgpzQxRhk7PDXO7QK5iNcojUyxtvvPhnwsUwt1C6PHBcvx3tnH2ATUCScX8XV8SsuJb G68Hn1/wl0l+6PScYcaa+e2kkcOREXWtHQDOQ+fq+SycBRw1ByaOQ2y6YUVE/xo9zjLc mY+ohV+Ho9c8Sz5QC/ZAMWc2slH0Ue0GfMhZY3iXYfgYQ5jA4tbaCnh1N17Ccjb8of36 bH/A== X-Gm-Message-State: AOJu0YyPJkMe9PLo8n+DrSi8tYSvGbfZE6mu8a7+eApr6jsDi0aYNqBj 7vOqo26Amf/nCHahdDRZjh7jC+GGzTZLsJfPummvt16JKVpaC7GuT2NM X-Gm-Gg: AeBDiesJ7I83BaF3Ibh6huFV20AWWQwJdjLAYRDaH6pTFNnEQkWwePRnC/zRmf1kBxJ 8TKlxRz6zeyvwD85VTUrbIkSabU0dSPt18e1E2kqNvshvhECvmkFJ4EX1rbZKKlzFX59vrhAgcC b5DzeG0NrUe7OU3HBKTWvSDFSj4rknDx52kGdV0UMarQBqS4LtVi1hW4OTfMwBWGEg+9gcoTsA9 YewrsKrSU20+28Vw40iGG0MgYRYAif3qcpxvbYtGA+6I8M5/+CWSRF+NraiS9zKSY/Brqim2slf wBphPdWERIqK00NEKQVtU22JqCs5Jiy83S2hMijUGqfJRZr9Sxoa+4+2SBTO6vib6mOdUBxobHt fq7oNQjeMZV8sh7aacvwLppmlVdvsILLu1GQmaqqPGXNOlK6ZzIuOganTQVgp3rHRgZVSWA1Lc3 x/iCSHwSvJYvkFS5e20OGJHRzva/zOZJwfdq5IsaMgvhFOH5JtHFb6FdCwTsFeCIiMnl7MxUzCz 8Jvo/UilQAKMZbtYgGWmJJ1yjYcKVODC+wy0rMFXpbe3fTJ X-Received: by 2002:a17:906:d54f:b0:b9d:dc1d:7660 with SMTP id a640c23a62f3a-ba4214070a7mr482791166b.7.1776630070595; Sun, 19 Apr 2026 13:21:10 -0700 (PDT) Received: from ddolgov-thinkpadt14sgen1.rmtde.csb (dslb-084-056-106-044.084.056.pools.vodafone-ip.de. [84.56.106.44]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ba45121042esm276672366b.13.2026.04.19.13.21.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Apr 2026 13:21:09 -0700 (PDT) Date: Sun, 19 Apr 2026 22:21:07 +0200 From: Dmitry Dolgov <9erthalion6@gmail.com> To: SATYANARAYANA NARLAPURAM Cc: PostgreSQL Hackers , florents.tselai@gmail.com, david@justatheory.com Subject: Re: BUG: jsonpath .split_part() bypasses lax-mode error suppression Message-ID: <2cqv3uotlvjsjkkjganonpbghopgjwqqrwwylujmqu3qca7asn@smj4ghtqigpi> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Sat, Apr 18, 2026 at 09:31:03AM -0700, SATYANARAYANA NARLAPURAM wrote: > Hi hackers, > > The jsonpath string method .split_part() bypasses lax-mode error > suppression. > This is because executeStringInternalMethod() uses > DirectFunctionCall1(numeric_int4, ...) > to convert the field number from numeric to int4. This throws > ereport(ERROR) directly, > bypassing the jspThrowErrors(cxt) / RETURN_ERROR mechanism that other > methods > like .double() use correctly. > > Reproduction: > -- These should return NULL in lax mode, but throw hard ERRORs: > SELECT '"hello-world"'::jsonb @? '$.split_part("-", 99999999999)'; > SELECT '"hello-world"'::jsonb @? '$.split_part("-", 0)'; > ERROR: integer out of range > ERROR: field position must not be zero I don't have a SQL standard at hands, it might be worth checking what SQL/JSON says about such situations. But at least from the definition of lax mode, given in the documentation, current behavior seems to be correct: lax (default) — the path engine implicitly adapts the queried data to the specified path. Any structural errors that cannot be fixed as described below are suppressed, producing no match. I.e. only structural errors are suppressed, where a structural error defined as: An attempt to access a non-existent member of an object or element of an array is defined as a structural error. In this case what we have is an error, which happens due to an incorrect function argument valye (the second argument of split_part, either out of integer bound, or zero for 1 based field counting). It has nothing to do with the jsonb document, and hence doesn't fall into "structural errors" category.