mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-28 08:51:44 +00:00
Fix for 1003315: dry-run + alter-fk-method = auto always fail.
This commit is contained in:
@@ -29,7 +29,7 @@ elsif ( !$slave_dbh ) {
|
||||
plan skip_all => 'Cannot connect to sandbox slave1';
|
||||
}
|
||||
else {
|
||||
plan tests => 3;
|
||||
plan tests => 6;
|
||||
}
|
||||
|
||||
# The sandbox servers run with lock_wait_timeout=3 and it's not dynamic
|
||||
@@ -83,6 +83,34 @@ unlike $output,
|
||||
qr/\QThe original table `test1002448`.`table_name` does not have a PRIMARY KEY or a unique index which is required for the DELETE trigger/,
|
||||
"Bug 1002448: mistakenly uses indexes instead of keys";
|
||||
|
||||
# ############################################################################
|
||||
# https://bugs.launchpad.net/percona-toolkit/+bug/1003315
|
||||
# ############################################################################
|
||||
$sb->load_file('master', "$sample/bug-1003315.sql");
|
||||
|
||||
# Have to use full_output here, because the error message may happen during
|
||||
# cleanup, and so won't be caught by output().
|
||||
($output, $exit_status) = full_output(
|
||||
sub { pt_online_schema_change::main(@args,
|
||||
"$master_dsn,D=test1003315,t=A",
|
||||
"--alter", "ENGINE=InnoDB",
|
||||
"--alter-foreign-keys-method", "auto",
|
||||
"--dry-run",
|
||||
qw(--chunk-size 2 --dry-run --print))
|
||||
|
||||
},
|
||||
);
|
||||
|
||||
is $exit_status, 0, "Bug 1003315: Correct exit value for a dry run";
|
||||
|
||||
unlike $output,
|
||||
qr/\QError updating foreign key constraints: Invalid --alter-foreign-keys-method:/,
|
||||
"Bug 1003315: No error when combining --alter-foreign-keys-method auto and --dry-run";
|
||||
|
||||
like $output,
|
||||
qr/\QNot updating foreign key constraints because this is a dry run./,
|
||||
"Bug 1003315: But now we do get an explanation from --dry-run";
|
||||
|
||||
# #############################################################################
|
||||
# Done.
|
||||
# #############################################################################
|
||||
|
23
t/pt-online-schema-change/samples/bug-1003315.sql
Normal file
23
t/pt-online-schema-change/samples/bug-1003315.sql
Normal file
@@ -0,0 +1,23 @@
|
||||
drop database if exists test1003315;
|
||||
create database test1003315;
|
||||
use test1003315;
|
||||
|
||||
DROP TABLE IF EXISTS `B`;
|
||||
DROP TABLE IF EXISTS `A`;
|
||||
CREATE TABLE `A` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`foo` varchar(30) NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
DROP TABLE IF EXISTS `B`;
|
||||
CREATE TABLE `B` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`a` int(11) NOT NULL,
|
||||
KEY `9dde1f34` (`a`),
|
||||
PRIMARY KEY (`id`),
|
||||
CONSTRAINT `6970ddb42bec57fc` FOREIGN KEY (`a`) REFERENCES `A` (`id`)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
INSERT INTO `A` VALUES (1,'bar'), (2,'bar2'), (3,'bar3');
|
||||
INSERT INTO `B` VALUES (1, 1), (2, 2), (3, 1);
|
Reference in New Issue
Block a user