diff --git a/docs/percona-toolkit.pod b/docs/percona-toolkit.pod index 73d0b6bf..5cba1d81 100644 --- a/docs/percona-toolkit.pod +++ b/docs/percona-toolkit.pod @@ -313,6 +313,20 @@ provide defaults for all DSNs that do not specify the option's corresponding key part. For example, if DSN C and option C<--port=12345> are specified, then the tool automatically adds C to DSN. +=head2 ESCAPING VALUES + +DSNs are usually specified on the command line, so shell quoting and escaping +must be taken into account. Special characters, like asterisk (C<*>), need +to be quoted and/or escaped properly to be passed as literal characters in +DSN values. + +Since DSN parts are separated by commas, literal commas in DSN values must +be escaped with a single backslash (C<\>). And since a backslash is +the escape character for most shells, two backslashes are required to pass +a literal backslash. For example, if the username is literally C, +it must be specified as C on most shells. This applies to DSNs +and DSN-related options like C<--user>. + =head2 KEY PARTS Many of the tools add more parts to DSNs for special purposes, and sometimes diff --git a/lib/DSNParser.pm b/lib/DSNParser.pm index fd7b4f1b..938ec37b 100644 --- a/lib/DSNParser.pm +++ b/lib/DSNParser.pm @@ -131,9 +131,9 @@ sub parse { # Parse given props foreach my $dsn_part ( split($dsn_sep, $dsn) ) { + $dsn_part =~ s/\\,/,/g; if ( my ($prop_key, $prop_val) = $dsn_part =~ m/^(.)=(.*)$/ ) { # Handle the typical DSN parts like h=host, P=3306, etc. - $prop_val =~ s/\\,/,/g; $given_props{$prop_key} = $prop_val; } else {