Re: [GENERAL] bytea corruption?

2009-08-23 Thread Nathan Jahnke
thank you very much, all. i was able to insert my data and get it back out with a matching hash. my problems were caused by confusion going between plperlu - which has the bytea storage explicit custom encoding requirement - and regular perl using dbd::pg - which does not as long as the data type i

Re: [GENERAL] bytea corruption?

2009-08-23 Thread Colin Streicher
I'm probably a little late to this discussion, but I have had issues before with BYTEA in postgres before as well, this is what I found worked. use Digest::MD5; use DBI qw(:sql_types); use DBD::Pg qw(:pg_types); sub InsertBin($$$) { my ( $dbh, $md5sum, $filename ) = @_;

Re: [GENERAL] bytea corruption?

2009-08-22 Thread Daniel Verite
Nathan Jahnke wrote: > thanks for your help. unfortunately i'm still getting corruption on > this particular data (available at > http://nate.quandra.org/data.bin.0.702601051229191 ) even with these > changes: > > # ./bytea.pl > Argument "DBD::Pg::PG_BYTEA" isn't numeric in subroutine ent

Re: [GENERAL] bytea corruption?

2009-08-22 Thread Nathan Jahnke
wrong reply-address; please disregard the last message from me. thanks for your help. unfortunately i'm still getting corruption on this particular data (available at http://nate.quandra.org/data.bin.0.702601051229191 ) even with these changes: # ./bytea.pl Argument "DBD::Pg::PG_BYTEA" isn't num

Re: [GENERAL] bytea corruption?

2009-08-22 Thread Daniel Verite
Nathan Jahnke wrote: > good catch - it's because i'm used to working in plperlu. > unfortunately commenting out those lines makes no difference for this > particular data (that i linked in my original email); it's still > corrupted: Don't remove both: remove only the custom decoding. It'

Re: [GENERAL] bytea corruption?

2009-08-21 Thread Nathan Jahnke
good catch - it's because i'm used to working in plperlu. unfortunately commenting out those lines makes no difference for this particular data (that i linked in my original email); it's still corrupted: # ./bytea.pl 37652cf91fb8d5e41d3a90ea3a22ea61 != ce3fc63b88993af73fb360c70b7ec965 nathan O

Re: [GENERAL] bytea corruption?

2009-08-21 Thread Tim Landscheidt
Nathan Jahnke wrote: > [...] > my $encodeddata = $data; > $encodeddata =~ s!(\\|[^ -~])!sprintf("\\%03o",ord($1))!ge; #prepare > data for bytea column storage > [...] > my $insert_sth = $connection->prepare('insert into testtable (data) > values (?) returning id'); > $insert_sth->execute($encod

[GENERAL] bytea corruption?

2009-08-21 Thread Nathan Jahnke
got some binary data that changes when i insert and retrieve it later from bytea column: http://nate.quandra.org/data.bin.0.702601051229191 running 8.3 on debian 5.0. example: root=# create database testdb; CREATE DATABASE root=# \c testdb You are now connected to database "testdb". testdb=# cr