[OSSTEST,v2,33/41] cs-bisection-step: Generalise qtxt_common_rev_ok
diff mbox series

Message ID 20200731113820.5765-34-ian.jackson@eu.citrix.com
State New
Headers show
Series
  • Performance work
Related show

Commit Message

Ian Jackson July 31, 2020, 11:38 a.m. UTC
* Make it into a subref which takes a $table argument.
* Change the two references into function calls using the @{...} syntax
* Move the definition earlier in the file

No change to the generated query.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
v2: New patch.
---
 cs-bisection-step | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

Patch
diff mbox series

diff --git a/cs-bisection-step b/cs-bisection-step
index 9a0fee39..5d4e179e 100755
--- a/cs-bisection-step
+++ b/cs-bisection-step
@@ -182,6 +182,14 @@  END
 sub flight_rmap ($$) {
     my ($flight, $need_urls) = @_;
 
+    my $qtxt_common_rev_ok = sub {
+	my ($table) = @_;
+	[<<END];
+                 ($table.name LIKE E'built\\_revision\\_%' OR
+                  $table.name LIKE E'revision\\_%')
+END
+    };
+
     $dbh_tests->do(<<END, {});
           CREATE TEMP TABLE tmp_build_info (
               use varchar NOT NULL,
@@ -236,10 +244,6 @@  END
     my $qtxt_common_tables = <<END;
 	    FROM tmp_build_info AS rev
 END
-    my $qtxt_common_rev_condition = <<END;
-                 (rev.name LIKE E'built\\_revision\\_%' OR
-                  rev.name LIKE E'revision\\_%')
-END
 
     my $sth= db_prepare(!$need_urls ? <<END_NOURLS : <<END_URLS);
         SELECT
@@ -249,7 +253,7 @@  $qtxt_common_results
 $qtxt_common_tables
 
            WHERE
-$qtxt_common_rev_condition
+@{ $qtxt_common_rev_ok->('rev') }
 
 	   ORDER by rev.name;
 
@@ -262,7 +266,7 @@  $qtxt_common_tables
       CROSS JOIN tmp_build_info AS url
 
            WHERE
-$qtxt_common_rev_condition
+@{ $qtxt_common_rev_ok->('rev') }
   	     AND  url.name LIKE E'tree\\_%'
 	     AND  url.use = rev.use
 	     AND  url.job = rev.job