Author: timbo
Date: Thu Aug 9 14:50:55 2007
New Revision: 9833
Modified:
dbi/trunk/Changes
dbi/trunk/DBI.pm
dbi/trunk/lib/DBD/Proxy.pm
dbi/trunk/lib/DBI/Gofer/Execute.pm
dbi/trunk/lib/DBI/Profile.pm
Log:
Fixed bug (typo) in DBD/Gofer/Transport/Base.
Fixed DBD::Proxy disconnect error thanks to Philip Dye.
Added check_response_sub to DBI/Gofer/Execute.pm
Added functional flush_to_disk to DBI::Profile base class - helps DashProfiler.
Added vt_ driver prefix
Modified: dbi/trunk/Changes
==============================================================================
--- dbi/trunk/Changes (original)
+++ dbi/trunk/Changes Thu Aug 9 14:50:55 2007
@@ -16,6 +16,8 @@
Move post-request cleanup into separate method and enable hooks so
it can be done after the response has been sent
+Gofer - allow dbh attrib changes after connect?
+
Gofer request flags:
return current executor stats as an attribute - handy for tests
only fetch one result set - handy for Sybase/MSSQL users
@@ -37,14 +39,20 @@
Add trace modules that just records the last N trace messages into an array
and prepends them to any error message.
+Gofer: gearman - need to disable coallesing for non-idempotent requests
+
=head2 Changes in DBI 1.59 (svn rev XXX), XXth June 2007
Fixed DBI::ProfileData to unescape headers lines read from data file.
Fixed DBI::ProfileData to not clobber $_, thanks to Alexey Tourbin.
Fixed DBI::SQL::Nano to not clobber $_, thanks to Alexey Tourbin.
Fixed DBI::PurePerl to return undef for ChildHandles if weaken not available.
+ Fixed DBD::Proxy disconnect error thanks to Philip Dye.
Fixed dbiprof compile errors, thanks to Alexey Tourbin.
Fixed t/03handle.t to skip some tests if ChildHandles not available.
+ Fixed DBD::Gofer::Transport::Base bug (typo) in timeout code.
+
+ Added check_response_sub to DBI::Gofer::Execute
=head2 Changes in DBI 1.58 (svn rev 9678), 25th June 2007
Modified: dbi/trunk/DBI.pm
==============================================================================
--- dbi/trunk/DBI.pm (original)
+++ dbi/trunk/DBI.pm Thu Aug 9 14:50:55 2007
@@ -348,6 +348,7 @@
tmplss_ => { class => 'DBD::TemplateSS', },
tuber_ => { class => 'DBD::Tuber', },
uni_ => { class => 'DBD::Unify', },
+ vt_ => { class => 'DBD::Vt', },
wmi_ => { class => 'DBD::WMI', },
x_ => { }, # for private use
xbase_ => { class => 'DBD::XBase', },
@@ -3400,14 +3401,13 @@
sub show_child_handles {
my ($h, $level) = @_;
- $level ||= 0;
printf "%sh %s %s\n", $h->{Type}, "\t" x $level, $h;
show_child_handles($_, $level + 1)
for (grep { defined } @{$h->{ChildHandles}});
}
my %drivers = DBI->installed_drivers();
- show_child_handles($_) for (values %drivers);
+ show_child_handles($_, 0) for (values %drivers);
=head3 C<CompatMode> (boolean, inherited)
Modified: dbi/trunk/lib/DBD/Proxy.pm
==============================================================================
--- dbi/trunk/lib/DBD/Proxy.pm (original)
+++ dbi/trunk/lib/DBD/Proxy.pm Thu Aug 9 14:50:55 2007
@@ -306,10 +306,12 @@
# Drop database connection at remote end
my $rdbh = $dbh->{'proxy_dbh'};
- local $SIG{__DIE__} = 'DEFAULT';
- local $@;
- eval { $rdbh->disconnect() };
- DBD::Proxy::proxy_set_err($dbh, $@) if $@;
+ if ( $rdbh ) {
+ local $SIG{__DIE__} = 'DEFAULT';
+ local $@;
+ eval { $rdbh->disconnect() } ;
+ DBD::Proxy::proxy_set_err($dbh, $@) if $@;
+ }
# Close TCP connect to remote
# XXX possibly best left till DESTROY? Add a config attribute to choose?
Modified: dbi/trunk/lib/DBI/Gofer/Execute.pm
==============================================================================
--- dbi/trunk/lib/DBI/Gofer/Execute.pm (original)
+++ dbi/trunk/lib/DBI/Gofer/Execute.pm Thu Aug 9 14:50:55 2007
@@ -41,6 +41,7 @@
forced_connect_attributes => {},
track_recent => 1,
check_request_sub => sub {},
+ check_response_sub => sub {},
forced_single_resultset => 1,
max_cached_dbh_per_drh => 1,
max_cached_sth_per_dbh => 1,
@@ -286,6 +287,12 @@
: $self->execute_dbh_request($request);
};
$response ||= $self->new_response_with_err(undef, $@, $current_dbh);
+
+ if (my $check_response_sub = $self->check_response_sub) {
+ eval { $check_response_sub->($response, $self, $request) };
+ warn "check_response_sub failed: $@" if $@;
+ }
+
undef $current_dbh;
$response->warnings([EMAIL PROTECTED]) if @warnings;
@@ -678,7 +685,7 @@
=head2 check_request_sub
If defined, it must be a reference to a subroutine that will 'check' the
request.
-It is pass the request object and the executor as its only arguments.
+It is passed the request object and the executor as its only arguments.
The subroutine can either return the original request object or die with a
suitable error message (which will be turned into a Gofer response).
@@ -686,6 +693,15 @@
It can also construct and return a new request that should be executed instead
of the original request.
+=head2 check_response_sub
+
+If defined, it must be a reference to a subroutine that will 'check' the
response.
+It is passed the response object, the executor, and the request object.
+The return value is ignored, though the sub may alter the response object.
+
+This mechanism can be used to, for example, terminate the service if specific
+database errors are seen.
+
=head2 forced_connect_dsn
If set, this DSN is always used instead of the one in the request.
Modified: dbi/trunk/lib/DBI/Profile.pm
==============================================================================
--- dbi/trunk/lib/DBI/Profile.pm (original)
+++ dbi/trunk/lib/DBI/Profile.pm Thu Aug 9 14:50:55 2007
@@ -667,7 +667,7 @@
use strict;
-use vars qw(@ISA @EXPORT @EXPORT_OK $VERSION $ON_DESTROY_DUMP);
+use vars qw(@ISA @EXPORT @EXPORT_OK $VERSION);
use Exporter ();
use UNIVERSAL ();
use Carp;
@@ -695,7 +695,8 @@
use constant DBIprofile_MethodName => '!MethodName';
use constant DBIprofile_MethodClass => '!MethodClass';
-$ON_DESTROY_DUMP = sub { DBI->trace_msg(shift, 0) };
+our $ON_DESTROY_DUMP = sub { DBI->trace_msg(shift, 0) };
+our $ON_FLUSH_DUMP = sub { DBI->trace_msg(shift, 0) };
sub new {
my $class = shift;
@@ -767,8 +768,12 @@
return undef;
}
-sub flush_to_disk { # baseclass method, see DBI::ProfileDumper
- return undef;
+sub flush_to_disk { # baseclass method, see DBI::ProfileDumper &
DashProfiler::Core
+ my $self = shift;
+ return unless $ON_FLUSH_DUMP;
+ return unless $self->{Data};
+ my $detail = $self->format();
+ $ON_FLUSH_DUMP->($detail) if $detail;
}