pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
ECPG and bytea
2+ messages / 2 participants
[nested] [flat]

* ECPG and bytea
@ 2003-06-26 16:37 Lee Kindness <lkindness@csl.co.uk>
  2003-06-26 17:04 ` Re: [HACKERS] ECPG and bytea Joe Conway <mail@joeconway.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Lee Kindness @ 2003-06-26 16:37 UTC (permalink / raw)
  To: pgsql-hackers@postgresql.org; pgsql-interfaces; +Cc: Lee Kindness <lkindness@csl.co.uk>

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...

Thanks, L.



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: [HACKERS] ECPG and bytea
  2003-06-26 16:37 ECPG and bytea Lee Kindness <lkindness@csl.co.uk>
@ 2003-06-26 17:04 ` Joe Conway <mail@joeconway.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Joe Conway @ 2003-06-26 17:04 UTC (permalink / raw)
  To: Lee Kindness <lkindness@csl.co.uk>; +Cc: pgsql-hackers@postgresql.org; 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





^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2003-06-26 17:04 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-06-26 16:37 ECPG and bytea Lee Kindness <lkindness@csl.co.uk>
2003-06-26 17:04 ` Joe Conway <mail@joeconway.com>

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