Author: spadkins
Date: Mon Jul 24 10:33:36 2006
New Revision: 6696
Modified:
p5ee/trunk/App-Repository/lib/App/Repository/MySQL.pm
Log:
enhanced the debug_sql for export_rows()/import_rows() to include timings
Modified: p5ee/trunk/App-Repository/lib/App/Repository/MySQL.pm
==============================================================================
--- p5ee/trunk/App-Repository/lib/App/Repository/MySQL.pm (original)
+++ p5ee/trunk/App-Repository/lib/App/Repository/MySQL.pm Mon Jul 24 10:33:36 2006
@@ -282,15 +282,23 @@
if ($options->{columns}) {
$sql .= "\n(" . join(",", @{$options->{columns}}) . ")";
}
- my $debug_sql = $self->{context}{options}{debug_sql};
+ my $context_options = $self->{context}{options};
+ my $debug_sql = $context_options->{debug_sql};
+ my ($timer, $elapsed_time);
if ($debug_sql) {
+ $timer = $self->_get_timer();
print "DEBUG_SQL: import_rows()\n";
print $sql;
}
- my $retval = $self->{dbh}->do($sql);
+ my ($retval);
+ eval {
+ $retval = $self->{dbh}->do($sql);
+ };
if ($debug_sql) {
- print "DEBUG_SQL: import_rows() = [$retval]\n";
+ $elapsed_time = $self->_read_timer($timer);
+ print "DEBUG_SQL: import_rows=[$retval] ($elapsed_time sec) $DBI::errstr : $@\n";
}
+ die $@ if ($@);
}
&App::sub_exit() if ($App::trace);
@@ -369,14 +377,21 @@
$sql .= "\n optionally enclosed by '$options->{field_quote}'" if ($options->{field_quote});
$sql .= "\n escaped by '$options->{field_escape}'" if ($options->{field_escape});
}
- my $debug_sql = $self->{context}{options}{debug_sql};
+ my $context_options = $self->{context}{options};
+ my $debug_sql = $context_options->{debug_sql};
+ my ($timer, $elapsed_time);
if ($debug_sql) {
+ $timer = $self->_get_timer();
print "DEBUG_SQL: export_rows()\n";
print $sql;
}
- my $retval = $self->{dbh}->do($sql);
+ my ($retval);
+ eval {
+ $retval = $self->{dbh}->do($sql);
+ };
if ($debug_sql) {
- print "DEBUG_SQL: export_rows() = [$retval]\n";
+ $elapsed_time = $self->_read_timer($timer);
+ print "DEBUG_SQL: export_rows=[$retval] ($elapsed_time sec) $DBI::errstr : $@\n";
}
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.