Re: DBD::Pg - BYTEA - fails for range outside chr(0)-chr(127)

2001-06-27 Thread Edmund Mergl

Alex Pilosov wrote:
 
 Oy, just when I sent it, I realised what the problem is:
 
 Please apply following patch to dbdimp.c
 
 Edmund, please, apply this patch to DBD::Pg for next release.
 


ok, on its way to CPAN.

Edmund
-- 
http://www.edmund-mergl.de
fon: +49 700 edemergl



RE: DBD::Pg - BYTEA - fails for range outside chr(0)-chr(127)

2001-06-27 Thread Alex Pilosov

I'm one to blame for the bytea support, so :)

Something is mangling chr(128) somewhere. If you do this one with
DBI_TRACE=2, you'll see: INSERT INTO test VALUES ('\\3777600')

I'm looking what's causing it...
---cut---
I'm getting core dumps when I try to use a BYTEA value with
a byte outside 0..127.

use DBI qw(SQL_BINARY);
my $dbh = DBI-connect(dbi:Pg:dbname=merlyntest, user, pass,
  { RaiseError = 1 });
$dbh-do(CREATE TABLE test (a BYTEA));
my $insert = $dbh-prepare(INSERT INTO test VALUES (?));
$insert-bind_param(1, undef, SQL_BINARY); # necessary for BYTEA
escaping
$insert-execute(fred); # works fine
$insert-execute(pack C*, 0..127); # works fine
$insert-execute(pack C*, 128); # BOMB, core dump

(I'm cutting and pasting this from a perl debugger session, so if
that's not quite it, forgive me.)

DBI version 1.18
DBD::Pg version 1.00
postgresql version 7.1.2
Perl version 5.5.3







RE: DBD::Pg - BYTEA - fails for range outside chr(0)-chr(127)

2001-06-27 Thread Alex Pilosov

Oy, just when I sent it, I realised what the problem is:

Please apply following patch to dbdimp.c

Edmund, please, apply this patch to DBD::Pg for next release.

1169c1169
 dest+=snprintf(dest, strlen(imp_sth-statement)
+ max_len + (statement - dest), %03o, *val);
---
 dest+=snprintf(dest, strlen(imp_sth-statement)
+ max_len + (statement - dest), %03o, *((unsigned char *)val));

On Wed, 27 Jun 2001, Alex Pilosov wrote:

 I'm one to blame for the bytea support, so :)
 
 Something is mangling chr(128) somewhere. If you do this one with
 DBI_TRACE=2, you'll see: INSERT INTO test VALUES ('\\3777600')
 
 I'm looking what's causing it...
 ---cut---
 I'm getting core dumps when I try to use a BYTEA value with
 a byte outside 0..127.
 
 use DBI qw(SQL_BINARY);
 my $dbh = DBI-connect(dbi:Pg:dbname=merlyntest, user, pass,
   { RaiseError = 1 });
 $dbh-do(CREATE TABLE test (a BYTEA));
 my $insert = $dbh-prepare(INSERT INTO test VALUES (?));
 $insert-bind_param(1, undef, SQL_BINARY); # necessary for BYTEA
 escaping
 $insert-execute(fred); # works fine
 $insert-execute(pack C*, 0..127); # works fine
 $insert-execute(pack C*, 128); # BOMB, core dump
 
 (I'm cutting and pasting this from a perl debugger session, so if
 that's not quite it, forgive me.)
 
 DBI version 1.18
 DBD::Pg version 1.00
 postgresql version 7.1.2
 Perl version 5.5.3