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 1uaetw-0089Xj-4d for pgsql-hackers@arkaria.postgresql.org; Sat, 12 Jul 2025 18:24:44 +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 1uaett-00AJ8r-1U for pgsql-hackers@arkaria.postgresql.org; Sat, 12 Jul 2025 18:24:41 +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 1uaets-00AJ8j-8l for pgsql-hackers@lists.postgresql.org; Sat, 12 Jul 2025 18:24:41 +0000 Received: from fhigh-a1-smtp.messagingengine.com ([103.168.172.152]) by makus.postgresql.org with smtp (Exim 4.96) (envelope-from ) id 1uaetq-006xTm-1D for pgsql-hackers@lists.postgresql.org; Sat, 12 Jul 2025 18:24:39 +0000 Received: from phl-compute-06.internal (phl-compute-06.phl.internal [10.202.2.46]) by mailfhigh.phl.internal (Postfix) with ESMTP id 6E1E01400111; Sat, 12 Jul 2025 14:24:37 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Sat, 12 Jul 2025 14:24:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=justatheory.com; h=cc:cc:content-type:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm2; t=1752344677; x= 1752431077; bh=Bozz6kGSqo1+UHhs11RDA88qTGiYcAGWz5D0fCxcEeU=; b=I 3R9ljGSjNvraFwTP3igsUfCX97GnXxKtpG2baEr5J+0QpUXpIUcDnXkSFAoRZtA/ HJWWmq+6sVgikuCoRkO+llduiXoKyn6DQSx6zDLUlTDBSQSV1lWC2pEDUX0BBmXp 2ApfypdbDjOuy/Bn7COhmwQHt/4f5rJZmgKL0jPzEFDH+A4yk+RIMxCiYOFmLa7q wA7k17h61uUA6yQM4QTVqgrWAUhv2OatccKlBXtRZBPbbUA45gcwDnoQuDthk+Qy dqWoNH8sa3sXk4PaS8qX2h5dOngQDh6HhDA/27503F63NObptNu8eoyOsYACem/B 9iPo2myuHVq/FodCCiReA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1752344677; x=1752431077; bh=Bozz6kGSqo1+UHhs11RDA88qTGiYcAGWz5D 0fCxcEeU=; b=b6X4v+pDUtgWhBVbi9+Bu/5bm+/1Y2FOrKFRdf8mRi6lbqN3PUh RMiiABWiAFO9QbH4HGrfIeETam2MpRrrsrg2ikzR6yoVM7s90cbbaVi9WLVYEEH2 XGbzvaqL3lpzf4crz70gY7sxaYctAv+YugFuyDJ9XBN8LOAL18/NYTIiw2huBswo sVz1rBMnC6FkvUZ1wc+2AMTeIMUQSAvMwRPZYSD+YKxGkOEKXWY+TFYOPfYVROP9 7afAUU1h2Qx6R2SwzpSZLrQbMoQoguiueBitZO+gkWItBToTc0OO+XwtSXhUabyk DQ73cNan2JTS+/HhnFP9z31Fw2v+PPy/Exw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdegieeludcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpegtggfuhfgjffevkfhfvffosehgtdhmrehhtddvnecuhfhrohhmpedfffgrvhhiugcu gfdrucghhhgvvghlvghrfdcuoegurghvihgusehjuhhsthgrthhhvghorhihrdgtohhmqe enucggtffrrghtthgvrhhnpeekffdvfeekkeelkeevgeeghfduieehleehtefhieevvdff keevteeuteejfeevieenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpegurghvihgusehjuhhsthgrthhhvghorhihrdgtohhmpdhnsggprhgtphht thhopeejpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehflhhorhgvnhhtshdrth hsvghlrghisehgmhgrihhlrdgtohhmpdhrtghpthhtohepthhglhesshhsshdrphhghhdr phgrrdhushdprhgtphhtthhopehpvghtvghrsegvihhsvghnthhrrghuthdrohhrghdprh gtphhtthhopehrohgsvghrthhmhhgrrghssehgmhgrihhlrdgtohhmpdhrtghpthhtohep rggvkhhorhhothhkohhvsehgmhgrihhlrdgtohhmpdhrtghpthhtohepphhgshhqlhdqhh grtghkvghrsheslhhishhtshdrphhoshhtghhrvghsqhhlrdhorhhgpdhrtghpthhtohep rghnughrvgifseguuhhnshhlrghnvgdrnhgvth X-ME-Proxy: Feedback-ID: i7c334307:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 12 Jul 2025 14:24:36 -0400 (EDT) Content-Type: multipart/signed; boundary="Apple-Mail=_FEA8B938-5322-432E-B640-D007472BECCA"; protocol="application/pgp-signature"; micalg=pgp-sha256 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.600.51.1.1\)) Subject: Re: PATCH: jsonpath string methods: lower, upper, initcap, l/r/btrim, replace, split_part From: "David E. Wheeler" In-Reply-To: Date: Sat, 12 Jul 2025 14:24:25 -0400 Cc: Tom Lane , Peter Eisentraut , Robert Haas , Alexander Korotkov , pgsql-hackers , Andrew Dunstan Message-Id: <44F87861-8026-4AB8-95B0-E755E22C6B3F@justatheory.com> References: <145894.1727298237@sss.pgh.pa.us> <7e9debe6-4e96-4b0d-a801-b531e962ef43@eisentraut.org> <01DC1C38-0692-461B-AA63-5394330356BE@gmail.com> <2568904.1748022721@sss.pgh.pa.us> <40912112-7FFE-400F-A38F-368827C4BDF1@gmail.com> <176C517D-2DEB-4CAB-9AE4-261079D313B9@justatheory.com> <8FD5F4CF-9059-40C1-9F0A-C3CBA8DFE17A@justatheory.com> <696ECBBC-3CBF-4522-AE66-E48225688E93@gmail.com> <59C63857-406D-4704-A1EB-9BF3AA639C86@justatheory.com> <06FA8975-2E21-46A5-B510-028B3B967EB2@justatheory.com> <2F58E05D-D319-4CD3-8805-E1A8A2482A1A@justatheory.com> <4A96ACDB-78A1-4434-8C25-7C9716A7D421@justatheory.com> <4904EA5B-C6CA-42BD-BF08-C89325240C9D@gmail.com> <84727E10-62B7-4FE4-B487-E7044C7C0A1F@justatheory.com> <6CD16A54-BFEE-4CB5-84AC-F3B46289FA6D@justatheory.com> <7D19A273-1306-4F4C-9DFD-CE16F44790CB@justatheory.com> To: Florents Tselai X-Mailer: Apple Mail (2.3826.600.51.1.1) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail=_FEA8B938-5322-432E-B640-D007472BECCA Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii On Jul 12, 2025, at 00:07, Florents Tselai = wrote: > To recap so far;=20 >=20 > - I like your changes and renames on the parser/lexer; it indeed looks = much cleaner now and will help with future improvements. Thanks! > - I also like the addition of executeStringInternalMethod ; it'll help = us add more stuff in the future (reminder that for the original patch I = implemented the methods I'd like more, but string operations are quite = more). Agreed. > - AFAICT no test cases / results have changed with your versions; is = this correct ? I made some minor changes, notably to test alternate trim values and a = negative position passed to split_part(): ```patch --- a/src/test/regress/sql/jsonb_jsonpath.sql +++ b/src/test/regress/sql/jsonb_jsonpath.sql @@ -627,7 +627,7 @@ rollback; select jsonb_path_query('" hello "', '$.ltrim(" ")'); select jsonb_path_query('" hello "', '$.ltrim(" ")'); select jsonb_path_query('" hello "', '$.ltrim()'); -select jsonb_path_query('" hello "', '$.ltrim()'); +select jsonb_path_query('"zzzytest"', '$.ltrim("xyz")'); select jsonb_path_query('null', '$.ltrim()'); select jsonb_path_query('null', '$.ltrim()', silent =3D> true); select jsonb_path_query('[]', '$.ltrim()'); @@ -647,13 +647,13 @@ select jsonb_path_query_array('[" maybe ", " = yes", " no"]', '$[*].ltrim().ty -- test .rtrim() select jsonb_path_query('" hello "', '$.rtrim(" ")'); -select jsonb_path_query('" hello "', '$.rtrim(" ")'); +select jsonb_path_query('"testxxzx"', '$.rtrim("xyz")'); select jsonb_path_query('" hello "', '$.rtrim()'); select jsonb_path_query('" hello "', '$.rtrim()'); -- test .btrim() select jsonb_path_query('" hello "', '$.btrim(" ")'); -select jsonb_path_query('" hello "', '$.btrim(" ")'); +select jsonb_path_query('"xyxtrimyyx"', '$.btrim("xyz")'); select jsonb_path_query('" hello "', '$.btrim()'); select jsonb_path_query('" hello "', '$.btrim()'); @@ -723,6 +723,7 @@ select jsonb_path_query('"hello world"', = '$.replace("hello","bye") starts with " -- Test .split_part() select jsonb_path_query('"abc~@~def~@~ghi"', '$.split_part("~@~", 2)'); +select jsonb_path_query('"abc,def,ghi,jkl"', '$.split_part(",", -2)'); -- Test string methods play nicely together select jsonb_path_query('"hello world"', = '$.replace("hello","bye").upper()'); ``` Best, David --Apple-Mail=_FEA8B938-5322-432E-B640-D007472BECCA Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEd+KfmbOQis6ZycGGkt9idPjIgfEFAmhyqFkACgkQkt9idPjI gfFZUBAAkpa7z9AjZIeNp5+QM9jriCN/O4GXKCLCwyRmbIrLPYvr0VJ4c77+WNf/ eDDRuWJ47p6EbDiptim24KsEkbLKBDiufYa9EylcuTv2p9ce4XO0oDIQW4FUm6Fs jktSRqmdlNucd0Z/LxzsKSKUfR6LiOvLADr5QnsU9TXHptPfiMBM3H2dqhmvcLO0 LAu1d8So9i6rW5F6Xrv8EQ2kv0gIw84fohR36kkUEPaFWPK+eMSRRnXIAi2GHYqR /NGIMI8k6QxOMuaXKb5KFTei6KsH54le5CFEwm0gdjzfxDovEpzzn+vx/gDgEMdJ oWhGK+acJK6IVQWFwDrYMoCr1hOQB3L/XjcMFCiuJFHpWxmtzo5qKPzx7iF3EhkN wW/yCQacGNqesBdldG5itIC06ezzrNrb8uLTazjVaVSIRorl/9Nr6aN5OulMfZk9 0NzP98qEf7lbkOKB3m2W+ViSFzdyRrA4PSUA8AEE7+xGykKyPvDvh9TPo7rR9XKv FrvXpNzuuHAVcGXb2G3JRTbFvsr5ldqV0T004lYXnTh9UYrwTPajBmg+wqu280j4 +sXmrezsW5lIAGQjy/Kbj7AcQir6Cjn9iFhglbVbX4sL8sSxQgUOvYRsWs1U8yuw XYn2WiKFUgtZz0afyhotOeXXLhyahCaHlMBRqQSeExUrIbVIUwI= =ylo4 -----END PGP SIGNATURE----- --Apple-Mail=_FEA8B938-5322-432E-B640-D007472BECCA--