Comment 1 for bug 1289516

Revision history for this message
Martin Ringehahn (martwn) wrote : Re: broken fingerprinting of specific REPLACE queries

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
 # 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
 }

=== modified file 't/lib/QueryRewriter.t'
--- t/lib/QueryRewriter.t 2013-09-27 02:16:19 +0000
+++ t/lib/QueryRewriter.t 2014-03-09 00:15:46 +0000
@@ -247,6 +247,12 @@
 );

 is(
+ $qr->fingerprint('insert into foo values("(1),(2)")'),
+ 'insert into foo values(?+)',
+ 'not confused by parentheses inside a quoted string',
+);
+
+is(
    $qr->fingerprint('select * from foo limit 5'),
    'select * from foo limit ?',
    'limit alone',