Author: timbo
Date: Thu Apr 5 02:25:36 2007
New Revision: 9376
Modified:
dbi/trunk/lib/DBD/Gofer.pm
dbi/trunk/lib/DBI/Gofer/Request.pm
dbi/trunk/lib/DBI/Gofer/Transport/Base.pm
Log:
Avoid sending \%attribs to prepare if there are only local gofer attribs.
Avoid showing actual Password in $request->summary_as_text.
Remove newlines from summary_as_text (ie in sql)
Improve error message when thaw fails.
Modified: dbi/trunk/lib/DBD/Gofer.pm
==============================================================================
--- dbi/trunk/lib/DBD/Gofer.pm (original)
+++ dbi/trunk/lib/DBD/Gofer.pm Thu Apr 5 02:25:36 2007
@@ -478,19 +478,21 @@
return $dbh->set_err(1, "Can't prepare when disconnected")
unless $dbh->FETCH('Active');
- my $policy = $attr->{go_policy} || $dbh->{go_policy};
+ $attr = { %$attr } if $attr; # copy so we can edit
+
+ my $policy = delete($attr->{go_policy}) || $dbh->{go_policy};
+ my $lii_args = delete $attr->{go_last_insert_id_args};
+ my $go_prepare = delete($attr->{go_prepare}) || $dbh->{go_prepare} ||
'prepare';
+ $attr = undef if $attr and not %$attr;
my ($sth, $sth_inner) = DBI::_new_sth($dbh, {
Statement => $statement,
- go_prepare_call => [
- $attr->{go_prepare} || $dbh->{go_prepare} || 'prepare',
- $statement, $attr
- ],
+ go_prepare_call => [ $go_prepare, $statement, $attr ],
# go_method_calls => [], # autovivs if needed
go_request => $dbh->{go_request},
go_transport => $dbh->{go_transport},
go_policy => $policy,
- go_last_insert_id_args => $attr->{go_last_insert_id_args},
+ go_last_insert_id_args => $lii_args,
});
$sth->STORE(Active => 0);
Modified: dbi/trunk/lib/DBI/Gofer/Request.pm
==============================================================================
--- dbi/trunk/lib/DBI/Gofer/Request.pm (original)
+++ dbi/trunk/lib/DBI/Gofer/Request.pm Thu Apr 5 02:25:36 2007
@@ -63,7 +63,9 @@
}
my ($dsn, $attr) = @{ $self->connect_args };
- push @s, sprintf "dbh= connect('%s', , , { %s })", $dsn, neat_list([
%{$attr||{}} ]);
+ my $tmp = { %{$attr||{}} }; # copy so we can edit
+ $tmp->{Password} = '***' if exists $tmp->{Password};
+ push @s, sprintf "dbh= connect('%s', , , { %s })", $dsn, neat_list([ %$tmp
]);
if (my $dbh_attr = $self->dbh_attributes) {
push @s, sprintf "dbh->FETCH: %s", @$dbh_attr
@@ -71,7 +73,9 @@
}
my ($meth, @args) = @{ $self->dbh_method_call };
- push @s, sprintf "dbh->%s(%s)", $meth, neat_list([EMAIL PROTECTED]);
+ my $args = neat_list([EMAIL PROTECTED]);
+ $args =~ s/\n+/ /g;
+ push @s, sprintf "dbh->%s(%s)", $meth, $args;
if (my $lii_args = $self->dbh_last_insert_id_args) {
push @s, sprintf "dbh->last_insert_id(%s)", neat_list($lii_args);
@@ -79,7 +83,8 @@
for my $call (@{ $self->sth_method_calls || [] }) {
my ($meth, @args) = @$call;
- push @s, sprintf "sth->%s(%s)", $meth, neat_list([EMAIL PROTECTED]);
+ ($args = neat_list([EMAIL PROTECTED])) =~ s/\n+/ /g;
+ push @s, sprintf "sth->%s(%s)", $meth, $args;
}
if (my $sth_attr = $self->sth_result_attr) {
Modified: dbi/trunk/lib/DBI/Gofer/Transport/Base.pm
==============================================================================
--- dbi/trunk/lib/DBI/Gofer/Transport/Base.pm (original)
+++ dbi/trunk/lib/DBI/Gofer/Transport/Base.pm Thu Apr 5 02:25:36 2007
@@ -54,8 +54,10 @@
my $data = eval { thaw($frozen_data) };
if ($@) {
chomp(my $err = $@);
- $self->_dump("bad data",$frozen_data);
- die "Error thawing object: $err";
+ my $msg = "Error thawing object: $err";
+ Carp::cluck("$msg - stack trace:"); # XXX disable later
+ $self->_dump("thaw failed for", $frozen_data);
+ die $msg;
}
$self->_dump("thawing ".ref($data), $data)
if !$skip_trace and $self->trace;
@@ -79,7 +81,6 @@
return;
}
else {
- Carp::cluck("$label from");
my $summary = eval { $data->summary_as_text } || $@ || "no summary
available\n";
$self->trace_msg("$label: $summary");
}