X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id 05C6C30FFEC; Thu, 26 Jun 2003 17:08:35 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 92911-01; Thu, 26 Jun 2003 14:08:24 -0300 (ADT) Received: from joeconway.com (66-146-172-86.skyriver.net [66.146.172.86]) by svr1.postgresql.org (Postfix) with ESMTP id 5F6F630FFCE; Thu, 26 Jun 2003 14:08:23 -0300 (ADT) Received: from [206.19.64.3] (account jconway HELO joeconway.com) by joeconway.com (CommuniGate Pro SMTP 4.0.6) with ESMTP-TLS id 1813119; Thu, 26 Jun 2003 09:39:42 -0700 Message-ID: <3EFB2792.8080807@joeconway.com> Date: Thu, 26 Jun 2003 10:04:18 -0700 From: Joe Conway User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.3) Gecko/20030312 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Lee Kindness Cc: pgsql-hackers@postgresql.org, pgsql-interfaces@postgresql.org Subject: Re: [HACKERS] ECPG and bytea References: <16123.8538.839179.120406@kelvin.csl.co.uk> In-Reply-To: <16123.8538.839179.120406@kelvin.csl.co.uk> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Archive-Number: 200306/81 X-Sequence-Number: 4292 Lee Kindness wrote: > Guys, surely some one's done this before? I've tried using > PQescapeBytea too, but still get (slightly) different output. If I try > and insert "\x02\x01\x02\x03\x04hello\x05\x64\x99\x45" I get (int > values of chars printed): > > INSERT: 2 1 2 3 4 104 101 108 108 111 5 100 -103 69 > SELECT: 2 1 2 3 4 104 101 108 108 111 5 100 92 50 51 49 69 > > hoping someone has a quick answer... if not I'll post a full source > example and look into it more... > I don't know much about ecpg, but here are some thoughts: regression=# select x'99'::int; int4 ------ 153 (1 row) regression=# select chr(-103) = chr(153); ?column? ---------- t (1 row) So the insert looks correct but affected by signed vs unsigned char somehow. As far as the select goes, I'm wondering if your database is using UTF8 encoding or something like that. That would explain a high bit character getting converted to 4 bytes, I think. HTH, Joe