Merge lp:~percona-toolkit-dev/percona-toolkit/fix-1002448 into lp:percona-toolkit/2.1

Proposed by Brian Fraser
Status: Merged
Merged at revision: 273
Proposed branch: lp:~percona-toolkit-dev/percona-toolkit/fix-1002448
Merge into: lp:percona-toolkit/2.1
Diff against target: 68 lines (+33/-2)
3 files modified
bin/pt-online-schema-change (+1/-1)
t/pt-online-schema-change/bugs.t (+18/-1)
t/pt-online-schema-change/samples/bug-1002448.sql (+14/-0)
To merge this branch: bzr merge lp:~percona-toolkit-dev/percona-toolkit/fix-1002448
Reviewer Review Type Date Requested Status
Brian Fraser (community) Approve
Daniel Nichter Approve
Review via email: mp+107641@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Daniel Nichter (daniel-nichter) :
review: Approve
Revision history for this message
Brian Fraser (fraserbn) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/pt-online-schema-change'
2--- bin/pt-online-schema-change 2012-05-25 21:27:23 +0000
3+++ bin/pt-online-schema-change 2012-05-28 14:41:22 +0000
4@@ -6296,7 +6296,7 @@
5 # Find a pk or unique index to use for the delete trigger. can_nibble()
6 # above returns an index, but NibbleIterator will use non-unique indexes,
7 # so we have to do this again here.
8- my $indexes = $orig_tbl->{tbl_struct}->{indexes}; # brevity
9+ my $indexes = $orig_tbl->{tbl_struct}->{keys}; # brevity
10 foreach my $index ( $tp->sort_indexes($orig_tbl->{tbl_struct}) ) {
11 if ( $index eq 'PRIMARY' || $indexes->{$index}->{is_unique} ) {
12 PTDEBUG && _d('Delete trigger index:', Dumper($index));
13
14=== modified file 't/pt-online-schema-change/bugs.t'
15--- t/pt-online-schema-change/bugs.t 2012-05-16 16:04:52 +0000
16+++ t/pt-online-schema-change/bugs.t 2012-05-28 14:41:22 +0000
17@@ -29,7 +29,7 @@
18 plan skip_all => 'Cannot connect to sandbox slave1';
19 }
20 else {
21- plan tests => 2;
22+ plan tests => 3;
23 }
24
25 # The sandbox servers run with lock_wait_timeout=3 and it's not dynamic
26@@ -66,6 +66,23 @@
27 "Bug 994002: doesn't choose non-PK"
28 );
29
30+# ############################################################################
31+# https://bugs.launchpad.net/percona-toolkit/+bug/1002448
32+# ############################################################################
33+$sb->load_file('master', "$sample/bug-1002448.sql");
34+
35+$output = output(
36+ sub { pt_online_schema_change::main(@args,
37+ "$master_dsn,D=test1002448,t=table_name",
38+ "--alter", "add column (foo int)",
39+ qw(--chunk-size 2 --dry-run --print)) },
40+);
41+
42+
43+unlike $output,
44+ qr/\QThe original table `test1002448`.`table_name` does not have a PRIMARY KEY or a unique index which is required for the DELETE trigger/,
45+ "Bug 1002448: mistakenly uses indexes instead of keys";
46+
47 # #############################################################################
48 # Done.
49 # #############################################################################
50
51=== added file 't/pt-online-schema-change/samples/bug-1002448.sql'
52--- t/pt-online-schema-change/samples/bug-1002448.sql 1970-01-01 00:00:00 +0000
53+++ t/pt-online-schema-change/samples/bug-1002448.sql 2012-05-28 14:41:22 +0000
54@@ -0,0 +1,14 @@
55+drop database if exists test1002448;
56+create database test1002448;
57+use test1002448;
58+
59+CREATE TABLE `table_name` (
60+ `site` varchar(20) NOT NULL DEFAULT '',
61+ `update_name` varchar(32) NOT NULL DEFAULT '',
62+ `user` varchar(64) NOT NULL DEFAULT '',
63+ `time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
64+ `value` varchar(64) NOT NULL DEFAULT '',
65+ UNIQUE KEY `site` (`site`,`update_name`,`user`,`value`),
66+ KEY `user` (`user`)
67+) ENGINE=InnoDB DEFAULT CHARSET=latin1
68+

Subscribers

People subscribed via source and target branches