From patchwork Fri Jul 31 11:37:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Jackson X-Patchwork-Id: 11694645 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1E155913 for ; Fri, 31 Jul 2020 11:39:00 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 008D320838 for ; Fri, 31 Jul 2020 11:38:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 008D320838 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=eu.citrix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k1TN4-0005oL-At; Fri, 31 Jul 2020 11:38:42 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k1TN3-0005kZ-0H for xen-devel@lists.xenproject.org; Fri, 31 Jul 2020 11:38:41 +0000 X-Inumbo-ID: 59d8fa33-d322-11ea-8e26-bc764e2007e4 Received: from chiark.greenend.org.uk (unknown [2001:ba8:1e3::]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 59d8fa33-d322-11ea-8e26-bc764e2007e4; Fri, 31 Jul 2020 11:38:28 +0000 (UTC) Received: from [172.18.45.5] (helo=zealot.relativity.greenend.org.uk) by chiark.greenend.org.uk (Debian Exim 4.84_2 #1) with esmtp (return-path ijackson@chiark.greenend.org.uk) id 1k1TMp-0001W4-Cw; Fri, 31 Jul 2020 12:38:27 +0100 From: Ian Jackson To: xen-devel@lists.xenproject.org Subject: [OSSTEST PATCH v2 03/41] SQL: Fix incorrect LIKE pattern syntax (literals) Date: Fri, 31 Jul 2020 12:37:42 +0100 Message-Id: <20200731113820.5765-4-ian.jackson@eu.citrix.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200731113820.5765-1-ian.jackson@eu.citrix.com> References: <20200731113820.5765-1-ian.jackson@eu.citrix.com> MIME-Version: 1.0 X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 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" LIKE takes a weird SQLish glob pattern, where % is like a glob * and (relevantly, here) _ is like a glob ?. Every _ in one of these LIKE patterns needs to be escaped with \. Do that for all the literal LIKE patterns. This fixes bugs. Generally, bugs where the wrong rows might be returned (except that the data probably doesn't have any such rows). Signed-off-by: Ian Jackson --- New in v2. --- mg-force-push | 2 +- mg-report-host-usage-collect | 2 +- sg-report-flight | 2 +- sg-report-host-history | 6 +++--- ts-logs-capture | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/mg-force-push b/mg-force-push index 001e0c47..3a701a11 100755 --- a/mg-force-push +++ b/mg-force-push @@ -54,7 +54,7 @@ END FROM rv url JOIN rv built ON url.job = built.job - AND url.name LIKE 'tree_%' + AND url.name LIKE 'tree\_%' AND built.name = 'built_revision_' || substring(url.name, 6) WHERE url.val = ? END diff --git a/mg-report-host-usage-collect b/mg-report-host-usage-collect index 3fab490a..1944c8d7 100755 --- a/mg-report-host-usage-collect +++ b/mg-report-host-usage-collect @@ -166,7 +166,7 @@ END SELECT val, synth FROM runvars WHERE flight=? AND job=? - AND (name LIKE '%_host' OR name='host') + AND (name LIKE '%\_host' OR name='host') END my $finishq = db_prepare(</dev/null"; -my $namecond= "(name = 'host' OR name LIKE '%_host')"; +my $namecond= "(name = 'host' OR name LIKE '%\_host')"; csreadconfig(); while (@ARGV && $ARGV[0] =~ m/^-/) { @@ -256,7 +256,7 @@ END FROM runvars WHERE flight=? AND job=? AND ( - name LIKE (? || '_power_%') + name LIKE (? || '\_power\_%') ) END @@ -456,7 +456,7 @@ foreach my $host (@ARGV) { SELECT DISTINCT val FROM runvars WHERE flight=? - AND (name = 'host' OR name LIKE '%_host') + AND (name = 'host' OR name LIKE '%\_host') END $hostsinflightq->execute($flight); while (my $row = $hostsinflightq->fetchrow_hashref()) { diff --git a/ts-logs-capture b/ts-logs-capture index d75a2fda..62c281b8 100755 --- a/ts-logs-capture +++ b/ts-logs-capture @@ -44,7 +44,7 @@ our (@allguests, @guests); sub find_guests () { my $sth= $dbh_tests->prepare(<execute($flight, $job);