Subject: | ...::Lock::MySQL statement handles warning |
Using Apache::Session::MySQL with DBI 1.601 causes the warning:
DBI::db=HASH(0x833c3d0)->disconnect invalidates 2 active statement
handles (either destroy statement handles or call finish on them before
disconnecting) at apache_session.pl line 22.
when you disconnect the DBH - after the session has gone out of context.
This only happens if DBI's PrintWarn option is enabled (which is
enabled by $^W.)
I've attached apache_session.pl that demonstrates the problem.
Adding calls to finish() to acquire_read_lock() and release_read_lock()
in Apache::Session::Lock::MySQL prevents the warning.
I've attached apache_session_finish.diff which fixes the problem
Subject: | apache_session_finish.diff |
diff -ur -x blib -x /home/tony Apache-Session-1.85-orig/Session/Lock/MySQL.pm Apache-Session-1.85/Session/Lock/MySQL.pm
--- Apache-Session-1.85-orig/Session/Lock/MySQL.pm 2007-09-29 04:36:57.000000000 +1000
+++ Apache-Session-1.85/Session/Lock/MySQL.pm 2008-01-08 11:33:49.000000000 +1100
@@ -52,6 +52,7 @@
my $sth = $self->{dbh}->prepare_cached(q{SELECT GET_LOCK(?, 3600)}, {}, 1);
$sth->execute($self->{lockid});
+ $sth->finish();
$self->{lock} = 1;
}
@@ -68,6 +69,7 @@
my $sth = $self->{dbh}->prepare_cached(q{SELECT RELEASE_LOCK(?)}, {}, 1);
$sth->execute($self->{lockid});
+ $sth->finish();
$self->{lock} = 0;
}
Only in Apache-Session-1.85/Session/Lock: MySQL.pm~
Subject: | apache_session.pl |
#!perl -w
use strict;
use DBI;
#use blib '/home/tony/src/Apache-Session-1.85-orig';
#use blib '/home/tony/src/Apache-Session-1.85';
use Apache::Session::MySQL;
my $dbh = DBI->connect('dbi:mysql:bsetest', 'bsetest', 'bsetest')
or die;
{
my %session;
my $id;
tie %session, 'Apache::Session::MySQL', $id,
{
Handle => $dbh,
LockHandle => $dbh
};
untie %session;
}
$dbh->disconnect;