Skip to content

Commit

Permalink
Don't match REPLACE() function as REPLACE command.
Browse files Browse the repository at this point in the history
git-svn-id: http://maatkit.googlecode.com/svn/trunk@4213 dfb901c2-3250-0410-b216-0b33211c9131
  • Loading branch information
daniel@percona.com committed Jul 21, 2009
1 parent 874b672 commit f09b95b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion common/QueryParser.pm
Expand Up @@ -188,7 +188,7 @@ sub split {
# INSERT INTO ... SELECT ...
# split returns ('INSERT', 'INTO ...', 'SELECT', '...'). Therefore,
# we must re-attach each verb to its statement; we do this later...
my @split_statements = grep { $_ } split(m/\b($verbs\b)/io, $query);
my @split_statements = grep { $_ } split(m/\b($verbs\b(?!(?:\s*\()))/io, $query);

my @statements;
if ( @split_statements == 1 ) {
Expand Down
11 changes: 10 additions & 1 deletion common/t/QueryParser.t
Expand Up @@ -3,7 +3,7 @@
use strict;
use warnings FATAL => 'all';

use Test::More tests => 93;
use Test::More tests => 94;
use English qw(-no_match_vars);

require '../QueryRewriter.pm';
Expand Down Expand Up @@ -553,6 +553,15 @@ is_deeply(
'split 1 statement, CREATE'
);

$sql = "select num from db.tbl where replace(col,' ','') = 'foo'";
is_deeply(
[ $qp->split($sql) ],
[
$sql,
],
'split 1 statement, SELECT with REPLACE() function'
);

# #############################################################################
# Done.
# #############################################################################
Expand Down

0 comments on commit f09b95b

Please sign in to comment.