Created
October 6, 2011 13:33
-
-
Save yko/1267398 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use DBI; | |
use Test::More tests => 3; | |
use strict; | |
use warnings; | |
my $options = {mysql_auto_reconnect => 1}; | |
my $dbh = DBI->connect("dbi:mysql:", undef, undef, $options); | |
BAIL_OUT("MySQL connection failed: " . $DBI::errstr) unless $dbh; | |
my ($id) = $dbh->selectrow_array("SELECT CONNECTION_ID()"); | |
like $id, qr/^\d+$/, "right connection id"; | |
ok $dbh->do('KILL ?', undef, $id), "kill MySQL connection"; | |
my ($value) = $dbh->selectrow_array("SELECT 42;"); | |
is $value, 42, "reconnected"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment