Paul Makepeace wrote: > Hi, > > Apache::DBI doesn't seem to be caching connections here causing a test > failure. I'm using Debian/unstable, Debian's perl 5.8.2, mysql 4.0.16, > DBD::mysql 2.9003, and CPAN's DBI 1.39. (DBI warned about perl having > threading enabled, FWIW.) > > Any ideas what could be the problem?
after playing around a bit with this, it looks like the test isn't calling Apache::DBI at all. the attached patch adds some simple tests to make sure that the database handles being compared actually come from Apache::DBI - they don't for me using the latest DBI and DBD::mysql. once the BEGIN logic is changed, though, all the tests (old and new) pass just fine. Apache-Test would be a perfect fit for this module ;) --Geoff
--- t/10mysql.t 2003-05-05 11:14:22.000000000 -0400 +++ t/10mysql.t~ 2004-01-02 10:00:59.000000000 -0500 @@ -1,30 +1,34 @@ use strict; -use Test::More tests => 7; -use DBI; +use Test::More tests => 10; BEGIN { # trick DBI.pm into thinking we are running under mod_perl + # set both %ENV keys for old and new DBI versions - if ($DBI::VERSION > 1.33) { - $ENV{MOD_PERL} = 'CGI-Perl'; - } - else { - $ENV{GATEWAY_INTERFACE} = 'CGI-Perl'; - } - use_ok('Apache::DBI', 'load Apache::DBI') + $ENV{MOD_PERL} = 'CGI-Perl'; + $ENV{GATEWAY_INTERFACE} = 'CGI-Perl'; + + use_ok('Apache::DBI'); + use_ok('DBI'); }; my $dbd_mysql = eval { require DBD::mysql }; #$Apache::DBI::DEBUG = 10; +#DBI->trace(2"); SKIP: { - skip "Could not load DBD::mysql", 6 unless $dbd_mysql; + skip "Could not load DBD::mysql", 8 unless $dbd_mysql; ok($dbd_mysql, "DBD::mysql loaded"); + # checking private DBI data here is probably bad... + is($DBI::connect_via, 'Apache::DBI::connect', 'DBI is using Apache::DBI'); + my $dbh_1 = DBI->connect('dbi:mysql:test', undef, undef, { RaiseError => 0, PrintError => 0 }); + isa_ok($dbh_1, 'Apache::DBI::db'); + SKIP: { skip "Could not connect to test database: $DBI::errstr", 5 unless $dbh_1; ok(my $thread_1 = $dbh_1->{'mysql_thread_id'}, "Connected 1");
-- Reporting bugs: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html