pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Don Seiler <don@seiler.us>
Cc: Postgres General <pgsql-general@postgresql.org>
Subject: Re: Mixed Locales and Upgrading
Date: Mon, 16 Mar 2020 11:28:54 -0400
Message-ID: <5624.1584372534@sss.pgh.pa.us> (raw)
In-Reply-To: <CAHJZqBAS6kuTWZwSbu8KqfhJ8dapvTegyA1QweAHAmmQveUyRA@mail.gmail.com>
References: <CAHJZqBAS6kuTWZwSbu8KqfhJ8dapvTegyA1QweAHAmmQveUyRA@mail.gmail.com>

Don Seiler <don@seiler.us> 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, they
> ran "update pg_database set encoding = pg_char_to_encoding('UTF8') where
> datname = '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





view thread (19+ messages)  latest in thread

Message-ID: <5624.1584372534@sss.pgh.pa.us>
Permalink:  ../5624.1584372534@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/5624.1584372534@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, don@seiler.us
  Subject: Re: Mixed Locales and Upgrading
  In-Reply-To: <5624.1584372534@sss.pgh.pa.us>
  References: <CAHJZqBAS6kuTWZwSbu8KqfhJ8dapvTegyA1QweAHAmmQveUyRA@mail.gmail.com> <5624.1584372534@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