Merge lp:~percona-toolkit-dev/percona-toolkit/fix-ptc-index-bug-1199591-2.1 into lp:percona-toolkit/2.1

Proposed by Daniel Nichter
Status: Merged
Merged at revision: 537
Proposed branch: lp:~percona-toolkit-dev/percona-toolkit/fix-ptc-index-bug-1199591-2.1
Merge into: lp:percona-toolkit/2.1
Diff against target: 139 lines (+73/-7)
5 files modified
bin/pt-online-schema-change (+1/-1)
bin/pt-table-checksum (+1/-1)
lib/NibbleIterator.pm (+1/-1)
t/lib/NibbleIterator.t (+21/-4)
t/lib/samples/cardinality.sql (+49/-0)
To merge this branch: bzr merge lp:~percona-toolkit-dev/percona-toolkit/fix-ptc-index-bug-1199591-2.1
Reviewer Review Type Date Requested Status
Daniel Nichter Approve
Review via email: mp+174008@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-online-schema-change'
--- bin/pt-online-schema-change 2013-04-04 21:44:42 +0000
+++ bin/pt-online-schema-change 2013-07-10 17:30:43 +0000
@@ -5429,7 +5429,7 @@
5429 }5429 }
5430 @possible_indexes = sort {5430 @possible_indexes = sort {
5431 my $cmp5431 my $cmp
5432 = $indexes->{$b}->{cardinality} <=> $indexes->{$b}->{cardinality};5432 = $indexes->{$b}->{cardinality} <=> $indexes->{$a}->{cardinality};
5433 if ( $cmp == 0 ) {5433 if ( $cmp == 0 ) {
5434 $cmp = scalar @{$indexes->{$b}->{cols}}5434 $cmp = scalar @{$indexes->{$b}->{cols}}
5435 <=> scalar @{$indexes->{$a}->{cols}};5435 <=> scalar @{$indexes->{$a}->{cols}};
54365436
=== modified file 'bin/pt-table-checksum'
--- bin/pt-table-checksum 2013-06-25 23:40:41 +0000
+++ bin/pt-table-checksum 2013-07-10 17:30:43 +0000
@@ -6018,7 +6018,7 @@
6018 }6018 }
6019 @possible_indexes = sort {6019 @possible_indexes = sort {
6020 my $cmp6020 my $cmp
6021 = $indexes->{$b}->{cardinality} <=> $indexes->{$b}->{cardinality};6021 = $indexes->{$b}->{cardinality} <=> $indexes->{$a}->{cardinality};
6022 if ( $cmp == 0 ) {6022 if ( $cmp == 0 ) {
6023 $cmp = scalar @{$indexes->{$b}->{cols}}6023 $cmp = scalar @{$indexes->{$b}->{cols}}
6024 <=> scalar @{$indexes->{$a}->{cols}};6024 <=> scalar @{$indexes->{$a}->{cols}};
60256025
=== modified file 'lib/NibbleIterator.pm'
--- lib/NibbleIterator.pm 2013-01-03 00:19:16 +0000
+++ lib/NibbleIterator.pm 2013-07-10 17:30:43 +0000
@@ -554,7 +554,7 @@
554 @possible_indexes = sort {554 @possible_indexes = sort {
555 # Prefer the index with the highest cardinality.555 # Prefer the index with the highest cardinality.
556 my $cmp556 my $cmp
557 = $indexes->{$b}->{cardinality} <=> $indexes->{$b}->{cardinality};557 = $indexes->{$b}->{cardinality} <=> $indexes->{$a}->{cardinality};
558 if ( $cmp == 0 ) {558 if ( $cmp == 0 ) {
559 # Indexes have the same cardinality; prefer the one with559 # Indexes have the same cardinality; prefer the one with
560 # more columns.560 # more columns.
561561
=== modified file 't/lib/NibbleIterator.t'
--- t/lib/NibbleIterator.t 2012-12-04 01:50:32 +0000
+++ t/lib/NibbleIterator.t 2013-07-10 17:30:43 +0000
@@ -38,9 +38,6 @@
38if ( !$dbh ) {38if ( !$dbh ) {
39 plan skip_all => 'Cannot connect to sandbox master';39 plan skip_all => 'Cannot connect to sandbox master';
40}40}
41else {
42 plan tests => 54;
43}
4441
45my $q = new Quoter();42my $q = new Quoter();
46my $tp = new TableParser(Quoter=>$q);43my $tp = new TableParser(Quoter=>$q);
@@ -831,6 +828,26 @@
831 "Bug 995274: nibble iter works"828 "Bug 995274: nibble iter works"
832);829);
833830
831
832# #############################################################################
833# pt-table-checksum doesn't use non-unique index with highest cardinality
834# https://bugs.launchpad.net/percona-toolkit/+bug/1199591
835# #############################################################################
836
837diag(`/tmp/12345/use < $trunk/t/lib/samples/cardinality.sql >/dev/null`);
838
839$ni = make_nibble_iter(
840 db => 'cardb',
841 tbl => 't',
842 argv => [qw(--databases cardb --chunk-size 2)],
843);
844
845is(
846 $ni->{index},
847 'b',
848 "Use non-unique index with highest cardinality (bug 1199591)"
849);
850
834# #############################################################################851# #############################################################################
835# Done.852# Done.
836# #############################################################################853# #############################################################################
@@ -846,4 +863,4 @@
846);863);
847$sb->wipe_clean($dbh);864$sb->wipe_clean($dbh);
848ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");865ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
849exit;866done_testing;
850867
=== added file 't/lib/samples/cardinality.sql'
--- t/lib/samples/cardinality.sql 1970-01-01 00:00:00 +0000
+++ t/lib/samples/cardinality.sql 2013-07-10 17:30:43 +0000
@@ -0,0 +1,49 @@
1DROP DATABASE IF EXISTS cardb;
2CREATE DATABASE cardb;
3USE cardb;
4CREATE TABLE t (
5 high INT UNSIGNED NOT NULL,
6 low INT UNSIGNED NOT NULL,
7 INDEX a (low),
8 INDEX b (high),
9 INDEX c (low)
10) ENGINE=InnoDB;
11INSERT INTO t VALUES
12 (1, 1),
13 (2, 1),
14 (3, 1),
15 (4, 1),
16 (5, 1),
17 (6, 1),
18 (7, 1),
19 (8, 1),
20 (9, 1),
21 (10, 1),
22 (11, 1),
23 (12, 1),
24 (13, 1),
25 (14, 1),
26 (15, 1),
27 (16, 1),
28 (17, 1),
29 (18, 1),
30 (19, 1),
31 (20, 1),
32 (21, 2),
33 (22, 2),
34 (23, 2),
35 (24, 2),
36 (25, 2),
37 (26, 2),
38 (27, 2),
39 (28, 2),
40 (29, 2),
41 (30, 2),
42 (31, 2),
43 (32, 2),
44 (33, 2),
45 (34, 2),
46 (35, 2),
47 (36, 2),
48 (37, 2);
49ANALYZE TABLE t;

Subscribers

People subscribed via source and target branches