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 1uIGvU-001Mk9-DG for pgsql-bugs@arkaria.postgresql.org; Fri, 23 May 2025 01:10:20 +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 1uIGvR-00BjIZ-Jc for pgsql-bugs@arkaria.postgresql.org; Fri, 23 May 2025 01:10:17 +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 1uIGvQ-00BjIR-Mh for pgsql-bugs@lists.postgresql.org; Fri, 23 May 2025 01:10:17 +0000 Received: from fhigh-a7-smtp.messagingengine.com ([103.168.172.158]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uIGvO-000P7u-0w for pgsql-bugs@lists.postgresql.org; Fri, 23 May 2025 01:10:15 +0000 Received: from phl-compute-09.internal (phl-compute-09.phl.internal [10.202.2.49]) by mailfhigh.phl.internal (Postfix) with ESMTP id EE81A1140227; Thu, 22 May 2025 21:10:13 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-09.internal (MEProxy); Thu, 22 May 2025 21:10:13 -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=1747962613; x=1748049013; bh=6RLHm/JOZn 3mRW6P2+G52Z4N99sC9GTr0nLqLFnBTX0=; b=h/TgHi8L5vMmj6SfeVfrdYiZfo /5bzoUB8ladOldd62H+TEw+Fc/MMjSsSZMwjwVn2BtG85wbWQlR8HZLzTdcyAaB4 vgq2sr++ImkW1bHzhIJ7de6wNHJF6xKdRCKeR77B00VHK9HeCCgVFNYp+uySAt0n cH4lNSn8KFFwJmFb/asTLloRpB3Af+SWq0Tv362PcfTnQWuckbcBbEy/0wySRwj0 57FxiVUdfiCvdBglNo1F8xGs/3ILLY35+RjAseICFJjnyJ/5rVzIvOlZwqlrw90Q wkxNHQlc3PoRkf9p8qNd3LD2EiiTlOksogGVXwsZJCrym+O03BlCvqjXVLaw== 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= 1747962613; x=1748049013; bh=6RLHm/JOZn3mRW6P2+G52Z4N99sC9GTr0nL qLFnBTX0=; b=efA3O2qB9cBYfsd+GXivEGgr1VdC7ZPrtu+7q9SHxRi/dD0vfel gyw2ZnZLt7fgJ/L5i6xmkROsdkt/P6sCg1j0q8Rr0DBWFes2dZMjNbwiehdd3PjQ 4VJEmhPcMpj+bADQe4Tx1Ej/lEMnxnPYTTLLG0cbdFNlcyh5hSDdu0t+kVNUPu9G Q4IpUd6qTy9xRWUtucFxXsgLLOoN4x1t+c7thOkyY2JFZ19OCr617CMSsUe1oeGR 1X6z8yiNUiGq4bDlFzs0fb5HRu2s1Jx7vp+ZLa+mIvCghABlH9kmHXHMZVXaH1/I fnNj5+D3n5HHiMswGHkezLjdDgX0HCmd9dA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtddtgdejgeekucdltddurdegfedvrddttd 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 21:10:12 -0400 (EDT) Date: Fri, 23 May 2025 10:10:04 +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="T0VnWYkSFBBHVbW0" Content-Disposition: inline In-Reply-To: <16ab039d1af455652bdf4173402ddda145f2c73b.camel@cybertec.at> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --T0VnWYkSFBBHVbW0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, May 22, 2025 at 11:18:44PM +0200, Laurenz Albe wrote: > The underscore before the [:alpha:] is left alone, but the one after > it gets translated to a period. Now the underscore is a wildcard > that corresponds to the period in regular expressions, but characters > in square brackets should lose their special meaning. The code in > utils/adt/regexp.c doesn't expect that square brackets can be nested. >=20 > The attached patch fixes the bug. 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. + if (pchar !=3D '^' && charclass_start) + charclass_start =3D false; 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? -- Michael --T0VnWYkSFBBHVbW0 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmgvyuwACgkQnvQgOdby QH0Y4g/+LwSJDh4bVl6omZnDJulAbos2GlYE8qer9gZ8Riaqx+QMbcTzXXxJpcsa QTpfWTp07FL++YgxfW/IgEIMT208MWHPa1b1TLy0hqt2Gfa4F8wZTejWgwTvXL3d fEjp21L5Y6a/oh/6nZ3yJVm5DmoR7OH/akQ6uDNeuhgj5Iyb3Ik84cP4e0++gVT3 zX9k9q2+6Heis214H5ftPrPeaSEDOCaypl0C18qUdRuwzV7p3XEzdZ21oEH6akWr rud4uI4Udu3DymGGPjvUTn/RDm2n3NRwNwBmLKBKaZLOh4wYiTYrl9Cw/xQi7sid gredN/b3Gw+Ain3P4D7kE2LzMnnsEFLqv0AriZgcEB376Sl5n3t5zn0XDJi9nq5u 0vn3W/W0AW5G5SshSbjRZMvmH2yPtPQWAKZLs4bJ+CPS60bVWmzLUNnvn+ii+FqE dn3a0HdJr5z1YXTGUV2vy3DSgJngCggwJNaxRPGbo0z2wIznNJ8MW3nBV+wU7X2F bRzIxf0YR/V8JZaOLb1xEn/ftsHtysZBfTH1Mp5VE+qAYGSHgLQi9oRUiP/VyApR fIQSnNNTEC9UdfqmnuuPrIw9RZkqwymLmInr+JHC8ChNEqxmJPOg2eSohnBG0wTD p0jHwEfYCG9tE3qg8LPrHt8/lP/tK9RHaFCbofXSIAvxp2ureh8= =fMTc -----END PGP SIGNATURE----- --T0VnWYkSFBBHVbW0--