1use strict; 2use warnings; 3 4use Test::More; 5use DBI; 6$|= 1; 7 8use vars qw($test_dsn $test_user $test_password); 9use lib 't', '.'; 10require 'lib.pl'; 11 12my $dbh; 13eval {$dbh = DBI->connect($test_dsn, $test_user, $test_password, 14 { RaiseError => 1, AutoCommit => 1})}; 15 16if ($@) { 17 plan skip_all => "no database connection"; 18} 19plan tests => 13 * 2; 20 21for my $mysql_server_prepare (0, 1) { 22$dbh= DBI->connect("$test_dsn;mysql_server_prepare=$mysql_server_prepare;mysql_server_prepare_disable_fallback=1", $test_user, $test_password, 23 { RaiseError => 1, PrintError => 1, AutoCommit => 0 }); 24 25ok(defined $dbh, "Connected to database"); 26 27ok($dbh->{Active}, "checking for active handle"); 28 29ok($dbh->{mysql_auto_reconnect} = 1, "enabling reconnect"); 30 31ok($dbh->{AutoCommit} = 1, "enabling autocommit"); 32 33ok($dbh->disconnect(), "disconnecting active handle"); 34 35ok(!$dbh->{Active}, "checking for inactive handle"); 36 37ok($dbh->do("SELECT 1"), "implicitly reconnecting handle with 'do'"); 38 39ok($dbh->{Active}, "checking for reactivated handle"); 40 41ok(!($dbh->{AutoCommit} = 0), "disabling autocommit"); 42 43ok($dbh->disconnect(), "disconnecting active handle"); 44 45ok(!$dbh->{Active}, "checking for inactive handle"); 46 47ok(!$dbh->do("SELECT 1"), "implicitly reconnecting handle with 'do'"); 48 49ok(!$dbh->{Active}, "checking for reactivated handle"); 50} 51