Skip Menu | You are currently an anonymous guest. | Login | Return to Main | About rt.cpan.org
 

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.

X Report information
Id: 1956
Status: resolved
Left: 0 min
Priority: 0/0
Queue: DBD-mysqlPP

Owner: Nobody
Requestors: lairdshaw [...] hotmail.com
Cc:
AdminCc:

Severity: Normal
Broken in: (no value)
Fixed in: (no value)



X History Display mode: Brief headersFull headers
#   Sun Jan 19 09:23:39 2003 guest - Ticket created  
Subject: Incorrect retrieval of binary BLOB data
[text/plain 2.2k]
The mysqlPP driver returns truncated/incorrect BLOB field data when the BLOB data is binary. It seems to be OK with text data (except for '/'s, another apparent bug.

This bug occurred with the following setups

1)
OS: Windows 95
mysql server version 3.23.54 (running on the same machine as the scripts)
Perl v5.8.0 from ActiveState
DBI version 1.30
DBD::mysqlPP version 0.03

2)
OS: Windows 95
mysql server version 3.23.54 (running on the same machine as the scripts)
Perl v5.6.1 build 633 from ActiveState
DBI version 1.32
DBD::mysqlPP version 0.03

The script that follows is a cut-down version of code provided by Ron Savage on the dbi-users mailing list.
-----Begin Demonstration code-----
use strict;
use warnings;

use DBI;

my $input_file_name = 'c:\file0003.chk';
my $rootpassword;

&do_test("mysql");
&do_test("mysqlPP");

sub do_test {
my($driver) = shift;
print "Driver: $driver\n";
my($dbh) = DBI -> connect
(
"DBI:$driver:test:127.0.0.1", 'root', $rootpassword,
{
AutoCommit => 1,
LongReadLen => 150_000,
LongTruncOk => 0,
PrintError => 0,
RaiseError => 1,
ShowErrorStatement => 1,
}
);
eval{$dbh -> do('drop table ttable')};
my($sql) = "create table ttable (b_value blob)";
$dbh -> do($sql);

$sql = 'insert into ttable (b_value) values (?)';
my($sth) = $dbh -> prepare($sql);
open(INX, $input_file_name) || die("Can't open($input_file_name): $!");
binmode INX;
print "File name: $input_file_name. \n";
print "Blob file size: ", -s INX, " bytes.\n";

my($blob);
{
local $/ = undef;
$blob = <INX>;
close INX;
}

print "Blob ram size: ", length($blob), " bytes.\n";

$sth -> execute($blob);
$sth -> finish();

$sql = 'select b_value from ttable';
$sth = $dbh -> prepare($sql);

$sth -> execute();

$blob = $sth -> fetch();
$blob = $$blob[0];

$sth -> finish();

print "Blob db size: ", length($blob), " bytes.\n";

$dbh->disconnect;
}
-----End Demonstration code-----

-----Begin Results-----
Driver: mysql
File name: c:\file0003.chk.
Blob file size: 49152 bytes.
Blob ram size: 49152 bytes.
Blob db size: 49152 bytes.
Driver: mysqlPP
File name: c:\file0003.chk.
Blob file size: 49152 bytes.
Blob ram size: 49152 bytes.
Blob db size: 49137 bytes.
-----End Results-----

Notice that the final Blob db size is not correct.
#   Fri Jan 24 06:51:21 2003 OYAMA - Correspondence added  
Subject: Re: Incorrect retrieval of binary BLOB data
[text/plain 63b]
Newest DBD::mysqlPP v0.07 were uploaded to CPAN. Please try it.
#   Fri Jan 24 06:51:23 2003 OYAMA - Status changed from 'new' to 'resolved'  
#   Fri Jan 24 06:56:12 2003 RT_System - Status changed from 'resolved' to 'open'  
#   Fri Jan 24 06:56:12 2003 OYAMA - Correspondence added  
[text/plain 130b]
> Newest DBD::mysqlPP v0.07 were uploaded to CPAN. Please try it.

mistake. It is DBD::mysqlPP v0.04
______________
Hiroyuki OYAMA
#   Fri Jan 24 06:57:35 2003 OYAMA - Status changed from 'open' to 'resolved'