From: Bryce Nesbitt <bryce2@obviously.com>
To: pgsql-sql@postgresql.org
Subject: Why don't I get a LATIN1 encoding here with SET ENCODING?
Date: Tue, 03 Nov 2009 17:13:21 -0800
Message-ID: <4AF0D531.5080309@obviously.com> (raw)
<!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. 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=> create table bryce1 (key int,val1 text,val2
bytea);<br>
dblack3-deleteme=> \encoding<br>
UTF8<br>
dblack3-deleteme=> SET CLIENT_ENCODING TO 'LATIN1';<br>
SET<br>
dblack3-deleteme=> \encoding<br>
LATIN1<br>
dblack3-deleteme=> insert into bryce1 values(1,2,'test\177');<br>
INSERT 0 1<br>
<br>
dblack3-deleteme=> insert into bryce1 values(1,2,'test\375');<br>
ERROR: invalid byte sequence for encoding "UTF8": 0xfd<br>
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".<br>
<br>
dblack3-deleteme=> insert into bryce1 values(1,2,'test\200');<br>
ERROR: invalid byte sequence for encoding "UTF8": 0x80<br>
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".<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"><12><1>5<0><0><0><4>FOO1</font></div>
<div><font face="'courier new', monospace"><10><205><0><0><0><4>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->bind_param($index++,
$data, {pg_type => $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>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: bryce2@obviously.com
Subject: Re: Why don't I get a LATIN1 encoding here with SET ENCODING?
In-Reply-To: <4AF0D531.5080309@obviously.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox