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 1nzSpV-0003xO-Qh for pgsql-hackers@arkaria.postgresql.org; Fri, 10 Jun 2022 00:48:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nzSpT-0005Q4-VW for pgsql-hackers@arkaria.postgresql.org; Fri, 10 Jun 2022 00:48:47 +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 1nzSpT-0005Pu-L8 for pgsql-hackers@lists.postgresql.org; Fri, 10 Jun 2022 00:48:47 +0000 Received: from mout.gmx.net ([212.227.15.15]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nzSpM-0004mY-EE for pgsql-hackers@postgresql.org; Fri, 10 Jun 2022 00:48:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1654822115; bh=rCTNAM8R8AdbeeDWa8m25JcBO4661vfWhXUlH5OwN4Y=; h=X-UI-Sender-Class:Subject:From:In-Reply-To:Date:Cc:References:To; b=Ij5YE3X8yLdYrGRPytV74arqT0QwYAz7McS1CQPvZmZC0ge5XjQRieslawm7VnFrE Xxwjcfdi5f7iRHrvVWkOM1wcpQ2O0minKL50r1M56k06dgbON4PL576MZ8XvUsS4DG sZSgUbaSksk3YLP92tDHC4nfw19cxynW7w/ILHZs= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [10.0.1.12] ([185.74.121.211]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MGz1V-1nuoFs31Hf-00E8Gr; Fri, 10 Jun 2022 02:48:35 +0200 Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.7\)) Subject: Re: Collation version tracking for macOS From: Tobias Bussmann In-Reply-To: Date: Fri, 10 Jun 2022 02:48:33 +0200 Cc: Peter Eisentraut , Thomas Munro Content-Transfer-Encoding: quoted-printable Message-Id: <30766D63-C51C-4000-B270-501635F58E43@gmx.net> References: <381977b1-0898-cb6f-a427-3b5d873e81bd@enterprisedb.com> To: pgsql-hackers X-Mailer: Apple Mail (2.3445.9.7) X-Provags-ID: V03:K1:KmOzLFveK8LIN91NqwDjiepJeF3GLvE0p5MYwFrnm8kUaagv6OB KUcf1ed+xccRgjZO3Jaw4DLOGlM8cNWKvs1RQWQZGGeEjC5sfPaFsts7UpiVcrdQAxdb0BZ DSSFxHPREfH7s/D0SFMSLxMVzI7tZ9k8rx0CUjxghOjB9FCgsEfqtZkPUgEeniql0jV5wdl d7rZ5YGc1cr3tU8+l7g8g== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:P7/FWMAeeJE=:Tbla3waIiMW8aECnT5gNaQ nwBAxW8uah9dDvVgCderHSy+u9Rl68yDfVj4t/XXMO2yZXrortFUxAC1pH17xqP9ST2v2LIDt FHbHiDeeuf8sEP7jOSsIczeeozp8Nk4kfJu7Bb9YP8x/JNeC9gwd+C/2ccdItyenPFrztr5+c VVPOb/lPl2Ya5SZBqX5Aw7yRvXmIS872B8MT7duGn2qkiCAfsSr2MWjOKXjDqF/mKIM9Z9CgS WeSMHs5BXuUg4xF5jsHnTUpP2arOU021lF9MDmw3WjGBxBpPGPp8obHI7IVin9d3QknykXeD6 2chgKcYcYGVwJAy8+MEdArkE6nu5QCD79taELO328QN0MGpo4W+xLC3CYPloUkKXeg5VMTPfs V9AcQMtF3IJPxSKSF0YhmRty/djCYZwzx6jZnXZNW3Zr2bHjRrTdgsb0JRTJ+jQKtfH0kAmIX JCfm9uN4/eu1H5A/g5HSqJDs0bjcjJZHMvK3DdCovVa6h4al0LHO/1EoYb/7z8FFwnSLpazL0 mRxoSMSydnDen7prF7p3dwQ60ss4D/dtwda7pIsxmoazT6Irzriwu8feT+8b1SNjzP/fYlKDb kbvwVuQ9AJA+DoeWaLU6fOin/daSqAXR5h+Xvq/ubpe34pjKeSaEXBOrbWyF02ul4zReQ5+HP kE9DX8A6ADjed4fA15k0aFMbqVkRbqemjB1u8YaA+xmyFrdT4jytB1Ms4I0NzfwbzVwNJPxPr D3186c907h6tfYzCMaPnA2ivtoMw8Mx0pply/np2roYApUH+Cfs4ksw+n+0Sl5SJjR0HC1dj4 lA3jH1ubhtsCF8ysQ21TUTw+xR9Zb71AiBJRsbHVGHt2Z+N92iOr98iCmCVagK9HbVyEwG+9h GcrSHmSlVIVOVxKoniFMmt0xWxgxYskHjnRVX4809fQ/pZQ2yXE4ec5xZpwNYJqh38W6r8ohI W02c66+wuAZRvVU2QiGF6G7IqNcJXXbE4iC19VkT8QsIurvcjVXb4xLtNlm0M1QLv2CQxmyBS MCjOyfUHUCfguXM5PMMcNRv+rxeBXOvkRvSKrhmT0cCwsA8IOKYej2fnd95c8hAwGb8xkR3MN 3KAbHj02NzEnN1/9gGOngoV5MlGs0VaFRekKP/nQ0sM4w2Av0t0B15Hbg== List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Thanks for picking this up! > How can I see evidence of this? I'm comparing Debian, FreeBSD and > macOS 12.4 and when I run "LC_COLLATE=3Den_US.UTF-8 sort > /usr/share/dict/words" I get upper and lower case mixed together on > the other OSes, but on the Mac the upper case comes first, which is my > usual smoke test for "am I looking at binary sort order?" Perhaps I can shed some light on this matter: Apple's libc collations have always been a bit special in that concern, = even for the non-UTF8 ones. Rooted in ancient FreeBSD they "try to keep = collating table backward compatible with ASCII" thus upper and lower = cases characters are separated (There are exceptions like = 'cs_CZ.ISO8859-2'). The latest public sources I can find are in = adv_cmds-119 [1] which belongs to OSX 10.5 [2] - these correspond to the = ones used in FreeBSD till v10 [3], whereby the timestamps rather point = its origin around FreeBSD 5. Further, there are only very few locales = actually present on macOS (36 - none of it supporting Unicode) and these = have not changed for a very long time (I verified that from OS X 10.6.8 = till macOS 12.4 [4], exception is a 'de_DE-A.ISO8859-1' present only in = macOS 10.15). What they do instead is symlinking [5] missing collations to similar = ones even across encodings, often resulting in la_LN.US-ASCII ('la_LN' = seem to stand for a Latin meta language) being used which is exactly = byte order [6]. These symlinks have not changed [7] from OS X 10.6.8 = till macOS 10.15.7. But in macOS 11 many of these symlinks changed their = target. So did the popular 'en_US.UTF-8' from 'la_LN.US-ASCII' to = 'la_LN.ISO8859-1' or 'de_DE.UTF-8' from 'la_LN.US-ASCII' to = 'de_DE.ISO8859-1'. In effect, about half of the UTF-8 collations change = from no collation to partial/broken collation support. macOS 12 again = shows no changes - tests for macOS 13 are outstanding. # tl:dr; With your smoke test "sort /usr/share/dict/words" on a modern macOS you = won't see a difference between "C" and "en_US.UTF-8" but with "( echo = '5=C2=A3'; echo '=C2=A35' ) | LC_COLLATE=3Den_US.UTF-8 sort" you can = produce a difference against "( echo '5=C2=A3'; echo '=C2=A35' ) | = LC_COLLATE=3DC sort". Or test with "diff -q <(LC_COLLATE=3DC sort = /usr/share/dict/words) <(LC_COLLATE=3Des_ES.UTF-8 sort = /usr/share/dict/words)" The upside is that we don't have to cope with the new characters added = in every version of Unicode (although I have not examined LC_CTYPE yet). best regards Tobias [1]: = https://github.com/apple-oss-distributions/adv_cmds/tree/adv_cmds-119/usr-= share-locale.tproj/colldef [2]: https://opensource.apple.com/releases/ [3]: https://github.com/freebsd/freebsd-src/tree/stable/10/share/colldef [4]: find /usr/share/locale/*/LC_COLLATE -type f -exec md5 {} \; [5]: = https://github.com/apple-oss-distributions/adv_cmds/blob/adv_cmds-119/usr-= share-locale.tproj/colldef/BSDmakefile [6]: = https://github.com/apple-oss-distributions/adv_cmds/blob/adv_cmds-119/usr-= share-locale.tproj/colldef/la_LN.US-ASCII.src [7]: find /usr/share/locale/*/LC_COLLATE -type l -exec stat -f "%N%SY" = {} \;=20=