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 1msVIe-0005b0-58 for pgsql-general@arkaria.postgresql.org; Wed, 01 Dec 2021 19:29:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1msVIb-0005eS-1x for pgsql-general@arkaria.postgresql.org; Wed, 01 Dec 2021 19:29:49 +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 1msVIZ-0005db-SR for pgsql-general@lists.postgresql.org; Wed, 01 Dec 2021 19:29:48 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1msVIP-0004X2-WF for pgsql-general@lists.postgresql.org; Wed, 01 Dec 2021 19:29:46 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 3557E5C019B; Wed, 1 Dec 2021 14:29:36 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Wed, 01 Dec 2021 14:29:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=RQEGeUf56Gjc5nFzeembsS7FqBTzJ7DzlYNNZtJZ2 Gw=; b=YOIgj0nrIb89pREKtQws8Ebd7cdPyR6U8cHXqQhsIV/3UcxZFrHOuUMDT hEZ7oupmNbXiKAI72+wolCGZyDxVK0h2ReenFUfpAXvQexjwvWrIFyEjkhWVPya/ V6muTCy5XeI0UISU+J5xb7kHQBa1PnlDHqAtSbKlGeN29nqiRqnCTOvGv4I3ZzqT yO+GyV/K87KxsaR3Zh8r4tXnZRy8iCuSo/AJ9E6AqupE9m2nl4pk3GKXzpM4FHm5 Cjap985XEgESiV7ECKTNshhLvk+Htf0z9/cBIFvioU+yEiemQqEYQNsolDX3FoXJ hDYb8q8s9xipjN88VH2mlsvwO+sCw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddrieefgdduvdehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvfhfhjggtgfesthekredttdefjeenucfhrhhomheprfgvthgv rhcugfhishgvnhhtrhgruhhtuceophgvthgvrhdrvghishgvnhhtrhgruhhtsegvnhhtvg hrphhrihhsvggusgdrtghomheqnecuggftrfgrthhtvghrnheplefgteefiedtleelgeeg jeevhfeuteefvddtjeehveeuieefgedvhfeuleduteeunecuvehluhhsthgvrhfuihiivg eptdenucfrrghrrghmpehmrghilhhfrhhomhepphgvthgvrhdrvghishgvnhhtrhgruhht segvnhhtvghrphhrihhsvggusgdrtghomh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 1 Dec 2021 14:29:35 -0500 (EST) Message-ID: <9e3220da-d47e-add7-8b97-7c65b12ff6d7@enterprisedb.com> Date: Wed, 1 Dec 2021 20:29:33 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Subject: Re: case insensitive collation of Greek's sigma Content-Language: en-US To: Jakub Jedelsky , pgsql-general@lists.postgresql.org References: From: Peter Eisentraut In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 26.11.21 08:37, Jakub Jedelsky wrote: > postgres=# SELECT > postgres-# 'ΣΣ' ILIKE 'σσ' COLLATE "en_US", > postgres-# 'ΣΣ' ILIKE 'σς' COLLATE "en_US" > postgres-# ; >  ?column? | ?column? > ----------+---------- >  t        | f > (1 row) > > postgres=# SELECT > postgres-# 'ΣΣ' ILIKE 'σσ' COLLATE "en-US-x-icu", > postgres-# 'ΣΣ' ILIKE 'σς' COLLATE "en-US-x-icu"; >  ?column? | ?column? > ----------+---------- >  f        | t > (1 row) > > If I could start, I think both results are wrong as both should return > True. If I got it right, in the background there is a lower() function > running to compare strings, which is not enough for such cases (until > the left side isn't taken as a standalone word). The reason for these results is that for multibyte encodings, a ILIKE b basically does lower(a) LIKE lower(b), and select lower('ΣΣ' COLLATE "en_US"), lower('ΣΣ' COLLATE "en-US-x-icu"); lower | lower -------+------- σσ | σς 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.