Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gj50e-0005Rh-Ru for pgsql-hackers@arkaria.postgresql.org; Mon, 14 Jan 2019 16:22:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gj4zf-0001IK-D5 for pgsql-hackers@arkaria.postgresql.org; Mon, 14 Jan 2019 16:21:43 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gj4zf-0001IC-5h for pgsql-hackers@lists.postgresql.org; Mon, 14 Jan 2019 16:21:43 +0000 Received: from mail.verite.pro ([185.16.44.216]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gj4zc-0002Ca-HC for pgsql-hackers@postgresql.org; Mon, 14 Jan 2019 16:21:42 +0000 Received: from genius-map.net (verite.pro [195.154.189.246]) by mail.verite.pro (Postfix) with ESMTP id F18CE8C0233; Mon, 14 Jan 2019 17:16:44 +0100 (CET) Received: by genius-map.net (Postfix, from userid 1001) id CDAB738A18F7; Mon, 14 Jan 2019 17:21:37 +0100 (CET) Content-Type: text/plain; charset="iso-8859-15" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: insensitive collations From: "Daniel Verite" To: "Andreas Karlsson" Cc: "Peter Eisentraut" ,"pgsql-hackers" In-Reply-To: Date: Mon, 14 Jan 2019 17:21:34 +0100 Message-Id: X-Mailer: Manitou v1.7.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Andreas Karlsson wrote: > > Nondeterministic collations do address this by allowing canonically > > equivalent code point sequences to compare as equal. You still need a > > collation implementation that actually does compare them as equal; ICU > > does this, glibc does not AFAICT. >=20 > Ah, right! You could use -ks-identic[1] for this. Strings that differ like that are considered equal even at this level: postgres=3D# create collation identic (locale=3D'und-u-ks-identic', provider=3D'icu', deterministic=3Dfalse); CREATE COLLATION postgres=3D# select '=E9' =3D E'e\u0301' collate "identic"; ?column?=20 ---------- t (1 row) There's a separate setting "colNormalization", or "kk" in BCP 47 From=20 http://www.unicode.org/reports/tr35/tr35-collation.html#Normalization_Setti= ng "The UCA always normalizes input strings into NFD form before the rest of the algorithm. However, this results in poor performance. With normalization=3Doff, strings that are in [FCD] and do not contain Tibetan precomposed vowels (U+0F73, U+0F75, U+0F81) should sort correctly. With normalization=3Don, an implementation that does not normalize to NFD must at least perform an incremental FCD check and normalize substrings as necessary" But even setting this to false does not mean that NFD and NFC forms of the same text compare as different: postgres=3D# create collation identickk (locale=3D'und-u-ks-identic-kk-fal= se', provider=3D'icu', deterministic=3Dfalse); CREATE COLLATION postgres=3D# select '=E9' =3D E'e\u0301' collate "identickk"; ?column?=20 ---------- t (1 row) AFAIU such strings may only compare as different when they're not in FCD form (http://unicode.org/notes/tn5/#FCD) There are also ICU-specific explanations about FCD here: http://source.icu-project.org/repos/icu/icuhtml/trunk/design/collation/ICU_= collation_design.htm#Normalization It looks like setting colNormalization to false might provide a performance benefit when you know your contents are in FCD form, which is mostly the case according to ICU: "Note that all NFD strings are in FCD, and in practice most NFC strings will also be in FCD; for that matter most strings (of whatever ilk) will be in FCD. We guarantee that if any input strings are in FCD, that we will get the right results in collation without having to normalize". Best regards, --=20 Daniel V=E9rit=E9 PostgreSQL-powered mailer: http://www.manitou-mail.org Twitter: @DanielVerite