Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1afpNr-0001UV-8C for pgsql-interfaces@arkaria.postgresql.org; Tue, 15 Mar 2016 13:51:39 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1afpNq-0003tN-9S for pgsql-interfaces@arkaria.postgresql.org; Tue, 15 Mar 2016 13:51:38 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1afpNY-0003Ya-17 for pgsql-interfaces@postgresql.org; Tue, 15 Mar 2016 13:51:20 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1afpNQ-0003FF-7z for pgsql-interfaces@postgresql.org; Tue, 15 Mar 2016 13:51:18 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 7D3DE20AC4 for ; Tue, 15 Mar 2016 09:51:11 -0400 (EDT) Received: from web2 ([10.202.2.212]) by compute2.internal (MEProxy); Tue, 15 Mar 2016 09:51:11 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.fm; h= content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=sJM XwRg0fj5VGemvtD6E2wjURXU=; b=dGSC05IXw8ffFbIFOeEt5FicoXcwgjSYacU J7du9ZQ9EIJD/5dNQzjB9kDDVhoT562hDIRlR0vQa5fxqT0roffBQoYYzPe+Wbu2 B6uo2uDA10qBefZwZ64dLh4oJ/KiOplwx5P3yd9NPhVFAujmseSBtTucEUvb84Kg camQkRT0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-sasl-enc :x-sasl-enc; s=smtpout; bh=sJMXwRg0fj5VGemvtD6E2wjURXU=; b=hUuP1 or9s6GamwoSOoVebe4tD8MjkKnIi20X2i2qw02bPn9xP9f2DLFOBPCXBk4s7LjEt SjBmxbQ+Q0OsmShErO6OnIBY/lfOBAX2B0PEkKbbln+cVVzrgcJekdOh9wWnuN4T yaq2p3+QiZaSnSIlFiqyiKpR/cOTh1Gpqxf/u4= Received: by web2.nyi.internal (Postfix, from userid 99) id 4719D5404BD; Tue, 15 Mar 2016 09:51:11 -0400 (EDT) Message-Id: <1458049871.2074609.549741642.32C1352A@webmail.messagingengine.com> X-Sasl-Enc: /t0n/tzHyp4igGw30TaTA4CQUZ70SdO+pXQUjkuxQ/k3 1458049871 From: CN To: pgsql-interfaces@postgresql.org MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain X-Mailer: MessagingEngine.com Webmail Interface - ajax-872772a7 Subject: libpq - characterset encoding error from selecting BYTEA Date: Tue, 15 Mar 2016 21:51:11 +0800 X-Pg-Spam-Score: -2.5 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-interfaces Precedence: bulk Sender: pgsql-interfaces-owner@postgresql.org 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