From patchwork Thu May 2 17:42:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Jackson X-Patchwork-Id: 10927419 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 66E2C1390 for ; Thu, 2 May 2019 17:54:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 56E0A1FF13 for ; Thu, 2 May 2019 17:54:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4B9901FFF9; Thu, 2 May 2019 17:54:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D93E61FF13 for ; Thu, 2 May 2019 17:54:55 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hMFtR-0006gs-18; Thu, 02 May 2019 17:53:13 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hMFtP-0006gL-QD for xen-devel@lists.xenproject.org; Thu, 02 May 2019 17:53:11 +0000 X-Inumbo-ID: 26231b66-6d03-11e9-843c-bc764e045a96 Received: from SMTP03.CITRIX.COM (unknown [162.221.156.55]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 26231b66-6d03-11e9-843c-bc764e045a96; Thu, 02 May 2019 17:53:10 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.60,422,1549929600"; d="scan'208";a="84983427" From: Ian Jackson To: Date: Thu, 2 May 2019 18:42:32 +0100 Message-ID: <20190502174238.23848-4-ian.jackson@eu.citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190502174238.23848-1-ian.jackson@eu.citrix.com> References: <20190502174238.23848-1-ian.jackson@eu.citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [OSSTEST PATCH 3/9] cs-adjust-flight: Use db_prepare and honour -D -D for sql dumps X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Ian Jackson Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP This makes debugging it easier. No functional change with zero or one occurrences of -D. Signed-off-by: Ian Jackson --- 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(<prepare(<prepare(<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) {