Re: [HACKERS] ECPG and bytea - Mailing list pgsql-interfaces

From Joe Conway
Subject Re: [HACKERS] ECPG and bytea
Date
Msg-id 3EFB2792.8080807@joeconway.com
Whole thread Raw
In response to ECPG and bytea  (Lee Kindness <lkindness@csl.co.uk>)
List pgsql-interfaces
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




pgsql-interfaces by date:

Previous
From: Lee Kindness
Date:
Subject: ECPG and bytea
Next
From: Nicolás Alvarez
Date:
Subject: libpq++ on sco openserver