chiark / gitweb /
Pass $dbh down through the stack, for better lifetime
[ypp-sc-tools.db-live.git] / yarrg / web / qtextstringcheck
index 5ef8971f644b63991af5d6eb5379be7fec1da596..b2c101390589b01daf00d858c60f9d205d05ce83 100755 (executable)
@@ -43,6 +43,7 @@ $format
 $ctype => undef
 $string
 $what
+$dbh => undef
 </%args>
 
 <%flags>
@@ -58,7 +59,8 @@ use CommodsWeb;
 die if $what =~ m/[^a-z]/;
 my $chk= $m->fetch_comp("check_${what}");
 
-my $dbh= dbw_connect($ocean);
+my $mydbh;
+$dbh ||= ($mydbh= dbw_connect($ocean));
 
 my $sqlstmt= $chk->scall_method("sqlstmt");
 my $sth= $dbh->prepare($sqlstmt);
@@ -119,7 +121,7 @@ if ($format =~ /dump/) {
        print Dumper($emsg, $canontext, \@results);
 }
 
-$dbh->rollback();
+$mydbh->rollback() if $mydbh;
 
 return  $emsg,
        $canontext,