pt-config-diff doesn't handle end-of-line comments
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Percona Toolkit moved to https://jira.percona.com/projects/PT |
Fix Released
|
Low
|
Brian Fraser |
Bug Description
option file supports end-of-line comments started with semi-comma(;) or sharp (#), but MySQLConfig treats those comments part of value.
[kc@dns1 percona-toolkit]$ cat mycnf-kc-001.txt
[mysqld]
user=mysql ; comment
[kc@dns1 percona-toolkit]$ cat mycnf-kc-002.txt
[mysqld]
user=mysql
[kc@dns1 percona-toolkit]$ perl bin/pt-config-diff mycnf-kc-001.txt mycnf-kc-002.txt
1 config difference
Variable mycnf-kc-001.txt mycnf-kc-002.txt
=======
user mysql ; comment mysql
I think the problem is in _parse_varvals()
=== modified file 'lib/MySQLConfi
--- lib/MySQLConfig.pm 2012-01-19 19:46:56 +0000
+++ lib/MySQLConfig.pm 2012-06-02 20:07:03 +0000
@@ -339,6 +339,7 @@
if ( $item ) {
# Strip leading and trailing whitespace.
$item =~ s/^\s+//;
+ $item =~ s/[#;].*$//; # trailing comment
$item =~ s/\s+$//;
}
The enclosed patch(bin/
not ok 26 - end of line comment in option file
# Failed test 'end of line comment in option file'
# in t/lib/MySQLConfig.t at line 805.
# got: 'mysql ; comment'
# expected: 'mysql'
# Looks like you failed 1 test of 30.
Thanks,
kc
Related branches
- Daniel Nichter: Approve
- Brian Fraser (community): Approve
-
Diff: 194 lines (+93/-19)4 files modifiedbin/pt-config-diff (+21/-10)
lib/MySQLConfig.pm (+23/-9)
t/lib/MySQLConfig.t (+40/-0)
t/lib/samples/configs/mycnf-kc-001.txt (+9/-0)
tags: | added: comments pt-config-diff |
Changed in percona-toolkit: | |
status: | New → Triaged |
tags: |
added: option-parsing removed: comments |
Changed in percona-toolkit: | |
assignee: | nobody → Brian Fraser (fraserbn) |
status: | Triaged → In Progress |
Changed in percona-toolkit: | |
milestone: | none → 2.1.7 |
Changed in percona-toolkit: | |
milestone: | 2.1.7 → 2.1.8 |
Changed in percona-toolkit: | |
importance: | Undecided → Low |
Changed in percona-toolkit: | |
status: | In Progress → Fix Committed |
summary: |
- MySQLConfig doesn't support end-of-line comments + pt-config-diff doesn't handle end-of-line comments |
Changed in percona-toolkit: | |
status: | Fix Committed → Fix Released |
Hey,
Thank you for the patch! It's an unexpected but welcome surprise to get one with a test case. I have just created a branch with it, and will be running tests shortly, but a bit of a heads up: It might be a bit too late to get this into the 2.1.2 release, so it'll probably have to wait until 2.1.3.