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 1pb6Db-0006Hk-Vl for pgsql-admin@arkaria.postgresql.org; Sat, 11 Mar 2023 20:53:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pb6Da-0008A5-Nx for pgsql-admin@arkaria.postgresql.org; Sat, 11 Mar 2023 20:53:30 +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 1pb6Da-00089w-DF for pgsql-admin@lists.postgresql.org; Sat, 11 Mar 2023 20:53:30 +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 1pb6DX-0000oQ-RV for pgsql-admin@lists.postgresql.org; Sat, 11 Mar 2023 20:53:29 +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 32BKrNJQ1253568; Sat, 11 Mar 2023 15:53:23 -0500 From: Tom Lane To: Erik Wienhold cc: Alexey Murz Korepov , pgsql-admin@lists.postgresql.org Subject: Re: Ways to change a database collation with removing duplicates In-reply-to: <1378811615.328761.1678562412852@office.mailbox.org> References: <1378811615.328761.1678562412852@office.mailbox.org> Comments: In-reply-to Erik Wienhold message dated "Sat, 11 Mar 2023 20:20:12 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1253566.1678568003.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sat, 11 Mar 2023 15:53:23 -0500 Message-ID: <1253567.1678568003@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Erik Wienhold writes: > On 11/03/2023 19:23 CET Alexey Murz Korepov wrote: >> Could anyone suggest to me the ways to change a database collation with >> removing all the duplicates, caused by this change? > Collations can only affect uniqueness if they are nondeterministic or if= you > have functional indexes, e.g. using lower(text) for a case-insensitive u= nique > index. Otherwise the collations only affect text ordering. Yeah. I suspect that what actually happened here was a previous change in the host system's sort ordering (cf [1]), leading to text indexes becoming functionally corrupt and unable to enforce uniqueness correctly, after which you accumulated some unintentional duplicates. If you try reindex'ing on the source database you'll probably find that it fails with the same errors. I don't know of any automatic tools for fixing up such duplications, and wouldn't trust one hugely anyway --- you'll probably need manual curation of the fixes. regards, tom lane [1] https://wiki.postgresql.org/wiki/Locale_data_changes