in reply to Re^2: disconnect, then ping returns true under apache, false from command line, no Apache::DBI around. Why would this be?
in thread disconnect, then ping returns true under apache, false from command line, no Apache::DBI around. Why would this be?
Note that this is true even if you don't have Apache::DBI (which completely overloads disconnect), and even if you don't have mod_perl. DBD::mysql checks for MOD_PERL or GATEWAY_INTERFACE in the env, and if it sees them, turns on mysql_auto_reconnect on the handle when you connect. (perldoc DBD::mysql for details.)
So in my case I needed to explicitly set $dbh->{mysql_auto_reconnect} = 0 and then call $dbh->disconnect. Otherwise, when I "verify that it's disconnected" with the ping() call, I actually reconnect first. (The ping() was really just something I was doing to make sure that Apache::DBI hadn't snuck itself back in--a debugging device.)
Thanks again for help everyone.
Oh, also, in comparing two DBI->trace outputs I wrote a hack to help diff ignore the differences in memory addresses. Here it is:
#!perl -w #use like this, if file1 and file2 are two traces of similar db operat +ions: # perl ox2read <file1 >file1scrub # perl ox2read <file2 >file2scrub # diff -c file1scrub file2scrub >mydiff use strict; my @seen_addy = (); while (my $line = <>) { foreach my $sr ( @seen_addy ) { my $search = $sr->[0]; my $replace = $sr->[1]; $line =~ s/$search/$replace/g; } while ($line =~ /(0x\w+)/) { my $search = $1; my $last_replace = @seen_addy ? $seen_addy[$#seen_addy]->[1] : + 'addy001'; my $replace = ++$last_replace; push @seen_addy, [$search, $replace]; $line =~ s/$search/$replace/g; } print $line; }
|
|---|