~percona-toolkit-dev/percona-toolkit/fix-929046-pt-qa-sub.001-lit.001-lit.002-fix

  • Committer: Brian Fraser
  • Date: 2012-12-03 03:17:39 UTC
  • Revision ID: brian.fraser@percona.com-20121203031739-mls0481lg72bwzkw
Fix for bug 929046: SUB.001, LIT.001 and LIT.002 are sensitive to program state

The original bug was about SUB.001, but LIT.00[12] were affected
as well. The bug boiled down to using //g on $event->{arg}, but
here's a simplified version:

        my $str = "abc in stuff";
        # This will print "6"
        say $str =~ /in/g  ? pos($str) : "no match";
        # This will print "no match"
        say $str =~ /abc/g ? pos($str) : "no match";

The second doesn't match because it will start from after
the "in" that the previous regex matched, at which point
it's too late to match abc.

There's two solutions to this: First, to use lvalue pos() before
each match, ala pos($str) = 0; -- But that's doing a lot of
extra stuff to work around our own bug. The other solution,
and what this commit implements, is not using //g and pos() at all,
instead using the @+ variable. $+[0] already holds the data we need,
at no extra cost, and to boot makes things slightly faster.

So what was previously

        if ( $str =~ m/./g ) {
          return pos($str)
        }

Is now

        if ( $str =~ m/./ ) {
          return $+[0];
        }
Filename Latest Rev Last Changed Committer Comment Size
..
bin 1 12 years ago Daniel Nichter Init repo directory structure. Diff
config 1 12 years ago Daniel Nichter Init repo directory structure. Diff
docs 1 12 years ago Daniel Nichter Init repo directory structure. Diff
lib 1 12 years ago Daniel Nichter Init repo directory structure. Diff
sandbox 2 12 years ago Daniel Nichter Add lib/, t/lib/, and sandbox/. All modules are u Diff
t 1 12 years ago Daniel Nichter Init repo directory structure. Diff
util 2 12 years ago Daniel Nichter Add lib/, t/lib/, and sandbox/. All modules are u Diff
.bzrignore 306.1.1 11 years ago Daniel Nichter Create util/build-snapshot and ignore /snapshot. 126 bytes Diff Download File
Changelog 464.1.8 11 years ago Daniel Nichter Check and update tool versions, release notes, use 18.6 KB Diff Download File
COPYING 34 12 years ago Daniel Nichter Add standard pkg files (COPYING, README, etc.), pe 17.6 KB Diff Download File
INSTALL 34 12 years ago Daniel Nichter Add standard pkg files (COPYING, README, etc.), pe 1.4 KB Diff Download File
Makefile.PL 464.1.8 11 years ago Daniel Nichter Check and update tool versions, release notes, use 483 bytes Diff Download File
MANIFEST 241 12 years ago Daniel Nichter Build percona-toolkit-2.1.1 731 bytes Diff Download File
README 34 12 years ago Daniel Nichter Add standard pkg files (COPYING, README, etc.), pe 1.1 KB Diff Download File