Merge lp:~percona-toolkit-dev/percona-toolkit/fix-pqd-distill-bug-821690 into lp:percona-toolkit/2.2

Proposed by Daniel Nichter
Status: Merged
Merged at revision: 586
Proposed branch: lp:~percona-toolkit-dev/percona-toolkit/fix-pqd-distill-bug-821690
Merge into: lp:percona-toolkit/2.2
Diff against target: 94 lines (+26/-15)
4 files modified
bin/pt-query-digest (+1/-0)
lib/QueryRewriter.pm (+2/-0)
t/lib/QueryRewriter.t (+14/-0)
t/pt-query-digest/processlist.t (+9/-15)
To merge this branch: bzr merge lp:~percona-toolkit-dev/percona-toolkit/fix-pqd-distill-bug-821690
Reviewer Review Type Date Requested Status
Daniel Nichter Approve
Review via email: mp+178438@code.launchpad.net
To post a comment you must log in.
587. By Daniel Nichter

Update QueryRewriter in pqd.

588. By Daniel Nichter

Fix 'unexpectedly succeeded' in t/pt-query-digest/processlist.t.

Revision history for this message
Daniel Nichter (daniel-nichter) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/pt-query-digest'
2--- bin/pt-query-digest 2013-08-03 19:43:19 +0000
3+++ bin/pt-query-digest 2013-08-03 21:09:30 +0000
4@@ -2962,6 +2962,7 @@
5 eval $QueryParser::tbl_ident;
6 my ( $dds ) = $query =~ /^\s*($QueryParser::data_def_stmts)\b/i;
7 if ( $dds) {
8+ $query =~ s/\s+IF(?:\s+NOT)?\s+EXISTS/ /i;
9 my ( $obj ) = $query =~ m/$dds.+(DATABASE|TABLE)\b/i;
10 $obj = uc $obj if $obj;
11 PTDEBUG && _d('Data def statment:', $dds, 'obj:', $obj);
12
13=== modified file 'lib/QueryRewriter.pm'
14--- lib/QueryRewriter.pm 2013-08-03 18:44:41 +0000
15+++ lib/QueryRewriter.pm 2013-08-03 21:09:30 +0000
16@@ -298,6 +298,8 @@
17 eval $QueryParser::tbl_ident;
18 my ( $dds ) = $query =~ /^\s*($QueryParser::data_def_stmts)\b/i;
19 if ( $dds) {
20+ # https://bugs.launchpad.net/percona-toolkit/+bug/821690
21+ $query =~ s/\s+IF(?:\s+NOT)?\s+EXISTS/ /i;
22 my ( $obj ) = $query =~ m/$dds.+(DATABASE|TABLE)\b/i;
23 $obj = uc $obj if $obj;
24 PTDEBUG && _d('Data def statment:', $dds, 'obj:', $obj);
25
26=== modified file 't/lib/QueryRewriter.t'
27--- t/lib/QueryRewriter.t 2013-08-03 18:44:41 +0000
28+++ t/lib/QueryRewriter.t 2013-08-03 21:09:30 +0000
29@@ -1440,6 +1440,20 @@
30 "distill REPLACE without INTO (bug 984053)"
31 );
32
33+# IF EXISTS
34+# https://bugs.launchpad.net/percona-toolkit/+bug/821690
35+is(
36+ $qr->distill("DROP TABLE IF EXISTS foo"),
37+ "DROP TABLE foo",
38+ "distill DROP TABLE IF EXISTS foo (bug 821690)"
39+);
40+
41+is(
42+ $qr->distill("CREATE TABLE IF NOT EXISTS foo"),
43+ "CREATE TABLE foo",
44+ "distill CREATE TABLE IF NOT EXISTS foo",
45+);
46+
47 # #############################################################################
48 # Done.
49 # #############################################################################
50
51=== modified file 't/pt-query-digest/processlist.t'
52--- t/pt-query-digest/processlist.t 2012-11-21 16:58:40 +0000
53+++ t/pt-query-digest/processlist.t 2013-08-03 21:09:30 +0000
54@@ -27,9 +27,6 @@
55 if ( !$dbh ) {
56 plan skip_all => 'Cannot connect to sandbox master';
57 }
58-else {
59- plan tests => 3;
60-}
61
62 my @args = qw(-F /tmp/12345/my.sandbox.cnf --processlist h=127.1 --report-format query_report);
63
64@@ -58,21 +55,18 @@
65 # the usual stddev. -- stddev doesn't matter much. It's the other vals
66 # that indicate that --processlist works.
67 $exec =~ s/(\S+) 3s$/786ms 3s/;
68-TODO: {
69- local $::TODO = "This is a timing-related test, which may occasionally fail";
70- ok(
71- no_diff(
72- $exec,
73- "t/pt-query-digest/samples/proclist001.txt",
74- cmd_output => 1,
75- ),
76- "--processlist correctly observes and measures multiple queries"
77- );
78-}
79+ok(
80+ no_diff(
81+ $exec,
82+ "t/pt-query-digest/samples/proclist001.txt",
83+ cmd_output => 1,
84+ ),
85+ "--processlist correctly observes and measures multiple queries"
86+);
87
88 # #############################################################################
89 # Done.
90 # #############################################################################
91 $sb->wipe_clean($dbh);
92 ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
93-exit;
94+done_testing;

Subscribers

People subscribed via source and target branches