mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-12-19 01:09:21 +08:00
Add --default-engine to pt-osc.
This commit is contained in:
@@ -8461,6 +8461,9 @@ sub create_new_table{
|
|||||||
my $sql = $ddl;
|
my $sql = $ddl;
|
||||||
$sql =~ s/\ACREATE TABLE .*?\($/CREATE TABLE $quoted (/m;
|
$sql =~ s/\ACREATE TABLE .*?\($/CREATE TABLE $quoted (/m;
|
||||||
$sql =~ s/^ CONSTRAINT `/ CONSTRAINT `_/gm;
|
$sql =~ s/^ CONSTRAINT `/ CONSTRAINT `_/gm;
|
||||||
|
if ( $o->get('default-engine') ) {
|
||||||
|
$sql =~ s/\s+ENGINE=\S+//;
|
||||||
|
}
|
||||||
PTDEBUG && _d($sql);
|
PTDEBUG && _d($sql);
|
||||||
eval {
|
eval {
|
||||||
$cxn->dbh()->do($sql);
|
$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
|
50 seems likely to be unacceptably high for most servers, indicating that the
|
||||||
operation should be canceled immediately.
|
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
|
=item --defaults-file
|
||||||
|
|
||||||
short form: -F; type: string
|
short form: -F; type: string
|
||||||
|
|||||||
@@ -634,6 +634,31 @@ test_alter_table(
|
|||||||
qw(--no-drop-new-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.
|
# Done.
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
|
|||||||
20
t/pt-online-schema-change/samples/default-engine.sql
Normal file
20
t/pt-online-schema-change/samples/default-engine.sql
Normal 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
|
||||||
Reference in New Issue
Block a user