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
=== modified file 'bin/pt-query-digest'
--- bin/pt-query-digest 2013-08-03 19:43:19 +0000
+++ bin/pt-query-digest 2013-08-03 21:09:30 +0000
@@ -2962,6 +2962,7 @@
2962 eval $QueryParser::tbl_ident;2962 eval $QueryParser::tbl_ident;
2963 my ( $dds ) = $query =~ /^\s*($QueryParser::data_def_stmts)\b/i;2963 my ( $dds ) = $query =~ /^\s*($QueryParser::data_def_stmts)\b/i;
2964 if ( $dds) {2964 if ( $dds) {
2965 $query =~ s/\s+IF(?:\s+NOT)?\s+EXISTS/ /i;
2965 my ( $obj ) = $query =~ m/$dds.+(DATABASE|TABLE)\b/i;2966 my ( $obj ) = $query =~ m/$dds.+(DATABASE|TABLE)\b/i;
2966 $obj = uc $obj if $obj;2967 $obj = uc $obj if $obj;
2967 PTDEBUG && _d('Data def statment:', $dds, 'obj:', $obj);2968 PTDEBUG && _d('Data def statment:', $dds, 'obj:', $obj);
29682969
=== modified file 'lib/QueryRewriter.pm'
--- lib/QueryRewriter.pm 2013-08-03 18:44:41 +0000
+++ lib/QueryRewriter.pm 2013-08-03 21:09:30 +0000
@@ -298,6 +298,8 @@
298 eval $QueryParser::tbl_ident;298 eval $QueryParser::tbl_ident;
299 my ( $dds ) = $query =~ /^\s*($QueryParser::data_def_stmts)\b/i;299 my ( $dds ) = $query =~ /^\s*($QueryParser::data_def_stmts)\b/i;
300 if ( $dds) {300 if ( $dds) {
301 # https://bugs.launchpad.net/percona-toolkit/+bug/821690
302 $query =~ s/\s+IF(?:\s+NOT)?\s+EXISTS/ /i;
301 my ( $obj ) = $query =~ m/$dds.+(DATABASE|TABLE)\b/i;303 my ( $obj ) = $query =~ m/$dds.+(DATABASE|TABLE)\b/i;
302 $obj = uc $obj if $obj;304 $obj = uc $obj if $obj;
303 PTDEBUG && _d('Data def statment:', $dds, 'obj:', $obj);305 PTDEBUG && _d('Data def statment:', $dds, 'obj:', $obj);
304306
=== modified file 't/lib/QueryRewriter.t'
--- t/lib/QueryRewriter.t 2013-08-03 18:44:41 +0000
+++ t/lib/QueryRewriter.t 2013-08-03 21:09:30 +0000
@@ -1440,6 +1440,20 @@
1440 "distill REPLACE without INTO (bug 984053)"1440 "distill REPLACE without INTO (bug 984053)"
1441);1441);
14421442
1443# IF EXISTS
1444# https://bugs.launchpad.net/percona-toolkit/+bug/821690
1445is(
1446 $qr->distill("DROP TABLE IF EXISTS foo"),
1447 "DROP TABLE foo",
1448 "distill DROP TABLE IF EXISTS foo (bug 821690)"
1449);
1450
1451is(
1452 $qr->distill("CREATE TABLE IF NOT EXISTS foo"),
1453 "CREATE TABLE foo",
1454 "distill CREATE TABLE IF NOT EXISTS foo",
1455);
1456
1443# #############################################################################1457# #############################################################################
1444# Done.1458# Done.
1445# #############################################################################1459# #############################################################################
14461460
=== modified file 't/pt-query-digest/processlist.t'
--- t/pt-query-digest/processlist.t 2012-11-21 16:58:40 +0000
+++ t/pt-query-digest/processlist.t 2013-08-03 21:09:30 +0000
@@ -27,9 +27,6 @@
27if ( !$dbh ) {27if ( !$dbh ) {
28 plan skip_all => 'Cannot connect to sandbox master';28 plan skip_all => 'Cannot connect to sandbox master';
29}29}
30else {
31 plan tests => 3;
32}
3330
34my @args = qw(-F /tmp/12345/my.sandbox.cnf --processlist h=127.1 --report-format query_report);31my @args = qw(-F /tmp/12345/my.sandbox.cnf --processlist h=127.1 --report-format query_report);
3532
@@ -58,21 +55,18 @@
58# the usual stddev. -- stddev doesn't matter much. It's the other vals55# the usual stddev. -- stddev doesn't matter much. It's the other vals
59# that indicate that --processlist works.56# that indicate that --processlist works.
60$exec =~ s/(\S+) 3s$/786ms 3s/;57$exec =~ s/(\S+) 3s$/786ms 3s/;
61TODO: {58ok(
62 local $::TODO = "This is a timing-related test, which may occasionally fail";59 no_diff(
63 ok(60 $exec,
64 no_diff(61 "t/pt-query-digest/samples/proclist001.txt",
65 $exec,62 cmd_output => 1,
66 "t/pt-query-digest/samples/proclist001.txt",63 ),
67 cmd_output => 1,64 "--processlist correctly observes and measures multiple queries"
68 ),65);
69 "--processlist correctly observes and measures multiple queries"
70 );
71}
7266
73# #############################################################################67# #############################################################################
74# Done.68# Done.
75# #############################################################################69# #############################################################################
76$sb->wipe_clean($dbh);70$sb->wipe_clean($dbh);
77ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");71ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
78exit;72done_testing;

Subscribers

People subscribed via source and target branches