From f550652dbfa77d1f485767e1a7f71cb539c2f1d8 Mon Sep 17 00:00:00 2001 From: Sveta Smirnova Date: Tue, 9 Sep 2025 19:25:13 +0300 Subject: [PATCH] PT-2014 - pt-config-diff does not honor case insensitivity flag - Fixed the proposed fix - Fixed proposed configuration files - Added test case --- bin/pt-config-diff | 2 +- lib/MySQLConfigComparer.pm | 2 +- t/lib/MySQLConfigComparer.t | 24 +++++++++++++++++++ .../samples/configs/pt-2014-1.txt} | 2 -- t/lib/samples/configs/pt-2014-2.txt | 7 ++++++ t/pt-config-diff/samples/cnf2 | 9 ------- 6 files changed, 33 insertions(+), 13 deletions(-) rename t/{pt-config-diff/samples/cnf1 => lib/samples/configs/pt-2014-1.txt} (72%) create mode 100644 t/lib/samples/configs/pt-2014-2.txt delete mode 100644 t/pt-config-diff/samples/cnf2 diff --git a/bin/pt-config-diff b/bin/pt-config-diff index bb12c274..a4e5dcbe 100755 --- a/bin/pt-config-diff +++ b/bin/pt-config-diff @@ -3696,7 +3696,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{lc($val)} if exists $alt_val_for{lc($val)}; + $val = $alt_val_for{uc($val)} if exists $alt_val_for{uc($val)}; if ( $val ) { if ( $is_dir ) { diff --git a/lib/MySQLConfigComparer.pm b/lib/MySQLConfigComparer.pm index f430a0d3..34da4031 100644 --- a/lib/MySQLConfigComparer.pm +++ b/lib/MySQLConfigComparer.pm @@ -294,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{lc($val)} if exists $alt_val_for{lc($val)}; + $val = $alt_val_for{uc($val)} if exists $alt_val_for{uc($val)}; if ( $val ) { if ( $is_dir ) { diff --git a/t/lib/MySQLConfigComparer.t b/t/lib/MySQLConfigComparer.t index 3977fd44..58b811db 100644 --- a/t/lib/MySQLConfigComparer.t +++ b/t/lib/MySQLConfigComparer.t @@ -425,6 +425,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/pt-config-diff/samples/cnf1 b/t/lib/samples/configs/pt-2014-1.txt similarity index 72% rename from t/pt-config-diff/samples/cnf1 rename to t/lib/samples/configs/pt-2014-1.txt index 1dd5f93d..5c279d66 100644 --- a/t/pt-config-diff/samples/cnf1 +++ b/t/lib/samples/configs/pt-2014-1.txt @@ -2,8 +2,6 @@ log_bin=1 gtid_mode=on read_only=off -autocommit=yes autocommit=no binlog_format=mixed skip_name_resolve=true -skip_name_resolve=false 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 diff --git a/t/pt-config-diff/samples/cnf2 b/t/pt-config-diff/samples/cnf2 deleted file mode 100644 index b711b3a7..00000000 --- a/t/pt-config-diff/samples/cnf2 +++ /dev/null @@ -1,9 +0,0 @@ -[mysqld] -LOGBIN=1 -gtid_mode=ON -read_only=OFF -autocommit=YES -autocommit=NO -binlog_format=MIXED -skip_name_resolve=TRUE -skip_name_resolve=FALSE