mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-12 14:18:32 +00:00
Merged fix-889739-pt-cd-quoted-strings and added the new sample files
This commit is contained in:
@@ -2171,6 +2171,13 @@ sub _parse_varvals {
|
||||
$val = '';
|
||||
}
|
||||
else {
|
||||
$val =~ s/
|
||||
\A # Start of value
|
||||
(['"]) # Opening quote
|
||||
(.*) # Value
|
||||
\1 # Closing quote
|
||||
[\n\r]*\z # End of value
|
||||
/$2/x;
|
||||
if ( my ($num, $factor) = $val =~ m/(\d+)([KMGT])b?$/i ) {
|
||||
my %factor_for = (
|
||||
k => 1_024,
|
||||
|
@@ -371,6 +371,13 @@ sub _parse_varvals {
|
||||
$val = '';
|
||||
}
|
||||
else {
|
||||
$val =~ s/
|
||||
\A # Start of value
|
||||
(['"]) # Opening quote
|
||||
(.*) # Value
|
||||
\1 # Closing quote
|
||||
[\n\r]*\z # End of value
|
||||
/$2/x;
|
||||
if ( my ($num, $factor) = $val =~ m/(\d+)([KMGT])b?$/i ) {
|
||||
# value is a size like 1k, 16M, etc.
|
||||
my %factor_for = (
|
||||
|
@@ -9,7 +9,7 @@ BEGIN {
|
||||
use strict;
|
||||
use warnings FATAL => 'all';
|
||||
use English qw(-no_match_vars);
|
||||
use Test::More tests => 16;
|
||||
use Test::More;
|
||||
|
||||
use TextResultSetParser();
|
||||
use MySQLConfigComparer;
|
||||
@@ -369,6 +369,29 @@ $c2 = new MySQLConfig(
|
||||
) or print Dumper($diff);
|
||||
}
|
||||
|
||||
# ############################################################################
|
||||
# https://bugs.launchpad.net/percona-toolkit/+bug/889739
|
||||
# pt-config-diff doesn't diff quoted strings properly
|
||||
# ############################################################################
|
||||
$c1 = new MySQLConfig(
|
||||
file => "$trunk/$sample/quoted_cnf.txt",
|
||||
TextResultSetParser => $trp,
|
||||
);
|
||||
$c2 = new MySQLConfig(
|
||||
file => "$trunk/$sample/unquoted_cnf.txt",
|
||||
TextResultSetParser => $trp,
|
||||
);
|
||||
{
|
||||
my $diff = $cc->diff(
|
||||
configs => [$c1, $c2],
|
||||
);
|
||||
|
||||
is_deeply(
|
||||
$diff,
|
||||
undef,
|
||||
"Values are the same regardless of quoting"
|
||||
) or diag(Dumper($diff));
|
||||
}
|
||||
# #############################################################################
|
||||
# Done.
|
||||
# #############################################################################
|
||||
@@ -382,4 +405,5 @@ like(
|
||||
qr/Complete test coverage/,
|
||||
'_d() works'
|
||||
);
|
||||
exit;
|
||||
|
||||
done_testing;
|
||||
|
6
t/lib/samples/configs/quoted_cnf.txt
Normal file
6
t/lib/samples/configs/quoted_cnf.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
[client]
|
||||
port = 3306
|
||||
socket = /var/run/mysqld/mysqld.sock
|
||||
|
||||
[mysqld]
|
||||
init-connect='SET NAMES utf8'
|
6
t/lib/samples/configs/unquoted_cnf.txt
Normal file
6
t/lib/samples/configs/unquoted_cnf.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
[client]
|
||||
port = 3306
|
||||
socket = /var/run/mysqld/mysqld.sock
|
||||
|
||||
[mysqld]
|
||||
init-connect=SET NAMES utf8
|
0
t/lib/samples/empty.txt
Normal file
0
t/lib/samples/empty.txt
Normal file
Reference in New Issue
Block a user