Subject: | incorrect value returned for int column |
See also <http://bugs.mysql.com/bug.php?id=18426>.
Description:
An integer column with -1 stored in it returns 4294967295 instead of -1.
The details of my setup:
Mac OS X Tiger 10.4.5 (PPC)
perl 5.8.6
DBI 1.49
DBD::mysql 3.0002_5 (vs 3.0002) (built with mysql-4.1.18 libraries)
mysql 4.1.18
It appears this bug was introduced between 3.0002 and 3.0002_1 and is still
present in 3.0002_5. I tested this on Linux and could not reproduce it there, so
it appears to be specific to Mac OS X.
How to repeat:
This script below, when run with DBD::mysql 3.0002 outputs ...
value is: -1
... but with DBD::mysql 3.0002_5 (and 3.0002_1) it prints ...
value is: 4294967295
#!/usr/bin/perl -w
use DBI;
my $dbh = DBI->connect('DBI:mysql:test', 'test');
my $table = 'DBDmysql30002_1bug';
$dbh->do("DROP TABLE IF EXISTS $table") or die $dbh->errstr;
$dbh->do("CREATE TABLE $table (value int)") or die $dbh->errstr;
$dbh->do("INSERT INTO $table VALUES (-1)") or die $dbh->errstr;
$h = $dbh->selectrow_hashref("SELECT * FROM $table");
print 'value is: ' . $h->{value} . "\n";
## cleanup
$dbh->do("DROP TABLE IF EXISTS $table") or die $dbh->errstr;
$dbh->disconnect;
1;