Why don't I get a LATIN1 encoding here with SET ENCODING?

From: Bryce Nesbitt <bryce2(at)obviously(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Why don't I get a LATIN1 encoding here with SET ENCODING?
Date: 2009-11-04 01:13:21
Message-ID: 4AF0D531.5080309@obviously.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="#ffffff" text="#000000">
I'm tracking another bug, but wanted to verify stuff on the command
line.&nbsp; I can't figure out why this did not work:<br>
<br>
# psql dblack3-deleteme<br>
Welcome to psql 8.3.8 (server 8.3.4), the PostgreSQL interactive
terminal.<br>
dblack3-deleteme=&gt; create table bryce1 (key int,val1 text,val2
bytea);<br>
dblack3-deleteme=&gt; \encoding<br>
UTF8<br>
dblack3-deleteme=&gt; SET CLIENT_ENCODING TO 'LATIN1';<br>
SET<br>
dblack3-deleteme=&gt; \encoding<br>
LATIN1<br>
dblack3-deleteme=&gt; insert into bryce1 values(1,2,'test\177');<br>
INSERT 0 1<br>
<br>
dblack3-deleteme=&gt; insert into bryce1 values(1,2,'test\375');<br>
ERROR:&nbsp; invalid byte sequence for encoding "UTF8": 0xfd<br>
HINT:&nbsp; This error can also happen if the byte sequence does not match
the encoding expected by the server, which is controlled by
"client_encoding".<br>
<br>
dblack3-deleteme=&gt; insert into bryce1 values(1,2,'test\200');<br>
ERROR:&nbsp; invalid byte sequence for encoding "UTF8": 0x80<br>
HINT:&nbsp; This error can also happen if the byte sequence does not match
the encoding expected by the server, which is controlled by
"client_encoding".<br>
<br>
<br>
------------------------------------------------------<br>
<br>
The underlying problem is a version upgrade of DBI drivers has broken
some binary objects we used.<br>
For the binary data:<br>
<span class="Apple-style-span"
style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"><span
class="Apple-style-span"
style="border-collapse: collapse; font-family: arial,sans-serif,'Arial Unicode MS'; font-size: 13px;">
<div><font face="'courier new', monospace">&lt;12&gt;&lt;1&gt;5&lt;0&gt;&lt;0&gt;&lt;0&gt;&lt;4&gt;FOO1</font></div>
<div><font face="'courier new', monospace">&lt;10&gt;&lt;205&gt;&lt;0&gt;&lt;0&gt;&lt;0&gt;&lt;4&gt;FOO2</font></div>
<div><font face="'courier new', monospace"><br>
</font></div>
<font face="'courier new', monospace">Going in like so:</font><br>
<div class="im" style="color: rgb(80, 0, 80);">
<div><font face="'courier new', monospace">$sth-&gt;bind_param($index++,
$data, {pg_type =&gt; $SQLDb::PG_BYTEA});</font></div>
<div><font face="'courier new', monospace"><br>
</font></div>
</div>
<div><font face="'courier new', monospace">It now comes out munged:</font></div>
<div><span style="font-family: 'courier new',monospace;">\012 \001 5
\000 \000 \000 \004 FOO1</span></div>
<div><font face="'courier new', monospace">\010 \377 \000 \000 \000
\004 FOO</font></div>
</span></span>
</body>
</html>

Attachment Content-Type Size
unknown_filename text/html 2.8 KB

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Craig Ringer 2009-11-04 02:29:35 Re: Why don't I get a LATIN1 encoding here with SET ENCODING?
Previous Message Jasen Betts 2009-11-02 10:11:23 Re: PostgreSQL Security/Roles/Grants