agora inbox for pgsql-interfaces@postgresql.org
help / color / mirror / Atom feedFrom: CN <cnliou9@fastmail.fm>
To: pgsql-interfaces@postgresql.org
Subject: libpq - characterset encoding error from selecting BYTEA
Date: Tue, 15 Mar 2016 21:51:11 +0800
Message-ID: <1458049871.2074609.549741642.32C1352A@webmail.messagingengine.com> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-interfaces>
My understanding of this part of documentation
"operations on binary strings process the actual bytes, whereas the
processing of character strings depends on locale settings."
is that reading BYTEA column does not involve character set conversion
especially when "1", indicating binary, is passed to parameter
"resultFormat" by calling libpq function PQexecParams().
Given
CREATE TABLE t1 (
PRIMARY KEY (c1,c2),
c1 SMALLINT,
c2 SMALLINT,
c3 BYTEA
);
PGconn* first switches to "BIG5" client encoding:
PQexec(conn,"SET CLIENT_ENCODING TO BIG5");
version 1:
const char *pValues[]={"5","6"};
PGresult *r=PQexecParams(conn,"SELECT c3::BYTEA FROM t1 WHERE c1=$1 AND
c2=$2",2,NULL,pValues,NULL,NULL,1);
What is strange is that above PQexecParams() works in one portion of my
program but in another portion it yields the following error:
ERROR: character with byte sequence 0x98 0xe1 in encoding "BIG5" has no
equivalent in encoding "UTF8"
version 2:
PQgetvalue(r,0,0) returns the correct BYTEA value from this version:
PGresult *r=PQexecParams(conn,"SELECT c3::BYTEA FROM t1 WHERE c1=5 AND
c2=6",0,NULL,NULL,NULL,NULL,1);
I simply can not find any intrinsic difference between the above two
versions. Why the first version is "unstable"?
Best Regards,
CN
--
http://www.fastmail.com - Or how I learned to stop worrying and
love email again
--
Sent via pgsql-interfaces mailing list (pgsql-interfaces@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-interfaces
view thread (3+ messages) latest in thread
Message-ID: <1458049871.2074609.549741642.32C1352A@webmail.messagingengine.com>
Permalink: ../1458049871.2074609.549741642.32C1352A@webmail.messagingengine.com/
Also on: postgresql.org/message-id/1458049871.2074609.549741642.32C1352A@webmail.messagingengine.com
reply
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-interfaces@postgresql.org
Cc: cnliou9@fastmail.fm
Subject: Re: libpq - characterset encoding error from selecting BYTEA
In-Reply-To: <1458049871.2074609.549741642.32C1352A@webmail.messagingengine.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox