Обсуждение: Encoding problem using pg_dumpall

Поиск
Список
Период
Сортировка

Encoding problem using pg_dumpall

От
"Moshe Ben-Shoham"
Дата:

Hi,

 

I have a database with encoding UTF-8 installed on Windows, and I try to dump it using pg_dumpall, on the machine on which the database is installed. I get the following error message:

 

C:\Program Files\PostgreSQL\8.3\bin>pg_dumpall -U admint > c:\temp\dbdump.sql

pg_dump: SQL command failed

pg_dump: Error message from server: ERROR:  character 0xd595 of encoding "UTF8" has no equivalent in "WIN1252"

pg_dump: The command was: COPY public.cms_history_properties (structure_id, propertydef_id, property_mapping_id, property_mapping_type, property_value, publish_tag) TO stdout;

pg_dumpall: pg_dump failed on database "opencms", exiting

 

it probably means that some UTF-8 characters cannot be represented in WIN1252 which is the encoding of the output file.

 

Is there any solution to this problem?

 

Thanks,

Moshe Ben Shoham.



The information contained in this message is proprietary to the sender, protected from disclosure, and may be privileged. The information is intended to be conveyed only to the designated recipient(s) of the message. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, use, distribution or copying of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please notify us immediately by replying to the message and deleting it from your computer. Thank you.





************************************************************************************
This footnote confirms that this email message has been scanned by
PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses.
************************************************************************************


Re: Encoding problem using pg_dumpall

От
Tom Lane
Дата:
"Moshe Ben-Shoham" <mosheb@nexperience.com> writes:
> C:\Program Files\PostgreSQL\8.3\bin>pg_dumpall -U admint >
> c:\temp\dbdump.sql
> pg_dump: SQL command failed
> pg_dump: Error message from server: ERROR:  character 0xd595 of encoding
> "UTF8" has no equivalent in "WIN1252"

Apparently you have WIN1252 set as the default client encoding, probably
via an environment variable or locale setting.  Either get rid of it,
or override it by including "-E UTF8" in the pg_dump command.

(Hmm, actually it looks like pg_dumpall hasn't got a -E switch,
which seems like an oversight.  So you need to fix your locale,
or else use pg_dump directly.)

            regards, tom lane

Re: Encoding problem using pg_dumpall

От
Magnus Hagander
Дата:
Tom Lane wrote:
> "Moshe Ben-Shoham" <mosheb@nexperience.com> writes:
>> C:\Program Files\PostgreSQL\8.3\bin>pg_dumpall -U admint >
>> c:\temp\dbdump.sql
>> pg_dump: SQL command failed
>> pg_dump: Error message from server: ERROR:  character 0xd595 of encoding
>> "UTF8" has no equivalent in "WIN1252"
>
> Apparently you have WIN1252 set as the default client encoding, probably
> via an environment variable or locale setting.  Either get rid of it,
> or override it by including "-E UTF8" in the pg_dump command.
>
> (Hmm, actually it looks like pg_dumpall hasn't got a -E switch,
> which seems like an oversight.  So you need to fix your locale,
> or else use pg_dump directly.)

IIRC, you can't set the windows console to be UTF8. Thus, your option is
to switch to using pg_dump and use -E UTF8 on that one.

//Magnus

Re: Encoding problem using pg_dumpall

От
Tom Lane
Дата:
Magnus Hagander <magnus@hagander.net> writes:
> Tom Lane wrote:
>> (Hmm, actually it looks like pg_dumpall hasn't got a -E switch,
>> which seems like an oversight.  So you need to fix your locale,
>> or else use pg_dump directly.)

> IIRC, you can't set the windows console to be UTF8.

Ugh.  That seems to raise the priority of having a -E switch quite
a lot.  I'm surprised no one has complained of this before.

I think it should be possible to work around it by setting
PGCLIENTENCODING in the environment, but I dunno how to do that
on Windows.

            regards, tom lane

Re: Encoding problem using pg_dumpall

От
Magnus Hagander
Дата:
Tom Lane wrote:
> Magnus Hagander <magnus@hagander.net> writes:
>> Tom Lane wrote:
>>> (Hmm, actually it looks like pg_dumpall hasn't got a -E switch,
>>> which seems like an oversight.  So you need to fix your locale,
>>> or else use pg_dump directly.)
>
>> IIRC, you can't set the windows console to be UTF8.
>
> Ugh.  That seems to raise the priority of having a -E switch quite
> a lot.  I'm surprised no one has complained of this before.

Most people use pg_dump. I know I recommend everbody to use pg_dump to
dump the database, because you can use -Fc. Then just use pg_dumpall to
dump the globals, and they normally don't have any non-ascii in them.


> I think it should be possible to work around it by setting
> PGCLIENTENCODING in the environment, but I dunno how to do that
> on Windows.

That's a simple
set PGCLIENTENCODING=UTF8

//Magnus