Merge lp:~percona-toolkit-dev/percona-toolkit/fix-dupe-key-bug-894140 into lp:percona-toolkit/2.1

Proposed by Daniel Nichter
Status: Merged
Merged at revision: 253
Proposed branch: lp:~percona-toolkit-dev/percona-toolkit/fix-dupe-key-bug-894140
Merge into: lp:percona-toolkit/2.1
Diff against target: 165 lines (+94/-4)
6 files modified
bin/pt-duplicate-key-checker (+1/-1)
lib/DuplicateKeyFinder.pm (+1/-1)
t/lib/DuplicateKeyFinder.t (+43/-1)
t/lib/samples/dupekeys/dupe-cluster-bug-894140.sql (+8/-0)
t/pt-duplicate-key-checker/basics.t (+12/-1)
t/pt-duplicate-key-checker/samples/bug-894140.txt (+29/-0)
To merge this branch: bzr merge lp:~percona-toolkit-dev/percona-toolkit/fix-dupe-key-bug-894140
Reviewer Review Type Date Requested Status
Daniel Nichter Approve
Review via email: mp+105744@code.launchpad.net
To post a comment you must log in.
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-duplicate-key-checker'
--- bin/pt-duplicate-key-checker 2012-04-03 19:42:45 +0000
+++ bin/pt-duplicate-key-checker 2012-05-15 01:11:18 +0000
@@ -2664,7 +2664,7 @@
2664 }2664 }
2665 else {2665 else {
2666 PTDEBUG && _d($right_name, 'not left-prefix of', $left_name);2666 PTDEBUG && _d($right_name, 'not left-prefix of', $left_name);
2667 next LEFT_KEY;2667 next RIGHT_KEY;
2668 }2668 }
2669 } # RIGHT_KEY2669 } # RIGHT_KEY
2670 } # LEFT_KEY2670 } # LEFT_KEY
26712671
=== modified file 'lib/DuplicateKeyFinder.pm'
--- lib/DuplicateKeyFinder.pm 2012-01-19 19:46:56 +0000
+++ lib/DuplicateKeyFinder.pm 2012-05-15 01:11:18 +0000
@@ -359,7 +359,7 @@
359 }359 }
360 else {360 else {
361 PTDEBUG && _d($right_name, 'not left-prefix of', $left_name);361 PTDEBUG && _d($right_name, 'not left-prefix of', $left_name);
362 next LEFT_KEY;362 next RIGHT_KEY;
363 }363 }
364 } # RIGHT_KEY364 } # RIGHT_KEY
365 } # LEFT_KEY365 } # LEFT_KEY
366366
=== modified file 't/lib/DuplicateKeyFinder.t'
--- t/lib/DuplicateKeyFinder.t 2012-03-06 13:56:08 +0000
+++ t/lib/DuplicateKeyFinder.t 2012-05-15 01:11:18 +0000
@@ -9,7 +9,7 @@
9use strict;9use strict;
10use warnings FATAL => 'all';10use warnings FATAL => 'all';
11use English qw(-no_match_vars);11use English qw(-no_match_vars);
12use Test::More tests => 37;12use Test::More tests => 38;
1313
14use DuplicateKeyFinder;14use DuplicateKeyFinder;
15use Quoter;15use Quoter;
@@ -729,6 +729,48 @@
729 'Issue 1192'729 'Issue 1192'
730);730);
731731
732
733# #############################################################################
734# https://bugs.launchpad.net/percona-toolkit/+bug/894140
735# #############################################################################
736$ddl = load_file('t/lib/samples/dupekeys/dupe-cluster-bug-894140.sql');
737$dupes = [];
738($keys, $ck) = $tp->get_keys($ddl, $opt);
739$dk->get_duplicate_keys(
740 $keys,
741 clustered_key => $ck,
742 clustered => 1,
743 callback => $callback,
744 tbl_info => { engine => 'InnoDB', ddl => $ddl },
745);
746
747is_deeply(
748 $dupes,
749 [
750 {
751 cols => [ 'row_id' ],
752 ddl => 'UNIQUE KEY `row_id` (`row_id`),',
753 dupe_type => 'exact',
754 duplicate_of => 'PRIMARY',
755 duplicate_of_cols => [ 'row_id' ],
756 duplicate_of_ddl => 'PRIMARY KEY (`row_id`),',
757 key => 'row_id',
758 reason => 'row_id is a duplicate of PRIMARY',
759 },
760 {
761 cols => [ 'player_id' ],
762 ddl => 'KEY `player_id_2` (`player_id`)',
763 dupe_type => 'exact',
764 duplicate_of => 'player_id',
765 duplicate_of_cols => [ 'player_id' ],
766 duplicate_of_ddl => 'UNIQUE KEY `player_id` (`player_id`),',
767 key => 'player_id_2',
768 reason => 'player_id_2 is a duplicate of player_id',
769 },
770 ],
771 'Finds duplicates OK on uppercase columns',
772);
773
732# #############################################################################774# #############################################################################
733# Done.775# Done.
734# #############################################################################776# #############################################################################
735777
=== added file 't/lib/samples/dupekeys/dupe-cluster-bug-894140.sql'
--- t/lib/samples/dupekeys/dupe-cluster-bug-894140.sql 1970-01-01 00:00:00 +0000
+++ t/lib/samples/dupekeys/dupe-cluster-bug-894140.sql 2012-05-15 01:11:18 +0000
@@ -0,0 +1,8 @@
1CREATE TABLE `bug_894140` (
2 `row_id` bigint(20) NOT NULL AUTO_INCREMENT,
3 `player_id` bigint(20) DEFAULT NULL,
4 PRIMARY KEY (`row_id`),
5 UNIQUE KEY `row_id` (`row_id`),
6 UNIQUE KEY `player_id` (`player_id`),
7 KEY `player_id_2` (`player_id`)
8) ENGINE=InnoDB DEFAULT CHARSET=utf8
09
=== modified file 't/pt-duplicate-key-checker/basics.t'
--- t/pt-duplicate-key-checker/basics.t 2011-07-12 22:56:55 +0000
+++ t/pt-duplicate-key-checker/basics.t 2012-05-15 01:11:18 +0000
@@ -23,7 +23,7 @@
23 plan skip_all => 'Cannot connect to sandbox master';23 plan skip_all => 'Cannot connect to sandbox master';
24}24}
25else {25else {
26 plan tests => 8;26 plan tests => 9;
27}27}
2828
29my $output;29my $output;
@@ -95,6 +95,17 @@
95 'No results for nonexistent db'95 'No results for nonexistent db'
96);96);
9797
98$dbh->do('create database test');
99$sb->load_file('master', 't/lib/samples/dupekeys/dupe-cluster-bug-894140.sql', 'test');
100
101ok(
102 no_diff(
103 sub { pt_duplicate_key_checker::main(@args, qw(-d test)) },
104 "$sample/bug-894140.txt",
105 ),
106 "Bug 894140"
107);
108
98# #############################################################################109# #############################################################################
99# Done.110# Done.
100# #############################################################################111# #############################################################################
101112
=== added file 't/pt-duplicate-key-checker/samples/bug-894140.txt'
--- t/pt-duplicate-key-checker/samples/bug-894140.txt 1970-01-01 00:00:00 +0000
+++ t/pt-duplicate-key-checker/samples/bug-894140.txt 2012-05-15 01:11:18 +0000
@@ -0,0 +1,29 @@
1# ########################################################################
2# test.bug_894140
3# ########################################################################
4
5# row_id is a duplicate of PRIMARY
6# Key definitions:
7# UNIQUE KEY `row_id` (`row_id`),
8# PRIMARY KEY (`row_id`),
9# Column types:
10# `row_id` bigint(20) not null auto_increment
11# To remove this duplicate index, execute:
12ALTER TABLE `test`.`bug_894140` DROP INDEX `row_id`;
13
14# player_id_2 is a duplicate of player_id
15# Key definitions:
16# KEY `player_id_2` (`player_id`)
17# UNIQUE KEY `player_id` (`player_id`),
18# Column types:
19# `player_id` bigint(20) default null
20# To remove this duplicate index, execute:
21ALTER TABLE `test`.`bug_894140` DROP INDEX `player_id_2`;
22
23# ########################################################################
24# Summary of indexes
25# ########################################################################
26
27# Size Duplicate Indexes 17
28# Total Duplicate Indexes 2
29# Total Indexes 4

Subscribers

People subscribed via source and target branches