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 1mREUO-00011o-Bm for pgsql-general@arkaria.postgresql.org; Fri, 17 Sep 2021 14:05:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mREUN-0001IR-0P for pgsql-general@arkaria.postgresql.org; Fri, 17 Sep 2021 14:05:15 +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 1mREUM-0001II-Nh for pgsql-general@lists.postgresql.org; Fri, 17 Sep 2021 14:05:14 +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 1mREUI-00073I-Vd for pgsql-general@lists.postgresql.org; Fri, 17 Sep 2021 14:05:13 +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 18HE562K1295881; Fri, 17 Sep 2021 10:05:06 -0400 From: Tom Lane To: Yi Sun cc: PostgreSQL General Subject: Re: pg_upgrade problem as locale difference in data centers In-reply-to: References: Comments: In-reply-to Yi Sun message dated "Fri, 17 Sep 2021 11:54:05 +0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1295879.1631887506.1@sss.pgh.pa.us> Date: Fri, 17 Sep 2021 10:05:06 -0400 Message-ID: <1295880.1631887506@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Yi Sun writes: > update pg_database set datcollate='en_US.UTF-8', datctype='en_US.UTF-8' > where datname in ('postgres','template1','template0') and > (datcollate<>'en_US.UTF-8' or datctype<>'en_US.UTF-8') This seems like a pretty bad idea. You might get away with it if you've not added any user-defined indexes in any of those databases, but it's definitely a case where if things go wrong you'll be told it's your own fault. The context of "moving to a new datacenter and also updating across four Postgres versions" suggests strongly to me that you are also planning a move to a new OS version, in which case you had better read https://wiki.postgresql.org/wiki/Locale_data_changes In short, it seems to me that you are at very great risk of ending up with corrupt (incorrectly ordered) indexes on textual columns. If you don't mind reindexing all of those after the update, you could proceed with this plan. Otherwise, pg_dump-and-restore might be a safer idea. regards, tom lane