Changes from Daniel's review.

Some wording changes, also fatalized two warnings, and some test
changes.
This commit is contained in:
Brian Fraser fraserb@gmail.com
2012-07-30 19:10:45 -03:00
parent 776798b3b9
commit a94da84b27
2 changed files with 35 additions and 12 deletions

View File

@@ -8147,7 +8147,7 @@ sub check_repl_table {
my @db_exists = $dbh->selectrow_array($sql);
if ( !@db_exists && !$o->get('create-replicate-table') ) {
die "--replicate database $db does not exist and "
. "--no-create-replicate-table was passed in. You need "
. "--no-create-replicate-table was specified. You need "
. "to create the database.\n";
}
@@ -8162,9 +8162,12 @@ sub check_repl_table {
};
if ( $EVAL_ERROR ) {
if ( @db_exists ) {
print STDERR "CREATE DATABASE IF NOT EXISTS $db failed, but the "
. "db already exists. This is harmless unless the "
. "slaves don't have the database. $EVAL_ERROR"; # kb link?
die "Error executing $sql: $EVAL_ERROR\n"
. "The database exists on the master, but replication will "
. "break if it does not also exist on all replicas. If the "
. "--replicate database and table already exist on the master "
. "and all replicas, or if you created them manually, then "
. "specify --no-create-replicate-table to avoid this error."
}
else {
die "--replicate database $db does not exist and it cannot be "
@@ -8188,7 +8191,7 @@ sub check_repl_table {
# was passed in; see https://bugs.launchpad.net/percona-toolkit/+bug/950294
if ( !$tbl_exists && !$o->get('create-replicate-table') ) {
die "--replicate table $repl_table does not exist and "
. "--no-create-replicate-table was passed in. "
. "--no-create-replicate-table was specified. "
. "You need to create the table.\n";
}
if ( $o->get('create-replicate-table') ) {
@@ -8198,13 +8201,17 @@ sub check_repl_table {
};
if ( $EVAL_ERROR ) {
if ( $tbl_exists ) {
print STDERR "CREATE TABLE IF NOT EXISTS $args{repl_table} "
. "failed, but the table already exists. This "
. "is harmless unless the slaves don't have the "
. "table. $EVAL_ERROR";
die "Error executing $sql: $EVAL_ERROR\n"
. "The table exists on the master, but replication will "
. "break if it does not also exist on all replicas. If the "
. "--replicate database and table already exist on the master "
. "and all replicas, or if you created them manually, then "
. "specify --no-create-replicate-table to avoid this error."
}
else {
die $EVAL_ERROR;
die "--replicate table $tbl does not exist and it cannot be "
. "created automatically. You need to create the table. "
. $EVAL_ERROR;
}
}
}

View File

@@ -67,7 +67,11 @@ PerconaTest::wait_for_table($slave1_dbh, "mysql.tables_priv", "user='ro_checksum
) },
);
isnt($exit_status, 0, "");
ok(
$exit_status,
"Dies with an error status if it can't create the db/table"
);
like($output,
qr/\Q--replicate database percona does not exist and it cannot be created automatically/,
"fails if the percona db doesn't exist and the user can't create it",
@@ -113,7 +117,7 @@ $output = output(
# Comment out this line and the tests fail because ro_checksum_user
# doesn't have privs to SHOW SLAVE HOSTS. This proves that
# --recursion-method none is working.
qw(--recursion-method none)
qw(--recursion-method none --no-create-replicate-table)
) },
stderr => 1,
);
@@ -130,6 +134,18 @@ like(
"Read-only user (bug 987694): checksummed rows"
);
($output) = full_output(
sub { $exit_status = pt_table_checksum::main(@args,
"$master_dsn,u=ro_checksum_user,p=msandbox",
qw(--recursion-method none)
) }
);
like($output,
qr/\QThe database exists on the master, but replication will break/,
"dies if the db exists on the master but it can't CREATE DATABASE and --no-create-replicate-table was not specified",
);
diag(qx{/tmp/12345/use -u root -e 'DROP TABLE `percona`.`checksums`'});
($output, $exit_status) = full_output(