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

Monks-

I posted this to Class::DBI mailing list, but it doesn't seem to be making it past the moderator.

Just migrated from Debian Woody to RedHat Enterprise 4. I ran my test suites before migration and they were perfect. Now, one of my modules that uses Class::DBI is broken in and odd way on the new system.

I've isolated the problem in the following short script that uses Class::DBI to drill down into a large database. The script works fine when run from the command line, but fails with the errors show below when run through the perl debugger (perl -d test.pl). The failure is of the type "Can't bind a reference (Recode::Bioentry=HASH(0x87864a0)) at ... DBIx/ContextualFetch.pm line 52".

I'm using perl 5.8.5 DBI 1.40 and Class::DBI 3.0.1 (the working Debian system had perl 5.6.1 and CDBI 0.96, but I've reverted to CDBI 0.96 on the failing RH system and get the same results). Any thoughts?<\p>

Barry

========================================== Script ========================================== #!/usr/bin/perl + + use Recode::RecodeDB; my $recode = Recode::Recode->retrieve(21); my $bioentry = $recode->bioentry_id; my $sequence = $bioentry->biosequence; my $seq = $sequence->seq; # $seq = $recode->bioentry_id->biosequence->seq; # has the same effect print "$seq"; ========================================== Snippets from database module Recode::RecodeDB ========================================== package Recode::RecodeDB; use base 'Class::DBI'; use strict; use warnings; Recode::RecodeDB->connection('dbi:Pg:dbname=*****', '******', '********'); ... package Recode::Recode; use base 'Recode::RecodeDB'; use Local::SeqTools qw(translate); use Text::Wrap; $Text::Wrap::columns = 80; Recode::Recode->table('recodes'); Recode::Recode->columns(All => qw/recode_id bioentry_id orf1_begin orf1_end orf2_begin orf2_end frameshift/); Recode::Recode->has_a(bioentry_id => 'Recode::Bioentry'); Recode::Recode->has_many(recode_features => 'Recode::Recode_Features'); Recode::Recode->has_many(homolocodes => 'Recode::Homolocodes'); ... package Recode::Biosequence; use base 'Recode::RecodeDB'; Recode::Biosequence->table('biosequence'); Recode::Biosequence->columns('All' => qw/ bioentry_id version length alphabet seq /); Recode::Biosequence->has_a('bioentry_id' => 'Recode::Bioentry'); ... package Recode::Bioentry; use base 'Recode::RecodeDB'; Recode::Bioentry->table('bioentry'); Recode::Bioentry->columns(All => qw/bioentry_id biodatabase_id taxon_id name accession identifier division description version /); Recode::Bioentry->has_a(biodatabase_id => 'Recode::Biodatabase'); #Recode::Bioentry->has_a(taxon_id => 'Recode::Taxon'); Recode::Bioentry->has_a(taxon_id => 'Recode::Taxon_Name'); Recode::Bioentry->might_have(biosequence => 'Recode::Biosequence' => qw/ length alphabet seq /); Recode::Bioentry->has_many(comments => 'Recode::Comment'); Recode::Bioentry->has_many(recodes => 'Recode::Recode'); Recode::Bioentry->has_many(seqfeatures => 'Recode::SeqFeature'); ========================================== Errors ========================================== Can't bind a reference (Recode::Bioentry=HASH(0x87864a0)) at /usr/lib/ +perl5/site_perl/5.8.5/DBIx/ContextualFetch.pm line 52Can't bind a ref +erence (Recode::Bioentry=HASH(0x87864a0)) at /usr/lib/perl5/site_perl +/5.8.5/DBIx/ContextualFetch.pm line 52. at /usr/lib/perl5/site_perl/ +5.8.5/DBIx/ContextualFetch.pm line 52 DBIx::ContextualFetch::st::_untaint_execute('DBIx::ContextualF +etch::st=HASH(0x8786494)', 'Recode::Bioentry=HASH(0x87864a0)') called + at /usr/lib/perl5/site_perl/5.8.5/DBIx/ContextualFetch.pm line 32 DBIx::ContextualFetch::st::execute('DBIx::ContextualFetch::st= +HASH(0x8786494)', 'Recode::Bioentry=HASH(0x87864a0)') called at /usr/ +lib/perl5/site_perl/5.8.5/DBIx/ContextualFetch.pm line 87 DBIx::ContextualFetch::st::select_row('DBIx::ContextualFetch:: +st=HASH(0x8786494)', 'Recode::Bioentry=HASH(0x87864a0)') called at /u +sr/lib/perl5/site_perl/5.8.5/Class/DBI.pm line 852 Class::DBI::_flesh('Recode::Biosequence=HASH(0x87865f0)', 'All +') called at /usr/lib/perl5/site_perl/5.8.5/Class/DBI.pm line 840 Class::DBI::get('Recode::Biosequence=HASH(0x87865f0)', 'seq') +called at /usr/lib/perl5/site_perl/5.8.5/Class/Accessor.pm line 328 Class::Accessor::__ANON__[/usr/lib/perl5/site_perl/5.8.5/Class +/Accessor.pm:330]('Recode::Biosequence=HASH(0x87865f0)') called at te +st.pl line 11. at /usr/lib/perl5/site_perl/5.8.5/DBIx/ContextualFetc +h.pm line 52 DBIx::ContextualFetch::st::_untaint_execute('DBIx::ContextualF +etch::st=HASH(0x8786494)', 'Recode::Bioentry=HASH(0x87864a0)') called + at /usr/lib/perl5/site_perl/5.8.5/DBIx/ContextualFetch.pm line 32 DBIx::ContextualFetch::st::execute('DBIx::ContextualFetch::st= +HASH(0x8786494)', 'Recode::Bioentry=HASH(0x87864a0)') called at /usr/ +lib/perl5/site_perl/5.8.5/DBIx/ContextualFetch.pm line 87 DBIx::ContextualFetch::st::select_row('DBIx::ContextualFetch:: +st=HASH(0x8786494)', 'Recode::Bioentry=HASH(0x87864a0)') called at /u +sr/lib/perl5/site_perl/5.8.5/Class/DBI.pm line 852 Class::DBI::_flesh('Recode::Biosequence=HASH(0x87865f0)', 'All +') called at /usr/lib/perl5/site_perl/5.8.5/Class/DBI.pm line 840 Class::DBI::get('Recode::Biosequence=HASH(0x87865f0)', 'seq') +called at /usr/lib/perl5/site_perl/5.8.5/Class/Accessor.pm line 328 Class::Accessor::__ANON__[/usr/lib/perl5/site_perl/5.8.5/Class +/Accessor.pm:330]('Recode::Biosequence=HASH(0x87865f0)') called at te +st.pl line 11

Replies are listed 'Best First'.
Re: Class::DBI failure within perl debugger
by perrin (Chancellor) on Nov 15, 2005 at 19:41 UTC
    The Class::DBI mailing list is not moderated. I'd suggest trying again. If you do, please mention which version of Class::DBI you use.

    The only thing that jumps out at me here is that you don't declare primary keys on any of these, so it will take the first column in your All list as the key. But if you only see this error under the debugger, what are you worried about? Sounds like a problem with the debugger mangling context somewhere to me.

    UPDATE: Someone else had a similar problem on here, and recompiling DBI/DBD fixed it. He was using a DBI compiled against an older version of perl. Try that, if you can.

Re: Class::DBI failure within perl debugger
by barvin (Beadle) on Nov 15, 2005 at 21:33 UTC
    Yes upgrading to the latest DBI and DBD::Pg did the trick. Not sure why. Not sure why I didn't think to try that first either! Thanks for the suggestion. Barry