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

Hi monks

I am fetching a record from a mysql database. if I run the code on Perl v5.6.2, code runs fine and fetches it. But if I am running on Perl v5.8.8, code thorws error - "Bus Error (core dumped)"

This is the code I am using.
#!/usr/bin/perl # PERL MODULES use DBI; use DBD::mysql; # HTTP HEADER print "Content-type: text/html \n\n"; # CONFIG VARIABLES $platform = "mysql"; $database = "TEST"; $host = "127.0.0.1"; $port = "3306"; $tablename = "SERVICE"; $user = "guest"; $pw = "guest"; #DATA SOURCE NAME $dsn = "dbi:mysql:$database:$host:3306"; # PERL DBI CONNECT $DBIconnect = DBI->connect($dsn, $user, $pw); #my $sth = $DBIconnect->prepare(qq{select serviceprovider from PROVSER +VICE limit 1}); my $sth = $DBIconnect->prepare(qq{SELECT COUNT(*) col FROM dual WHERE +1=1}); $sth->execute(); my $ss = $sth->fetchrow(); print $ss; print "\n"; $sth->finish(); $DBIconnect->disconnect();
Please help.

Replies are listed 'Best First'.
Re: Bus Error (core dumped)
by Anonymous Monk on Sep 07, 2009 at 11:52 UTC

    Just to add further, if I try to find the module version with Perl v5.8.8,it again shows core dump error.

    With Perl v5.6.2
    $/usr/bin/perl -MDBD::mysql -e 'print "$DBD::mysql::VERSION\n"' 4.005
    With Perl v5.6.2
    $/usr/bin/perl -MDBD::mysql -e 'print "$DBD::mysql::VERSION\n"' Bus Error

      The "Bus Error" means that likely something is wrong with the compiled parts of Perl. A most likely candidate is a mismatch between the Perl version and the version for which the extension DBD::mysql was compiled, or the version of DBD::mysql and the version of the MySQL client libraries against which the DBD was compiled. There is little we can do from afar - your best venue is to look at what (you) changed within the system and how you installed DBD::mysql into the 5.6.2 Perl.

      A common, easy to detect pitfall would be if you copied the DBD::mysql driver for Perl 5.8.x to the directories for Perl 5.6.2 - that cannot work.

      This might also have happened if you recompiled and reinstalled the driver and have shared extension directories between 5.8.x and 5.6.x.

      Look at @INC for both Perls:

      perl -v perl -le 'print for @INC';