Subject: | Non-graceful handling of lack of support of 64-bit integers |
Version 0.07 of the Net::MySQL module does not handle non-existing support of 64-bit integers gracefully.
My test environment is as follows:
$Net::MySQL::VERSION : 0.07
perl -v : v5.6.1 for i386-openbsd
uname -a : OpenBSD <hostname> 3.2 GENERIC#25 i386
On this platform the perl binary does not seem to support 'long long' or 'quad' (64-bit) integer types. This means that the following code will fail fatally:
unpack('Q', $data, $pos, $len);
And this (more or less) is what's done in the module in the sub _get_field_length() (on lines 562 through 570):
else {
my $length = unpack 'Q', substr(
$self->{packet},
$self->{position},
UNSIGNED_QUAD_LENGTH
);
$self->{position} += UNSIGNED_QUAD_LENGTH;
return $length;
}
Since this (getting long long header fields) is something that often happens when communicating with a MySQL server, it makes it very hard to use the Net::MySQL module. Since the DBD::mysqlPP driver is essentially a simple DBI driver using the Net::MySQL module for most functionality, it makes it very hard to use that as well.
I suggest that the first fix could be to simply test for the possibility of using 'Q' with unpack (such as through an eval{} statement) and then, when the need arises, _gracefully_ fail with an appropriate error message (so that the DBD::mysqlPP driver could function as a DBI driver is supposed to do).
A more long term solution would have to include some sort of "pure perl" support for 64-bit integers and incorporation with the Net::MySQL module. This would most certainly be in line with the original authors wish to create "pure perl" modules.