DBI, BLOBS, MySQL
Christopher Jones
c.jones at ucl.ac.uk
Thu Jan 8 23:02:58 GMT 2009
I'm having issues inserting files into a BLOB field in MySQL, using
something similar to this;
binmode($filehandle);
my $file_str;
{
local( $/, undef ) ;
$file_str = <$filehandle>;
}
my $statement = "
INSERT INTO 'files' (file_name, file)
VALUES (?,?,?)
";
my $sth = $dbh->prepare($statement);
$sth->execute('my.pdf',$file_str);
The problem is that files bigger than 64K are being truncated on their
insert into the database (i.e. the maximum BLOB length in the database
is 64K). The global max_allowed_packet variable is set to 16776192, so
that doesn't seem to be the culprit, and I don't know of any other
limitations in MySQL that would limit the size of the insert.
I'm tearing my hair out with this, and after wading through countless
dead-ends I've pretty much given up!
Is it possible this is a DBI problem, or is it bound to be a MySQL
issue? Any clues, from any direction, would be very gratefully received.
Cheers,
Chris
PS Perl 5.8.8, DBI v1.607, MySQL 5.1, if that makes any difference
More information about the london.pm
mailing list