diff --git a/bin/pt-config-diff b/bin/pt-config-diff index 9c619646..08dbc9c6 100755 --- a/bin/pt-config-diff +++ b/bin/pt-config-diff @@ -3515,12 +3515,12 @@ use English qw(-no_match_vars); use constant PTDEBUG => $ENV{PTDEBUG} || 0; my %alt_val_for = ( - ON => 1, - YES => 1, - TRUE => 1, - OFF => 0, - NO => 0, - FALSE => 0, + ON => 1, + YES => 1, + TRUE => 1, + OFF => 0, + NO => 0, + FALSE => 0, ); sub new { @@ -3637,7 +3637,8 @@ sub diff { next CONFIG if $val0 == $valN; } else { - next CONFIG if $ignore_case + + next CONFIG if $ignore_case ? lc($val0) eq lc($valN) : $val0 eq $valN; @@ -3699,7 +3700,7 @@ sub _normalize_value { my ($val, $is_dir, $base_path) = @args{qw(value is_directory base_path)}; $val = defined $val ? $val : ''; - $val = $alt_val_for{$val} if exists $alt_val_for{$val}; + $val = $alt_val_for{uc($val)} if exists $alt_val_for{uc($val)}; if ( $val =~ m/,/ && !$is_dir && !$base_path) { $val = join(',', sort(split(',', $val))); diff --git a/lib/MySQLConfigComparer.pm b/lib/MySQLConfigComparer.pm index 114297b1..d9f93586 100644 --- a/lib/MySQLConfigComparer.pm +++ b/lib/MySQLConfigComparer.pm @@ -31,12 +31,12 @@ use constant PTDEBUG => $ENV{PTDEBUG} || 0; # in SHOW VARS as var=TRUE. I.e. there's several synonyms for basic # true (1) and false (0), so we normalize them to make comparisons easier. my %alt_val_for = ( - ON => 1, - YES => 1, - TRUE => 1, - OFF => 0, - NO => 0, - FALSE => 0, + ON => 1, + YES => 1, + TRUE => 1, + OFF => 0, + NO => 0, + FALSE => 0, ); # Sub: new @@ -202,7 +202,8 @@ sub diff { next CONFIG if $val0 == $valN; } else { - next CONFIG if $ignore_case + + next CONFIG if $ignore_case ? lc($val0) eq lc($valN) : $val0 eq $valN; @@ -293,7 +294,7 @@ sub _normalize_value { my ($val, $is_dir, $base_path) = @args{qw(value is_directory base_path)}; $val = defined $val ? $val : ''; - $val = $alt_val_for{$val} if exists $alt_val_for{$val}; + $val = $alt_val_for{uc($val)} if exists $alt_val_for{uc($val)}; if ( $val =~ m/,/ && !$is_dir && !$base_path) { $val = join(',', sort(split(',', $val))); diff --git a/t/lib/MySQLConfigComparer.t b/t/lib/MySQLConfigComparer.t index 5ad852f3..47539039 100644 --- a/t/lib/MySQLConfigComparer.t +++ b/t/lib/MySQLConfigComparer.t @@ -449,6 +449,30 @@ is_deeply( "..but can be turned off" ); +# ############################################################################ +# https://perconadev.atlassian.net/browse/PT-2014 +# pt-config-diff does not honor case insensitivity flag for boolean values +# ############################################################################ +$c1 = new MySQLConfig( + file => "$trunk/$sample/pt-2014-1.txt", + TextResultSetParser => $trp, +); +$c2 = new MySQLConfig( + file => "$trunk/$sample/pt-2014-2.txt", + TextResultSetParser => $trp, +); +{ + my $diff = $cc->diff( + configs => [$c1, $c2], + ); + + is_deeply( + $diff, + undef, + "Boolean values are the same regardless of the case" + ) or diag(Dumper($diff)); +} + # ############################################################################# # Done. # ############################################################################# diff --git a/t/lib/samples/configs/pt-2014-1.txt b/t/lib/samples/configs/pt-2014-1.txt new file mode 100644 index 00000000..5c279d66 --- /dev/null +++ b/t/lib/samples/configs/pt-2014-1.txt @@ -0,0 +1,7 @@ +[mysqld] +log_bin=1 +gtid_mode=on +read_only=off +autocommit=no +binlog_format=mixed +skip_name_resolve=true diff --git a/t/lib/samples/configs/pt-2014-2.txt b/t/lib/samples/configs/pt-2014-2.txt new file mode 100644 index 00000000..3d98756f --- /dev/null +++ b/t/lib/samples/configs/pt-2014-2.txt @@ -0,0 +1,7 @@ +[mysqld] +log_bin=on +gtid_mode=True +read_only=FALSE +autocommit=0 +binlog_format=MIXED +skip_name_resolve=TRUE