Add --default-engine to pt-osc.

This commit is contained in:
Daniel Nichter
2012-10-22 08:44:44 -06:00
parent 046c4c7cc0
commit 575c94b29e
3 changed files with 59 additions and 0 deletions

View File

@@ -8461,6 +8461,9 @@ sub create_new_table{
my $sql = $ddl;
$sql =~ s/\ACREATE TABLE .*?\($/CREATE TABLE $quoted (/m;
$sql =~ s/^ CONSTRAINT `/ CONSTRAINT `_/gm;
if ( $o->get('default-engine') ) {
$sql =~ s/\s+ENGINE=\S+//;
}
PTDEBUG && _d($sql);
eval {
$cxn->dbh()->do($sql);
@@ -9619,6 +9622,17 @@ single value of Threads_running that is wrong for every server, but a default of
50 seems likely to be unacceptably high for most servers, indicating that the
operation should be canceled immediately.
=item --default-engine
Remove C<ENGINE> from the new table.
By default the new table is created with the same table options as
the original table, so if the original table uses InnoDB, then the new
table will use InnoDB. In certain cases involving replication, this may
cause unintended changes on replicas which use a different engine for
the same table. Specifying this option causes the new table to be
created with the system's default engine.
=item --defaults-file
short form: -F; type: string

View File

@@ -634,6 +634,31 @@ test_alter_table(
qw(--no-drop-new-table)],
);
# #############################################################################
# --default-engine
# #############################################################################
SKIP: {
skip "--default-engine tests require < MySQL 5.5", 1
if $sandbox_version ge '5.5';
# The alter doesn't actually change the engine (test_type),
# but the --default-engine does because the table uses InnoDB
# but MyISAM is the default engine before MySQL 5.5.
test_alter_table(
name => "--default-engine",
table => "pt_osc.t",
file => "default-engine.sql",
test_type => "new_engine",
new_engine => "MyISAM",
cmds => [
'--default-engine',
'--execute',
'--alter', 'ADD INDEX (d)',
],
);
}
# #############################################################################
# Done.
# #############################################################################

View File

@@ -0,0 +1,20 @@
DROP DATABASE IF EXISTS pt_osc;
CREATE DATABASE pt_osc;
USE pt_osc;
CREATE TABLE t (
id int auto_increment primary key,
c char(32),
d date,
unique index (c(32))
) ENGINE=InnoDB;
INSERT INTO pt_osc.t VALUES
(null, 'a', now()),
(null, 'b', now()),
(null, 'c', now()),
(null, 'd', now()),
(null, 'e', now()),
(null, 'f', now()),
(null, 'g', now()),
(null, 'h', now()),
(null, 'i', now()),
(null, 'j', now()); -- 10