Re: Recommended approach for upgrading DBs with nonmatching encodings - Mailing list pgsql-bugs

From Martin Pitt
Subject Re: Recommended approach for upgrading DBs with nonmatching encodings
Date
Msg-id 20080330205847.GP6486@piware.de
Whole thread Raw
In response to Re: Recommended approach for upgrading DBs with nonmatching encodings  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Recommended approach for upgrading DBs with nonmatching encodings
List pgsql-bugs
Tom Lane [2008-03-30 16:43 -0400]:
> Martin Pitt <martin@piware.de> writes:
> > One problem with this is that while pg_dump -E UTF8 works (with SQL
> > output), -E does not seem to have any effect when using -Fc.
>
> Huh?  Please provide a test case.

Ah, I got it. This fails:

  pg_dump -Fc -E UTF8 -p 5432  latin1test | pg_restore -p 5433 -d template1 -C

(5432 is 8.1, 5433 is 8.3, both with locale ru_RU.UTF-8;
createdb -E latin1 latin1test)

But if I create the DB beforehand (with correct encoding) and then
dump/restore without using -C, it works fine:

  createdb -p 5433 latin1test
  pg_dump -Fc -p 5432  latin1test | pg_restore -p 5433 -d latin1test

In that case I do not even need to specify -E. Seems that
pg_dump/pg_restore are clever enough to detect encodings and necessary
conversions.

So this seems to be the cleanest approach to me, and it's free of
hacks. pg_restore restores the correct owner of the DB, so calling
createdb as the DB superuser does not harm.

Thanks,

Martin
--
Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: Recommended approach for upgrading DBs with nonmatching encodings
Next
From: Tom Lane
Date:
Subject: Re: Recommended approach for upgrading DBs with nonmatching encodings