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 1uIIzV-0020VG-P9 for pgsql-bugs@arkaria.postgresql.org; Fri, 23 May 2025 03:22:38 +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 1uIIzU-00DSud-17 for pgsql-bugs@arkaria.postgresql.org; Fri, 23 May 2025 03:22:35 +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.94.2) (envelope-from ) id 1uIIzT-00DStc-0x for pgsql-bugs@lists.postgresql.org; Fri, 23 May 2025 03:22:35 +0000 Received: from fout-a6-smtp.messagingengine.com ([103.168.172.149]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uIIzP-000RsY-2m for pgsql-bugs@lists.postgresql.org; Fri, 23 May 2025 03:22:34 +0000 Received: from phl-compute-03.internal (phl-compute-03.phl.internal [10.202.2.43]) by mailfout.phl.internal (Postfix) with ESMTP id 09B461380171; Thu, 22 May 2025 23:22:30 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-03.internal (MEProxy); Thu, 22 May 2025 23:22:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; 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=fm3; t=1747970550; x=1748056950; bh=uNICto11h/ VWoSTbcCaoL/kQG7c/cbZ698cJVS0p284=; b=Hpl9xi8Nw5kFT057U+rQJd1d/J hbIcDzudVEn71RUmAKmIYkg0vRElsMV7mYI7brcV3l/8w5T7hiIN+d8zWv+NwrAG 1GKnjwkPuMLGiq0GwGoUvwxgaFLXlvSFW6nVgP59E6U3DbKwcvbLO0gkG0AwMZu4 xW1SR5baHKz6UObwah/Sx2Ux2SMRBuJToalz1sLEnK6yH/iZPvqvwUR6sY8agffg p8XpVuD+5xmYfeBReAclnOHRrwtgE7wiZKZ9YyiEOeln5ICQvjKSOO4nvq1m0UtX roORW7CdaRtbjfDwKDabjC/2fppa2qq3MU9zCVYSj6ChEVlfds8ElCcgIOFg== 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=fm3; t= 1747970550; x=1748056950; bh=uNICto11h/VWoSTbcCaoL/kQG7c/cbZ698c JVS0p284=; b=TxG0jgvKk9FjEjv3HuVTxvvM3hS0akPAZix7uSEftMg1g87uV8u NyPgr0KIh1y5DjPKH8vpzAh1LjcW4u5qrrffxbKpLKWFaLx9jtXiDPawIfvQG3qA naspynOa2y00iLNq6MFVY1C1chQRjjBD1t6dGazz8v2ngIKEYR4Mm7dkq1PYEyXI VNfx208c39dbAvHp3/2wY8kukVWc7keXsltTZ0np+pZFZng7pnklruAfEY13D5qd PG6jawU8+GFRUjBeUeJ4nbdp6EpT61Yb/PUTeCeOIYmxGfKXiNU07luVnsk0FPOH 71u8gLSQyhp6kms/6D0P9isWqEQXlraehpQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtddtgdejjeegucdltddurdegfedvrddttd dmucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgf nhhsuhgsshgtrhhisggvpdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttd enucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrhhlucfvnfffucdljedtmden ucfjughrpeffhffvvefukfhfgggtuggjsehgtderredttddvnecuhfhrohhmpefoihgthh grvghlucfrrghquhhivghruceomhhitghhrggvlhesphgrqhhuihgvrhdrgiihiieqnecu ggftrfgrthhtvghrnhepteelieefudffhffhtdetleeggeegfffhkeeuveetiefgudduve dutefggeeivdejnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhf rhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiihiidpnhgspghrtghpthhtohepvd dpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtoheplhgruhhrvghniidrrghlsggvsegt higsvghrthgvtgdrrghtpdhrtghpthhtohepphhgshhqlhdqsghughhssehlihhsthhsrd hpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 22 May 2025 23:22:28 -0400 (EDT) Date: Fri, 23 May 2025 12:22:21 +0900 From: Michael Paquier To: Laurenz Albe Cc: pgsql-bugs@lists.postgresql.org Subject: Re: SIMILAR TO expressions translate wildcards where they shouldn't Message-ID: References: <16ab039d1af455652bdf4173402ddda145f2c73b.camel@cybertec.at> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="Kggbu6NDWznZSGhC" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Kggbu6NDWznZSGhC Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, May 23, 2025 at 10:10:04AM +0900, Michael Paquier wrote: > Oh, good catch. [_[:alpha:]] and [[:alpha:]_] both that this should > match every string made of a-zA-Z and underscores, but this is failing > to do the job for the latter. >=20 > + if (pchar !=3D '^' && charclass_start) > + charclass_start =3D false; >=20 > I'm a bit puzzled by this part about '^', though, resetting the fact > that we are in a squared bracket section with '^' treated as an > exception. Perhaps this deserves a comment? Ah, I see. This is just a way of saying that the caret ^ should still be able to track the first character in the character class. Anyway, I don't think that the tests in the patch are complete. For example, '[[^](]' is transformed into '^(?:[[^](])$' in the SIMILAR TO conversion with the patch, and before the patch we get '^(?:[[^](?:])$'. Note the translation of the last parenthesis '(' to "(?:" when inside the character class, but your patch does not document that. AFAIU, we should not convert the parenthesis '(' while in a multi-level character class as the patch does, but we have no tests for it and the patch does not document this part, either. Could it be possible to split the single SIMILAR TO expression into multiple smaller pieces for each character that should not be converted while inside a character class? This is hard to parse as written in your proposal of patch. -- Michael --Kggbu6NDWznZSGhC Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmgv6e0ACgkQnvQgOdby QH1VuRAAhUHcwzyT4UOmstUWgPkcinOJa1TSOpAYKHc/Gh3Cpgw/IzNey3K7y8OQ 1uqxnGvI/1bysOmlLlvI+fAD2TrMIe1ly1u7nxEg7yxuOMGOC5yQJ77Wj/GdHEO9 31X/cH50QknJEi0kGQT8PtXittGZODsN8kcy1vX8RSTkzYgzm7f4Fyln78shslhG 2UIfq9FoiInHG25rMPvzGXyGtmqOC17Y2DhkOIDBYtKunyP8wqbAUy12q5GetRQH Wwmz4slV35k/nLaG/EWo46AZeCBgDM8Ib/f2iRjtwbQ4uLzNJ4Pu1DslkT942FKQ Cn+kllmqrtyzy+/grvYJ8Ory/EXxQnVvaYD8xTuwP7xnjDRMHsqoi2wCpm7+NJJP jpVV8FbgCnFdOEKbT/Pldfy4Hb/HaIDyUSeNdLP0ODPiwH3qDs160fY/2xyECNNo 0+CuW5m6zam3KXtQJ0TIgJU+x+WFQYtVh+QXLe/GVB1hdV9QY4nknEievKyQXBbk 7/fV+lxk2Hr6tImiRiIRPATZ/gbZTDUTBXK/uAztoExy0BMzn/BMRX52SScgXdks cU/n1fNNni2+rKu5EasSViP1mrVRHCEPZ/rTMfR9gb9aD92zXgTAj5hUf8DWzy2n KiR2HTBW2/YZ7VjZFqtcu5Xbfypna1l0KxsSqB4myWQT4UI7xM0= =eVkg -----END PGP SIGNATURE----- --Kggbu6NDWznZSGhC--