http://www.perlmonks.org?node_id=819455

samarzone has asked for the wisdom of the Perl Monks concerning the following question:

Problem: Same version of DBI returns different values on different servers

Description: I have a table named csresult with negative value stored in count column. When I try to fetch the value I get different results on different machines. On one machine it returns correct values, i.e. -1 but on another machine it returns the value 4294967295 (which I suppose is the number after conversing it into an unsigned value.) Similarly I get 4294967294 for -2. DBI version is same on both the machines however perl and linux versions differ. I got no help/hint on googling.

Can someone please explain this behaviour?

Different outputs are following

Mysql values/configuration (Output was same when I connected to the mysql server from both the machines) :-

<blockquote> mysql> select count from csresult where sig = '024b1680d57f61df3b3236f +0c9321ce7'; +-------+ | count | +-------+ | -1 | +-------+ 1 row in set (0.00 sec) mysql> show create table csresult\G *************************** 1. row *************************** Table: csresult Create Table: CREATE TABLE `csresult` ( `sig` varchar(32) NOT NULL default '', `count` int(10) default NULL, `results` mediumblob, `extrainfo` text, PRIMARY KEY (`sig`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 1 row in set (0.01 sec) mysql> show indexes from csresult\G *************************** 1. row *************************** Table: csresult Non_unique: 0 Key_name: PRIMARY Seq_in_index: 1 Column_name: sig Collation: A Cardinality: 204 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment: 1 row in set (0.00 sec) mysql> select version(); +------------+ | version() | +------------+ | 4.1.16-log | +------------+ 1 row in set (0.00 sec) </blockquote>

Contents of perl script(dbi-test.pl):-

#!/usr/bin/perl -w use strict; use DBI; my $dbh = DBI->connect("dbi:mysql:db:dbserver", "user", "password") or + die "could not connect\n"; my $sth = $dbh->prepare("Select count from csresult where sig = '024b1 +680d57f61df3b3236f0c9321ce7'"); $sth->execute(); while(my $data = $sth->fetchrow_hashref()) { print "count:$data->{count}\n"; }

Output on first machine:-

<blockquote>&#91;samar@malena perl&#93;$ uname -a Linux malena.XXX 2.6.18-128.el5 #1 SMP Wed Jan 21 10:41:14 EST 2009 x8 +6_64 x86_64 x86_64 GNU/Linux &#91;samar@malena perl&#93;$ perl -version This is perl, v5.8.8 built for x86_64-linux-thread-multi Copyright 1987-2006, Larry Wall Perl may be copied only under the terms of either the Artistic License + or the GNU General Public License, which may be found in the Perl 5 source ki +t. Complete documentation for Perl, including FAQ lists, should be found +on this system using "man perl" or "perldoc perl". If you have access to + the Internet, point your browser at http://www.perl.org/, the Perl Home Pa +ge. &#91;samar@malena perl&#93;$ perl -MDBI -e 'print "$DBI::VERSION\n"' 1.57 &#91;samar@malena perl&#93;$ perl dbi-test.pl count:-1 </blockquote>

Output on second machine:-

<blockquote>&#91;samar@maria perl&#93;$ uname -a Linux maria.XXX 2.6.9-22.0.1.XXX #1 SMP Mon Dec 5 17:33:30 IST 2005 x8 +6_64 x86_64 x86_64 GNU/Linux &#91;samar@maria perl&#93;$ perl -version This is perl, v5.8.3 built for x86_64-linux-thread-multi Copyright 1987-2003, Larry Wall Perl may be copied only under the terms of either the Artistic License + or the GNU General Public License, which may be found in the Perl 5 source ki +t. Complete documentation for Perl, including FAQ lists, should be found +on this system using `man perl' or `perldoc perl'. If you have access to + the Internet, point your browser at http://www.perl.com/, the Perl Home Pa +ge. &#91;samar@maria perl&#93;$ perl -MDBI -e 'print "$DBI::VERSION\n"' 1.57 &#91;samar@maria perl&#93;$ perl dbi-test.pl count:4294967295 </blockquote>

Thanks in advance