Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1msVbh-0006rL-2m for pgsql-general@arkaria.postgresql.org; Wed, 01 Dec 2021 19:49:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1msVbg-00013V-0s for pgsql-general@arkaria.postgresql.org; Wed, 01 Dec 2021 19:49:32 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1msVbf-00013A-MU for pgsql-general@lists.postgresql.org; Wed, 01 Dec 2021 19:49:31 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1msVbd-0004i4-Aa for pgsql-general@lists.postgresql.org; Wed, 01 Dec 2021 19:49:30 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 1B1JnOC11989906; Wed, 1 Dec 2021 14:49:24 -0500 From: Tom Lane To: Peter Eisentraut cc: Jakub Jedelsky , pgsql-general@lists.postgresql.org Subject: Re: case insensitive collation of Greek's sigma In-reply-to: <9e3220da-d47e-add7-8b97-7c65b12ff6d7@enterprisedb.com> References: <9e3220da-d47e-add7-8b97-7c65b12ff6d7@enterprisedb.com> Comments: In-reply-to Peter Eisentraut message dated "Wed, 01 Dec 2021 20:29:33 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <1989904.1638388164.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Wed, 01 Dec 2021 14:49:24 -0500 Message-ID: <1989905.1638388164@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Peter Eisentraut writes: > Running lower() like this is really the wrong thing to do. We should be > doing "case folding" instead, which normalizes these differences for the > purpose of case-insensitive comparisons. That just begs the question: if tolower (or towlower) isn't the appropriate API, what is? Perhaps ICU has something for a more generalized notion of case-similarity, but I'm not aware of any such thing in the POSIX API. BTW, I think it's only accidental that the regex example shown upthread gets the right answer. In that example, what's happening is that we consider a letter in a case-insensitive regex to match itself, or tolower() of itself, or toupper() of itself. Both σ and ς have Σ as toupper() so they both work. But if you'd written Σ in the regex, only one of σ and ς would match that as a data character. (Haven't actually tested this, but given the way the code works I'm pretty sure it's so.) Again, it's hard to see how to do better atop a POSIX locale library. regards, tom lane