From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Campbell Subject: [PATCH OSSTEST v1 3/5] mg-show-flight-runvars: calculate @colsw from @rows not via SQL Date: Mon, 1 Feb 2016 14:28:30 +0000 Message-ID: <1454336912-28503-3-git-send-email-ian.campbell@citrix.com> References: <1454336890.28781.99.camel@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1454336890.28781.99.camel@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: ian.jackson@eu.citrix.com, xen-devel@lists.xen.org Cc: Ian Campbell List-Id: xen-devel@lists.xenproject.org This will work even once @rows is not all collected by the same SQL statement. Signed-off-by: Ian Campbell --- mg-show-flight-runvars | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/mg-show-flight-runvars b/mg-show-flight-runvars index 0995430..0cf4e13 100755 --- a/mg-show-flight-runvars +++ b/mg-show-flight-runvars @@ -46,7 +46,6 @@ die unless @ARGV==1 && $ARGV[0] =~ m/^\w+$/; our @cols = qw(job name val); our @rows; -our @colws; sub collect ($) { my ($flight) = @_; @@ -54,9 +53,6 @@ sub collect ($) { $flight =~ m/^\d+/ or $flight = "'$flight'"; my $qfrom = "FROM runvars WHERE flight=$flight AND $synthcond"; - @colws = $dbh_tests->selectrow_array - ("SELECT ".(join ',', map { "max(length($_))" } @cols)." $qfrom"); - my $q = $dbh_tests->prepare ("SELECT synth, ".(join ',', @cols)." $qfrom ORDER BY synth, name, job"); $q->execute(); @@ -68,10 +64,15 @@ sub collect ($) { } } -$colws[1] += length $synthsufx; - collect($ARGV[0]); +our @colws; +sub max ($$) { $_[$_[0] < $_[1]] } +foreach my $row (@rows) { + @colws = map { max($colws[$_]//0,length($row->[$_])) } qw(0 1 2) +} +$colws[1] += length $synthsufx; + foreach my $row (@rows) { printf "%-*s %-*s %-*s\n", map { $colws[$_], $row->[$_] } qw(0 1 2) or die $!; -- 2.6.1