Unix Technical Forum

Re: v7.4 pg_dump(all) need to encode from SQL_ASCII to UTF8

This is a discussion on Re: v7.4 pg_dump(all) need to encode from SQL_ASCII to UTF8 within the Pgsql General forums, part of the PostgreSQL category; --> I'm not sure if you're saying I should ignore these errors... I'm using dumps from DB airaburst. >postgres=# \l ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-10-2008, 12:20 AM
Ralph Smith
 
Posts: n/a
Default Re: v7.4 pg_dump(all) need to encode from SQL_ASCII to UTF8

I'm not sure if you're saying I should ignore these errors...

I'm using dumps from DB airaburst.


>postgres=# \l

List of databases
Name | Owner | Encoding
------------+----------+-----------
airburst | root | SQL_ASCII
lt_dev1 | postgres | UTF8
lt_dev2 | postgres | UTF8
lt_reports | postgres | UTF8
postgres | postgres | UTF8
template0 | postgres | UTF8
template1 | postgres | UTF8
(7 rows)

============================================
Looking at the dump of one table there...

--
-- PostgreSQL database dump
--

-- Started on 2008-02-25 12:28:48 PST

SET client_encoding = 'UTF8';
SET standard_conforming_strings = off;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET escape_string_warning = off;

SET search_path = public, pg_catalog;

SET default_tablespace = '';

SET default_with_oids = false;

--
-- TOC entry 1455 (class 1259 OID 20378)
-- Dependencies: 1839 2
-- Name: board_posts; Type: TABLE; Schema: public; Owner: airburst;
Tablespace:

============================================
The error I get on trying to import it.


postgres@flexo:~/WORKING_DATA/airburst_tables$ psql lt_dev1 -f ./
table_board_posts.sql
SET
SET
SET
SET
SET
SET
SET
SET
CREATE TABLE
ALTER TABLE
psql:./table_board_posts.sql:248: ERROR: invalid byte sequence for
encoding "UTF8": 0x91
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".
CONTEXT: COPY board_posts, line 8
CREATE INDEX

Thank you!



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-10-2008, 12:20 AM
Tom Lane
 
Posts: n/a
Default Re: v7.4 pg_dump(all) need to encode from SQL_ASCII to UTF8

Ralph Smith <smithrn@washington.edu> writes:
> I'm not sure if you're saying I should ignore these errors...


No, not at all.

> I'm using dumps from DB airaburst.


Doesn't look like that --- you have

> Name | Owner | Encoding
> ------------+----------+-----------
> airburst | root | SQL_ASCII


but the dump contains

> SET client_encoding = 'UTF8';


which indicates that it came from a database that claimed to have UTF8
encoding. (Hmm .... although it's just barely possible that you have
PGCLIENTENCODING set in pg_dump's environment?)

> psql:./table_board_posts.sql:248: ERROR: invalid byte sequence for
> encoding "UTF8": 0x91


In any case, this failure is pretty strong evidence that what is in the
dump is actually *not* UTF8 data, or at least not all of it is. (I'd bet
on this particular value being in some LATINn encoding.) What you're
going to need to do is figure out exactly what encoding the data really
has. If you're lucky and it's all the same encoding, you can adjust it
to UTF8 by running the dump file through iconv, or just edit the SET
client_encoding command in the dump to match the true encoding (then
PG will take care of converting it to UTF8 during the load).

If you're not lucky, you have a mismash of differently encoded data,
and I'm afraid you're in for some unpleasant tedium getting it all into
one encoding.

The reason you're suffering this pain is that 7.x was not very good
about checking or enforcing encoding validity. Current PG is much
stricter; cleaning up the data will cost you some pain now but it'll be
a good investment in the long run.

Alternatively, if you don't particularly *care* about encoding issues
and feel that everything was working fine before, you can create your
new DB with SQL_ASCII encoding (which actually means "no known
encoding") and PG will be just as lax as it was before. But if you want
to say that the database uses UTF8 encoding, you need to present validly
encoded data.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:20 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com