Re: [HACKERS] ECPG and bytea

From: Joe Conway <mail(at)joeconway(dot)com>
To: Lee Kindness <lkindness(at)csl(dot)co(dot)uk>
Cc: pgsql-hackers(at)postgresql(dot)org, pgsql-interfaces(at)postgresql(dot)org
Subject: Re: [HACKERS] ECPG and bytea
Date: 2003-06-26 17:04:18
Message-ID: 3EFB2792.8080807@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers 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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2003-06-26 17:08:21 Re: Two weeks to feature freeze
Previous Message Kevin Jacobs 2003-06-26 17:04:17 Re: PlPython

Browse pgsql-interfaces by date

  From Date Subject
Next Message Michael Meskes 2003-06-26 19:07:30 Re: ECPG thread success (kind of) on Linux
Previous Message Lee Kindness 2003-06-26 16:37:46 ECPG and bytea