mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-12 14:18:32 +00:00
Bug 1007938: MySQLConfig doesn't support end-of-line comments
Patch provided by Kaiwang CHEN (~kaiwang-chen) on Launchpad.
This commit is contained in:
@@ -337,8 +337,9 @@ sub _parse_varvals {
|
|||||||
ITEM:
|
ITEM:
|
||||||
foreach my $item ( @varvals ) {
|
foreach my $item ( @varvals ) {
|
||||||
if ( $item ) {
|
if ( $item ) {
|
||||||
# Strip leading and trailing whitespace.
|
# Strip leading and trailing whitespace, and trailing comments.
|
||||||
$item =~ s/^\s+//;
|
$item =~ s/^\s+//;
|
||||||
|
$item =~ s/[#;].*$//;
|
||||||
$item =~ s/\s+$//;
|
$item =~ s/\s+$//;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -9,7 +9,7 @@ BEGIN {
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings FATAL => 'all';
|
use warnings FATAL => 'all';
|
||||||
use English qw(-no_match_vars);
|
use English qw(-no_match_vars);
|
||||||
use Test::More tests => 30;
|
use Test::More tests => 31;
|
||||||
|
|
||||||
use MySQLConfig;
|
use MySQLConfig;
|
||||||
use DSNParser;
|
use DSNParser;
|
||||||
@@ -827,6 +827,16 @@ SKIP: {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$config = new MySQLConfig(
|
||||||
|
file => "$trunk/t/lib/samples/configs/mycnf-kc-001.txt",
|
||||||
|
TextResultSetParser => $trp,
|
||||||
|
);
|
||||||
|
is(
|
||||||
|
$config->value_of('user'),
|
||||||
|
'mysql',
|
||||||
|
'end of line comment in option file'
|
||||||
|
);
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Done.
|
# Done.
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
|
2
t/lib/samples/configs/mycnf-kc-001.txt
Normal file
2
t/lib/samples/configs/mycnf-kc-001.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
[mysqld]
|
||||||
|
user=mysql ; comment
|
Reference in New Issue
Block a user