pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Yi Sun <yinan81@gmail.com>
Cc: PostgreSQL General <pgsql-general@lists.postgresql.org>
Subject: Re: pg_upgrade problem as locale difference in data centers
Date: Fri, 17 Sep 2021 10:05:06 -0400
Message-ID: <1295880.1631887506@sss.pgh.pa.us> (raw)
In-Reply-To: <CABWY_HB4LdgbfxCMFgV5E-YX3p4eJtgLk1f8eoViG9jwdYv6xw@mail.gmail.com>
References: <CABWY_HB4LdgbfxCMFgV5E-YX3p4eJtgLk1f8eoViG9jwdYv6xw@mail.gmail.com>

Yi Sun <yinan81@gmail.com> 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





view thread (4+ messages)  latest in thread

Message-ID: <1295880.1631887506@sss.pgh.pa.us>
Permalink:  ../1295880.1631887506@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1295880.1631887506@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, yinan81@gmail.com
  Subject: Re: pg_upgrade problem as locale difference in data centers
  In-Reply-To: <1295880.1631887506@sss.pgh.pa.us>
  References: <CABWY_HB4LdgbfxCMFgV5E-YX3p4eJtgLk1f8eoViG9jwdYv6xw@mail.gmail.com> <1295880.1631887506@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox