PT-1554 Make QueryFormater consistent

In some OSes/Perl versions, the 'filtered' row is being printed with or
without decimals.
For example, in Ubuntu 16.04/Perl 5.22 it is 100.00 while in Ubuntu
18.04/Perl 5.26 it is 100.
To make it consistent for tests, add a default formating string for the
filtered row.
This commit is contained in:
Carlos Salguero
2018-05-23 15:28:28 -03:00
parent cbe2333e92
commit 09cd07f58e
5 changed files with 12 additions and 6 deletions

View File

@@ -7778,7 +7778,12 @@ sub explain_report {
$explain .= "# *************************** $i. "
. "row ***************************\n";
foreach my $j ( 0 .. $#row ) {
$explain .= sprintf "# %13s: %s\n", $sth->{NAME}->[$j],
# In some OSes/Perl versions, the filtered row can be reported with or without decimals.
# Example, in Ubuntu 16.04 it is being printed as 100.00 while in Ubuntu 18.04 it is
# being printed as 100.
# To make it testeable, we need to have a consistent format across versions.
my $value_format = $sth->{NAME}->[$j] eq 'filtered' ? "%.02f" : "%s";
$explain .= sprintf "# %13s: $value_format\n", $sth->{NAME}->[$j],
defined $row[$j] ? $row[$j] : 'NULL';
}
$i++; # next row number

View File

@@ -1332,7 +1332,8 @@ sub explain_report {
$explain .= "# *************************** $i. "
. "row ***************************\n";
foreach my $j ( 0 .. $#row ) {
$explain .= sprintf "# %13s: %s\n", $sth->{NAME}->[$j],
my $value_format = $sth->{NAME}->[$j] eq 'filtered' ? "%.02f" : "%s";
$explain .= sprintf "# %13s: $value_format\n", $sth->{NAME}->[$j],
defined $row[$j] ? $row[$j] : 'NULL';
}
$i++; # next row number

View File

@@ -45,7 +45,7 @@ select t.a, count(*) from t join t t2 using(a) group by 1 order by 2 desc limit
# key_len: NULL
# ref: NULL
# rows: 14
# filtered: 100
# filtered: 100.00
# Extra: Using temporary; Using filesort
# *************************** 2. row ***************************
# id: 1
@@ -58,5 +58,5 @@ select t.a, count(*) from t join t t2 using(a) group by 1 order by 2 desc limit
# key_len: NULL
# ref: NULL
# rows: 14
# filtered: 10
# filtered: 10.00
# Extra: Using where; Using join buffer (Block Nested Loop)

View File

@@ -41,5 +41,5 @@ SELECT fruit FROM trees\G
# key_len: 27
# ref: NULL
# rows: 1
# filtered: 100
# filtered: 100.00
# Extra: Using index

View File

@@ -41,5 +41,5 @@ SELECT fruit FROM trees\G
# key_len: 27
# ref: NULL
# rows: 3
# filtered: 100
# filtered: 100.00
# Extra: Using index