From 1e4c7e7a26a57c88412345a838c76a7e01ac0c19 Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Mon, 27 Dec 2010 18:23:53 +1300 Subject: [PATCH] Output the database error when a query fails. Signed-off-by: Andrew McMillan --- testing/dav_test | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/testing/dav_test b/testing/dav_test index 150c743e..da648a37 100755 --- a/testing/dav_test +++ b/testing/dav_test @@ -229,6 +229,10 @@ if ( defined(@{$queries}) && @{$queries} ) { foreach $sql_statement ( @$queries ) { # run SQL statement and dump results, into array of hashes my $results = $dbh->selectall_arrayref($sql_statement, { Slice => {} } ); + if ( $dbh->err ) { + print $dbh->errstr, "\n"; + next; + } foreach my $row ( @$results ) { print "Query result ================================================\n" if ( $debug ); my $sep = ""; @@ -258,6 +262,10 @@ sub get_sql_value { opendb() unless defined($dbh); my $results = $dbh->selectall_arrayref($sql); + if ( $dbh->err ) { + print $dbh->errstr, "\n"; + return; + } print STDERR "RESULT for $varname is ", $results->[0][0], "\n" if ( $debug ); $values->{$varname} = (defined($results->[0][0]) ? $results->[0][0] : ""); }