Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1afq8s-00041K-NZ for pgsql-interfaces@arkaria.postgresql.org; Tue, 15 Mar 2016 14:40:15 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1afq8s-00027e-AF for pgsql-interfaces@arkaria.postgresql.org; Tue, 15 Mar 2016 14:40:14 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1afq8r-00024M-1n for pgsql-interfaces@postgresql.org; Tue, 15 Mar 2016 14:40:13 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1afq8n-0008Pq-3z for pgsql-interfaces@postgresql.org; Tue, 15 Mar 2016 14:40:12 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id A738720847 for ; Tue, 15 Mar 2016 10:40:07 -0400 (EDT) Received: from web2 ([10.202.2.212]) by compute6.internal (MEProxy); Tue, 15 Mar 2016 10:40:07 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.fm; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=WMN6RFeLvlWngBOf7qsY+IVzucY=; b=RYCjVW zfbgmEAp/lnk1x1jVPILDRCUmGc90V6LdKBUzZKY/PQOYmRND7Z5RM+kW6x8KMJM YvuU7dhRZGaqH8C9aNwOf57jaOP9dfSLpaxveypaXBfOxSxVJW6eAFbpXIVCMJh1 gpX8JKgJXRiSZdf2p3eiDOL5p6POHvJAGPD+4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=WMN6RFeLvlWngBO f7qsY+IVzucY=; b=POoYnYRr979Cx8fxjGEK80tMChDd+/ThroOoljn+5mFVboq a/c8bmuvcKBq5Nm/HkklklilGrrvMRpJUuvvsDrs26XNtp1wxMEYodTMC3va9dQK w5nnZ+GHAcOFuwMiQrLhoNPZDXbC3N2qOrqM2QDZ5J6fwuVZVXs/NCmzY89o= Received: by web2.nyi.internal (Postfix, from userid 99) id 77D705404BD; Tue, 15 Mar 2016 10:40:07 -0400 (EDT) Message-Id: <1458052807.2085089.549773330.2CD59643@webmail.messagingengine.com> X-Sasl-Enc: 0rnvTn4gXTbiMfZXd2QD2ad9KbjEyDg2z5IDqcuJFPyZ 1458052807 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 In-Reply-To: <18018.1458050231@sss.pgh.pa.us> References: <1458049871.2074609.549741642.32C1352A@webmail.messagingengine.com> <18018.1458050231@sss.pgh.pa.us> Subject: Re: libpq - characterset encoding error from selecting BYTEA Date: Tue, 15 Mar 2016 22:40:07 +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 On Tue, Mar 15, 2016, at 09:57 PM, Tom Lane wrote: > > 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" > > Given the way the complaint is phrased, the problem is with data going > *to* the server, not *from* the server. I don't think the returned bytea > is your issue at all; it must be either in the SQL query string or the > parameter values being sent. Probably you should review how you're > setting up the parameter strings. Thanks a lot for your always prompt and professional help! I must have made the unforgivable mistake - miss using temporary, like so: std::ostringstream oss1,oss2; oss1 << 5; oss2 << 6; const char *pValues[]={oss1.str().c_str(),oss2.str().c_str()}; PGresult *r=PQexecParams(conn,"SELECT c3 FROM t1 WHERE c1=$1 AND c2=$2",2,NULL,pValues,NULL,NULL,1); Humm... Maybe it is my compiler's issue. Maybe I should take a break now. Anyway, the error seems to be gone with the following slightly modified version: std::ostringstream oss1,oss2; oss1 << 5; oss2 << 6; std::string s1(oss1.str()),s2(oss2.str()); const char *pValues[]={s1.c_str(),s2.c_str()}; PGresult *r=PQexecParams(conn,"SELECT c3 FROM t1 WHERE c1=$1 AND c2=$2",2,NULL,pValues,NULL,NULL,1); 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