mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-20 02:44:58 +00:00
bug-984057 Tests for --preserve-triggers
This commit is contained in:
@@ -3381,6 +3381,7 @@ sub check_table {
|
|||||||
$self->{check_table_error} = $e;
|
$self->{check_table_error} = $e;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !$row->[0] || $row->[0] ne $tbl ) {
|
if ( !$row->[0] || $row->[0] ne $tbl ) {
|
||||||
PTDEBUG && _d('Table does not exist');
|
PTDEBUG && _d('Table does not exist');
|
||||||
return 0;
|
return 0;
|
||||||
@@ -8923,11 +8924,11 @@ sub main {
|
|||||||
$pr = new Progress(
|
$pr = new Progress(
|
||||||
jobsize => scalar @$slaves,
|
jobsize => scalar @$slaves,
|
||||||
spec => $o->get('progress'),
|
spec => $o->get('progress'),
|
||||||
name => "Waiting for " . $slave->name(),
|
name => "Waiting for slave at " . $slave->{dsn_name},
|
||||||
);
|
);
|
||||||
$pr_first_report = sub {
|
$pr_first_report = sub {
|
||||||
print "Waiting forever for new table $new_tbl->{name} to replicate "
|
print "Waiting forever for new table $new_tbl->{name} to replicate "
|
||||||
. "to " . $slave->name() . "...\n";
|
. "to " . $slave->{dsn_name} . "...\n";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
$pr->start() if $pr;
|
$pr->start() if $pr;
|
||||||
|
@@ -11,7 +11,7 @@ pid-file = /tmp/PORT/data/mysql_sandboxPORT.pid
|
|||||||
basedir = PERCONA_TOOLKIT_SANDBOX
|
basedir = PERCONA_TOOLKIT_SANDBOX
|
||||||
datadir = /tmp/PORT/data
|
datadir = /tmp/PORT/data
|
||||||
key_buffer_size = 16M
|
key_buffer_size = 16M
|
||||||
innodb_buffer_pool_size = 16M
|
innodb_buffer_pool_size = 64M
|
||||||
innodb_data_home_dir = /tmp/PORT/data
|
innodb_data_home_dir = /tmp/PORT/data
|
||||||
innodb_log_group_home_dir = /tmp/PORT/data
|
innodb_log_group_home_dir = /tmp/PORT/data
|
||||||
innodb_data_file_path = ibdata1:10M:autoextend
|
innodb_data_file_path = ibdata1:10M:autoextend
|
||||||
@@ -26,3 +26,4 @@ log-error = /tmp/PORT/data/mysqld.log
|
|||||||
innodb_lock_wait_timeout = 3
|
innodb_lock_wait_timeout = 3
|
||||||
general_log
|
general_log
|
||||||
general_log_file = genlog
|
general_log_file = genlog
|
||||||
|
innodb_flush_log_at_trx_commit=2
|
||||||
|
@@ -819,9 +819,51 @@ like(
|
|||||||
|
|
||||||
$master_dbh->do("DROP DATABASE test_recursion_method");
|
$master_dbh->do("DROP DATABASE test_recursion_method");
|
||||||
|
|
||||||
|
|
||||||
|
# #############################################################################
|
||||||
|
# Tests for --preserve-triggers option
|
||||||
|
# #############################################################################
|
||||||
|
|
||||||
|
test_alter_table(
|
||||||
|
name => "Basic --preserve-triggers",
|
||||||
|
table => "pt_osc.account",
|
||||||
|
pk_col => "id",
|
||||||
|
file => "triggers.sql",
|
||||||
|
test_type => "add_col",
|
||||||
|
new_col => "foo",
|
||||||
|
cmds => [
|
||||||
|
qw(--execute --preserve-triggers), '--alter', 'ADD COLUMN foo INT',
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
test_alter_table(
|
||||||
|
name => "--preserve-triggers --no-swap-table",
|
||||||
|
table => "pt_osc.account",
|
||||||
|
pk_col => "id",
|
||||||
|
test_type => "add_col",
|
||||||
|
new_col => "foo",
|
||||||
|
cmds => [
|
||||||
|
qw(--execute --preserve-triggers --no-swap-table), '--alter', 'ADD COLUMN foo2 INT',
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
test_alter_table(
|
||||||
|
name => "FK rebuild_constraints --preserve-triggers",
|
||||||
|
table => "sakila.film",
|
||||||
|
pk_col => "film_id",
|
||||||
|
test_type => "add_col",
|
||||||
|
file => "sakila_triggers.sql",
|
||||||
|
new_col => "foo",
|
||||||
|
check_fks => "rebuild_constraints",
|
||||||
|
cmds => [
|
||||||
|
qw(--execute --preserve-triggers --alter-foreign-keys-method rebuild_constraints), '--alter', 'ADD COLUMN foo INT',
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Done.
|
# Done.
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
$sb->wipe_clean($master_dbh);
|
$sb->wipe_clean($master_dbh);
|
||||||
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
|
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
|
||||||
|
#
|
||||||
done_testing;
|
done_testing;
|
||||||
|
9
t/pt-online-schema-change/samples/sakila_triggers.sql
Normal file
9
t/pt-online-schema-change/samples/sakila_triggers.sql
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
USE sakila;
|
||||||
|
CREATE TRIGGER triggers_migration_test
|
||||||
|
BEFORE
|
||||||
|
-- a comment here
|
||||||
|
INSERT ON film
|
||||||
|
-- just to make things harder
|
||||||
|
FOR EACH ROW SET NEW.length = 60
|
||||||
|
-- for pt_osc
|
||||||
|
;
|
72
t/pt-online-schema-change/samples/triggers.sql
Normal file
72
t/pt-online-schema-change/samples/triggers.sql
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user