| Bug #78743 | mysqltest's replace_regex can't match ^ (beginning of line) atom | ||
|---|---|---|---|
| Submitted: | 7 Oct 2015 22:46 | Modified: | 8 Oct 2015 15:32 |
| Reporter: | Dmitry Lenev | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | Tools: MTR / mysql-test-run | Severity: | S3 (Non-critical) |
| Version: | 8.0.0-git | OS: | Any |
| Assigned to: | CPU Architecture: | Any | |
[8 Oct 2015 15:32]
Paul DuBois
Fixed in 5.7.10. Changes for test suite. No changelog entry needed.
[18 Jun 2016 21:28]
Omer Barnir
Posted by developer: Reported version value updated to reflect release name change from 5.8 to 8.0

Description: --replace_regex command can't match and replace expressions using beginning of line '^' atom. Expressions with end of line atom - '$' work as expected. How to repeat: --replace_regex /^a/R/ select "a" as a; # Shown as: # select "a" as a; # a # a --replace_regex /a/R/ select "a" as a; # Shown as: # select "R" Rs R; # R # R --replace_regex /a$/R/ select "a" as a; # Shown as: # select "a" as R; # R # R Suggested fix: diff --git a/client/mysqltest.cc b/client/mysqltest.cc index e913d4c..f808248 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -10239,7 +10239,7 @@ int reg_replace(char** buf_p, int* buf_len_p, char *pattern, { /* find the match */ err_code= my_regexec(&r,str_p, r.re_nsub+1, subs, - (str_p == string) ? MY_REG_NOTBOL : 0); + (str_p != string) ? MY_REG_NOTBOL : 0); /* if regular expression error (eg. bad syntax, or out of memory) */ if (err_code && err_code != MY_REG_NOMATCH)