[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [OSSTEST PATCH 03/11] cs-adjust-flight: Use db_prepare and honour -D -D for sql dumps



This makes debugging it easier.  No functional change with zero or one
occurrences of -D.

Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 cs-adjust-flight | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/cs-adjust-flight b/cs-adjust-flight
index badabeff..cc1684b4 100755
--- a/cs-adjust-flight
+++ b/cs-adjust-flight
@@ -75,6 +75,7 @@ csreadconfig();
 our $debug = 0;
 
 open VERBOSE, ">/dev/null" or die $!;
+open DEBUG, ">/dev/null" or die $!;
 our $verbose_buffer;
 
 while (@ARGV && $ARGV[0] =~ m/^\-/) {
@@ -83,6 +84,7 @@ while (@ARGV && $ARGV[0] =~ m/^\-/) {
     if (m/^-v$/) {
        open VERBOSE, ">&STDERR" or die $!;
     } elsif (m/^-D$/) {
+        open DEBUG, ">&STDERR" if $debug;
         $debug = 1;
     } else {
         die "$_ ?";
@@ -138,9 +140,9 @@ sub for_things ($$$$$$$) {
     my ($spec, $fn, $ifnone,
         $table, $keycol, $basecond, $basecondvals) = @_;
 
-    my $thing_q = $dbh_tests->prepare
+    my $thing_q = db_prepare
         ("SELECT * FROM $table WHERE $basecond AND $keycol = ?");
-    my $things_q = $dbh_tests->prepare
+    my $things_q = db_prepare
         ("SELECT * FROM $table WHERE $basecond");
 
     my ($specfn,$exact) = notspec_exfn("FOR_THINGS $table.$keycol",$spec);
@@ -182,7 +184,7 @@ our @job_rm_qs;
 
 sub prep_rm_jobs () {
     return if @job_rm_qs;
-    @job_rm_qs = map { $dbh_tests->prepare($_) }
+    @job_rm_qs = map { db_prepare($_) }
         ("DELETE FROM runvars WHERE flight = ? AND job = ?",
          "DELETE FROM jobs WHERE flight = ? AND job = ?");
 }
@@ -195,7 +197,7 @@ sub do_rm_job ($) {
 }
 
 sub copy_jobs_qs () {
-    map { $dbh_tests->prepare($_) }
+    map { db_prepare($_) }
         ("INSERT INTO jobs (flight, job, recipe, status)".
          "     SELECT ?, job, recipe, 'queued'".
          "       FROM jobs".
@@ -205,8 +207,8 @@ sub copy_jobs_qs () {
          "       FROM runvars".
          "      WHERE flight = ? AND job = ? AND NOT synth");
 }
-sub copy_jobs_do ($$) {
-    my ($qs, $srcflight, $srcjob) = @_;
+sub copy_jobs_do ($$$) {
+    my ($qs, $srcflight, $job) = @_;
     $_->execute($dstflight, $srcflight, $job) foreach @$qs;
     verbose "$dstflight.$job job created from $srcflight.$job\n";
 }
@@ -253,9 +255,9 @@ sub change__copy_jobs {
     copy_jobs($srcflight, $jobs);
 }
 
-our $runvar_rm_q = $dbh_tests->prepare
+our $runvar_rm_q = db_prepare
     ("DELETE FROM runvars WHERE flight = ? AND job = ? AND name = ?");
-our $runvar_insert_q = $dbh_tests->prepare
+our $runvar_insert_q = db_prepare
     ("INSERT INTO runvars (flight, job, name, val, synth)".
      " VALUES (?, ?, ?, ?, 'f')");
 
@@ -430,7 +432,7 @@ sub change__job_status {
     die unless @changes >= 1;
     my $jobs = shift @changes;
 
-    my $q = $dbh_tests->prepare(<<END);
+    my $q = db_prepare(<<END);
         SELECT status
           FROM jobs
          WHERE flight = ? AND job = ?
@@ -449,12 +451,12 @@ sub change__jobs_rename {
     my $jobs = shift @changes;
     my $perlop = shift @changes;
 
-    my $jobq = $dbh_tests->prepare(<<END);
+    my $jobq = db_prepare(<<END);
     UPDATE jobs
        SET job = ?
      WHERE flight = ? AND job = ?
 END
-    my $runvarq = $dbh_tests->prepare(<<END);
+    my $runvarq = db_prepare(<<END);
     UPDATE runvars
        SET job = ?
      WHERE flight = ? AND job = ?
@@ -472,7 +474,7 @@ sub changes () {
 
     if ($dstflight =~ m/^\d+$/) {
        my $steps_q =
-           $dbh_tests->prepare("SELECT * FROM steps WHERE flight = ?");
+           db_prepare("SELECT * FROM steps WHERE flight = ?");
        $steps_q->execute($dstflight);
        my $step = $steps_q->fetchrow_hashref();
        if ($step) {
-- 
2.11.0


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.