Merge lp:~percona-toolkit-dev/percona-toolkit/pt-osc-default-engine into lp:percona-toolkit/2.1

Proposed by Daniel Nichter
Status: Superseded
Proposed branch: lp:~percona-toolkit-dev/percona-toolkit/pt-osc-default-engine
Merge into: lp:percona-toolkit/2.1
Diff against target: 92 lines (+59/-0)
3 files modified
bin/pt-online-schema-change (+14/-0)
t/pt-online-schema-change/basics.t (+25/-0)
t/pt-online-schema-change/samples/default-engine.sql (+20/-0)
To merge this branch: bzr merge lp:~percona-toolkit-dev/percona-toolkit/pt-osc-default-engine
Reviewer Review Type Date Requested Status
Daniel Nichter Pending
Review via email: mp+133599@code.launchpad.net

This proposal has been superseded by a proposal from 2012-11-10.

To post a comment you must log in.

Unmerged revisions

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-11-08 23:38:07 +0000
3+++ bin/pt-online-schema-change 2012-11-08 23:43:22 +0000
4@@ -8585,6 +8585,9 @@
5 my $sql = $ddl;
6 $sql =~ s/\ACREATE TABLE .*?\($/CREATE TABLE $quoted (/m;
7 $sql =~ s/^ CONSTRAINT `/ CONSTRAINT `_/gm;
8+ if ( $o->get('default-engine') ) {
9+ $sql =~ s/\s+ENGINE=\S+//;
10+ }
11 PTDEBUG && _d($sql);
12 eval {
13 $cxn->dbh()->do($sql);
14@@ -9752,6 +9755,17 @@
15 50 seems likely to be unacceptably high for most servers, indicating that the
16 operation should be canceled immediately.
17
18+=item --default-engine
19+
20+Remove C<ENGINE> from the new table.
21+
22+By default the new table is created with the same table options as
23+the original table, so if the original table uses InnoDB, then the new
24+table will use InnoDB. In certain cases involving replication, this may
25+cause unintended changes on replicas which use a different engine for
26+the same table. Specifying this option causes the new table to be
27+created with the system's default engine.
28+
29 =item --defaults-file
30
31 short form: -F; type: string
32
33=== modified file 't/pt-online-schema-change/basics.t'
34--- t/pt-online-schema-change/basics.t 2012-06-09 18:43:33 +0000
35+++ t/pt-online-schema-change/basics.t 2012-11-08 23:43:22 +0000
36@@ -635,6 +635,31 @@
37 );
38
39 # #############################################################################
40+# --default-engine
41+# #############################################################################
42+
43+SKIP: {
44+ skip "--default-engine tests require < MySQL 5.5", 1
45+ if $sandbox_version ge '5.5';
46+
47+ # The alter doesn't actually change the engine (test_type),
48+ # but the --default-engine does because the table uses InnoDB
49+ # but MyISAM is the default engine before MySQL 5.5.
50+ test_alter_table(
51+ name => "--default-engine",
52+ table => "pt_osc.t",
53+ file => "default-engine.sql",
54+ test_type => "new_engine",
55+ new_engine => "MyISAM",
56+ cmds => [
57+ '--default-engine',
58+ '--execute',
59+ '--alter', 'ADD INDEX (d)',
60+ ],
61+ );
62+}
63+
64+# #############################################################################
65 # Done.
66 # #############################################################################
67 $master_dbh->do("UPDATE mysql.proc SET created='2012-06-05 00:00:00', modified='2012-06-05 00:00:00'");
68
69=== added file 't/pt-online-schema-change/samples/default-engine.sql'
70--- t/pt-online-schema-change/samples/default-engine.sql 1970-01-01 00:00:00 +0000
71+++ t/pt-online-schema-change/samples/default-engine.sql 2012-11-08 23:43:22 +0000
72@@ -0,0 +1,20 @@
73+DROP DATABASE IF EXISTS pt_osc;
74+CREATE DATABASE pt_osc;
75+USE pt_osc;
76+CREATE TABLE t (
77+ id int auto_increment primary key,
78+ c char(32),
79+ d date,
80+ unique index (c(32))
81+) ENGINE=InnoDB;
82+INSERT INTO pt_osc.t VALUES
83+ (null, 'a', now()),
84+ (null, 'b', now()),
85+ (null, 'c', now()),
86+ (null, 'd', now()),
87+ (null, 'e', now()),
88+ (null, 'f', now()),
89+ (null, 'g', now()),
90+ (null, 'h', now()),
91+ (null, 'i', now()),
92+ (null, 'j', now()); -- 10

Subscribers

People subscribed via source and target branches