Thursday, June 2, 2011

ERROR: invalid byte sequence for encoding "UTF8": 0xf1612220


I was transferring data from Postgresql 8.1 to Postgresql 8.3 using pg_dump and pg_restore.
During the resotre process, I got the following error

pg_restore: [archiver (db)] Error from TOC entry 2764; 0 29708702 TABLE DATA tab_originaldata postgres
pg_restore: [archiver (db)] COPY failed: ERROR:  invalid byte sequence for encoding "UTF8": 0xf1612220
HINT:  This error can also happen if the byte sequence does not match the encoding expected by the server, which is controlled by "client_encoding".

I found that data have been restored succesfully for all tables except tab_originaldata for the above error.

I made a csv data file of the table from Postgresql 8.1.

copy tab_originaldata to '/tmp/tab_originaldata.csv' delimiter '|'  csv;

I imported that data in Postgresql 8.3 as follows:

show client_encoding ;
(1 row)
 set client_encoding to 'latin1';
copy tab_originaldata FROM '/tmp/tab_originaldata.csv' delimiter '|'  csv;

Data imported successfully.

I took backup from Postgresql 8.3 and restored in the same server to check whether the restoration was successful.

Leave a Reply