From: Joe Conway <mail@joeconway.com>
To: Lee Kindness <lkindness@csl.co.uk>
Cc: pgsql-hackers@postgresql.org
Cc: pgsql-interfaces@postgresql.org
Subject: Re: [HACKERS] ECPG and bytea
Date: Thu, 26 Jun 2003 10:04:18 -0700
Message-ID: <3EFB2792.8080807@joeconway.com> (raw)
In-Reply-To: <16123.8538.839179.120406@kelvin.csl.co.uk>
References: <16123.8538.839179.120406@kelvin.csl.co.uk>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: mail@joeconway.com, lkindness@csl.co.uk, pgsql-hackers@postgresql.org
Subject: Re: [HACKERS] ECPG and bytea
In-Reply-To: <3EFB2792.8080807@joeconway.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox