If this is DBI
, you can set the maximum buffer of your database handle to your desired limit:
$dbh->{LongReadLen} = 10485760; # 10 MB
From the DBI
FAQ:
How do I handle BLOB data with DBI?
Handling BLOB data with the DBI is
very straight-forward. BLOB columns
are specified in a SELECT statement as
per normal columns. However, you also
need to specify a maximum BLOB size
that the database handle can
fetch using the LongReadLen attribute.
For example:
### $dbh is a connected database handle
$sth = $dbh->prepare( "SELECT blob_column FROM blobby_table" );
$sth->execute; would fail.
### $dbh is a connected database handle
### Set the maximum BLOB size...
$dbh->{LongReadLen} = 16384; ### 16Kb...Not much of a BLOB!
$sth = $dbh->prepare( "..." );
would succeed provided no column
values were larger than the specified
value.
If the BLOB data is longer than the
value of LongReadLen, then an error
will occur. However, the DBI provides
an additional piece of functionality
that will automatically truncate the
fetched BLOB to the size of
LongReadLen if it is longer. This does
not cause an error to occur, but may
make your fetched BLOB data useless.
This behaviour is regulated by the
LongTruncOk attribute which is
defaultly set to a false value ( thus
making overlong BLOB fetches fail ).
### Set BLOB handling such that it's 16Kb and can be truncated
$dbh->{LongReadLen} = 16384;
$dbh->{LongTruncOk} = 1;
Truncation of BLOB data may not be a
big deal in cases where the BLOB
contains run-length encoded data, but
data containing checksums at the end,
for example, a ZIP file, would be
rendered useless.