The diff at the end of the comment is for a test case that reproduces this issue. It appears that the following optimization from QueryRewriter->fingerprint() is a little too greedy and chops off the VALUES incorrectly. When this block is removed, the test succeeds (with some other tests failing, of course).
# mysqldump's INSERT statements will have long values() lists, don't waste
# time on them... they also tend to segfault Perl on some machines when you
# get to the "# Collapse IN() and VALUES() lists" regex below!
if ( my ($beginning) = $query =~ m/\A((?:INSERT|REPLACE)(?: IGNORE)?\s+INTO.+?VALUES\s*\(.*?\))\s*,\s*\(/is ) {
$query = $beginning; # Shorten multi-value INSERT statements ASAP
}
Some triaging:
The diff at the end of the comment is for a test case that reproduces this issue. It appears that the following optimization from QueryRewriter- >fingerprint( ) is a little too greedy and chops off the VALUES incorrectly. When this block is removed, the test succeeds (with some other tests failing, of course).
# mysqldump's INSERT statements will have long values() lists, don't waste :INSERT| REPLACE) (?: IGNORE) ?\s+INTO. +?VALUES\ s*\(.*? \))\s*, \s*\(/is ) {
# time on them... they also tend to segfault Perl on some machines when you
# get to the "# Collapse IN() and VALUES() lists" regex below!
if ( my ($beginning) = $query =~ m/\A((?
$query = $beginning; # Shorten multi-value INSERT statements ASAP
}
=== modified file 't/lib/ QueryRewriter. t' iter.t 2013-09-27 02:16:19 +0000 iter.t 2014-03-09 00:15:46 +0000
--- t/lib/QueryRewr
+++ t/lib/QueryRewr
@@ -247,6 +247,12 @@
);
is( t('insert into foo values( "(1),(2) ")'), >fingerprint( 'select * from foo limit 5'),
+ $qr->fingerprin
+ 'insert into foo values(?+)',
+ 'not confused by parentheses inside a quoted string',
+);
+
+is(
$qr-
'select * from foo limit ?',
'limit alone',