question on plain pg_dump file usage

Started by Zwettler Markus (OIZ)over 1 year ago7 messagesgeneral
Jump to latest
#1Zwettler Markus (OIZ)
Markus.Zwettler@zuerich.ch

I have to do an out-of-place Postgres migration from PG12 to PG16 using:

pg_dump -F p -f dump.sql ...
sed -i "s/old_name/new_name/g"
psql -f dump.sql ...

Both databases are on UTF-8.

I wonder if there could be character set conversion errors here, as the data is temporarily written to a plain text file.

Thanks, Markus

#2Ron
ronljohnsonjr@gmail.com
In reply to: Zwettler Markus (OIZ) (#1)
Re: question on plain pg_dump file usage

On Tue, Sep 17, 2024 at 8:22 AM Zwettler Markus (OIZ) <
Markus.Zwettler@zuerich.ch> wrote:

I have to do an out-of-place Postgres migration from PG12 to PG16 using:

pg_dump -F p -f dump.sql …

sed -i "s/old_name/new_name/g"

psql -f dump.sql …

Both databases are on UTF-8.

I wonder if there could be character set conversion errors here, as the
data is temporarily written to a plain text file.

Why must it be a plain text dump instead of a custom or directory dump?
Restoring to a new (and differently-named( database is perfectly doable.

--
Death to <Redacted>, and butter sauce.
Don't boil me, I'm still alive.
<Redacted> crustacean!

#3Zwettler Markus (OIZ)
Markus.Zwettler@zuerich.ch
In reply to: Ron (#2)
WG: [Extern] Re: question on plain pg_dump file usage

Von: Ron Johnson <ronljohnsonjr@gmail.com>
Gesendet: Dienstag, 17. September 2024 14:44
An: PG-General Mailing List <pgsql-general@postgresql.org>
Betreff: [Extern] Re: question on plain pg_dump file usage

On Tue, Sep 17, 2024 at 8:22 AM Zwettler Markus (OIZ) <Markus.Zwettler@zuerich.ch<mailto:Markus.Zwettler@zuerich.ch>> wrote:
I have to do an out-of-place Postgres migration from PG12 to PG16 using:

pg_dump -F p -f dump.sql …
sed -i "s/old_name/new_name/g"
psql -f dump.sql …

Both databases are on UTF-8.

I wonder if there could be character set conversion errors here, as the data is temporarily written to a plain text file.

Why must it be a plain text dump instead of a custom or directory dump? Restoring to a new (and differently-named( database is perfectly doable.

--
Death to <Redacted>, and butter sauce.
Don't boil me, I'm still alive.
<Redacted> crustacean!

--- Externe Email: Vorsicht mit Anhängen, Links oder dem Preisgeben von Informationen ---

Because I can simply change the application from the old to the new structure then.

-Regards, Markus

#4Greg Sabino Mullane
greg@turnstep.com
In reply to: Zwettler Markus (OIZ) (#1)
Re: question on plain pg_dump file usage

On Tue, Sep 17, 2024 at 8:22 AM Zwettler Markus (OIZ) <
Markus.Zwettler@zuerich.ch> wrote:

pg_dump -F p -f dump.sql …

sed -i "s/old_name/new_name/g"

psql -f dump.sql …

Why not rename afterwards? Just "pg_dump mydb | psql -h newhost -f -" and
rename things via ALTER. Certainly much safer than a global replace via sed.

Cheers,
Greg

#5Zwettler Markus (OIZ)
Markus.Zwettler@zuerich.ch
In reply to: Zwettler Markus (OIZ) (#1)
WG: question on plain pg_dump file usage

Von: Zwettler Markus (OIZ) <Markus.Zwettler@zuerich.ch>
Gesendet: Dienstag, 17. September 2024 14:22
An: PG-General Mailing List <pgsql-general@postgresql.org>
Betreff: question on plain pg_dump file usage

I have to do an out-of-place Postgres migration from PG12 to PG16 using:

pg_dump -F p -f dump.sql ...
sed -i "s/old_name/new_name/g"
psql -f dump.sql ...

Both databases are on UTF-8.

I wonder if there could be character set conversion errors here, as the data is temporarily written to a plain text file.

Thanks, Markus

I found that the tempory plain text file is also encoded in UTF-8.

There should not be any problem so. Agreed?

$ file -bi dump.sql
text/plain; charset=utf-8

#6Tom Lane
tgl@sss.pgh.pa.us
In reply to: Zwettler Markus (OIZ) (#1)
Re: question on plain pg_dump file usage

"Zwettler Markus (OIZ)" <Markus.Zwettler@zuerich.ch> writes:

I have to do an out-of-place Postgres migration from PG12 to PG16 using:
pg_dump -F p -f dump.sql ...
sed -i "s/old_name/new_name/g"
psql -f dump.sql ...

Both databases are on UTF-8.

I wonder if there could be character set conversion errors here, as the data is temporarily written to a plain text file.

The dump script will include a "SET client_encoding" command to
prevent that.

regards, tom lane

#7Adrian Klaver
adrian.klaver@aklaver.com
In reply to: Ron (#2)
Re: question on plain pg_dump file usage

On 9/17/24 05:43, Ron Johnson wrote:

On Tue, Sep 17, 2024 at 8:22 AM Zwettler Markus (OIZ)
<Markus.Zwettler@zuerich.ch <mailto:Markus.Zwettler@zuerich.ch>> wrote:

Why must it be a plain text dump instead of a custom or directory dump?
Restoring to a new (and differently-named( database is perfectly doable.

Because of this:

sed -i "s/old_name/new_name/g"

--
Death to <Redacted>, and butter sauce.
Don't boil me, I'm still alive.
<Redacted> crustacean!

--
Adrian Klaver
adrian.klaver@aklaver.com