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.92) (envelope-from ) id 1jDriu-0001Ay-Rj for pgsql-general@arkaria.postgresql.org; Mon, 16 Mar 2020 15:32:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jDris-0005wP-P7 for pgsql-general@arkaria.postgresql.org; Mon, 16 Mar 2020 15:32:10 +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 1jDrfm-0001Rq-AR for pgsql-general@lists.postgresql.org; Mon, 16 Mar 2020 15:28:58 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jDrfk-0004Zx-3e for pgsql-general@postgresql.org; Mon, 16 Mar 2020 15:28:57 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id 02GFSsGM005625; Mon, 16 Mar 2020 11:28:54 -0400 From: Tom Lane To: Don Seiler cc: Postgres General Subject: Re: Mixed Locales and Upgrading In-reply-to: References: Comments: In-reply-to Don Seiler message dated "Mon, 16 Mar 2020 09:24:13 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <5623.1584372534.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 16 Mar 2020 11:28:54 -0400 Message-ID: <5624.1584372534@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Don Seiler writes: > However this database has encoding UTF8 while still having ctype and > collation of en_US. I've since found that when this was last upgraded, t= hey > ran "update pg_database set encoding =3D pg_char_to_encoding('UTF8') whe= re > datname =3D 'test';" to change the encoding. Egad. > In my testing, pg_upgrade breaks > when trying to restore this since UTF8 isn't supported in en_US for the = CREATE > DATABASE command used during pg_restore: Well, in principle you could likewise manually update pg_database's datcollate and datctype columns to say "en_US.utf8". However, there's a much bigger problem here --- what steps if any did this cowboy take to ensure that the data inside the database was valid UTF8? I don't think you should use pg_upgrade here at all. A dump/restore is really the only way to make sure that you have validly encoded data. However, if it's only one database out of a bunch, you could do something like * pg_dump that one database; * drop said database; * pg_upgrade everything else; * restore that one database from dump. regards, tom lane