USE repl db when deleting from repl db. Move and update issue_982.t tests to replication_filters.t and remove issue_982.t.

This commit is contained in:
Daniel Nichter
2011-10-20 13:46:33 -06:00
parent 41821380b6
commit 5c80f55874
3 changed files with 202 additions and 253 deletions

View File

@@ -5975,10 +5975,29 @@ sub main {
$last_chunk = undef;
}
elsif ( $o->get('empty-replicate-table') ) {
use_repl_db(
dbh => $master_cxn->dbh(),
repl_table => $repl_table,
OptionParser => $o,
Quoter => $q,
);
MKDEBUG && _d($delete_sth->{Statement});
$delete_sth->execute($tbl->{db}, $tbl->{tbl});
}
# USE the correct db while checksumming this table. The "correct"
# db is a complicated subject; see sub for comments.
use_repl_db(
dbh => $master_cxn->dbh(),
tbl => $tbl, # XXX working on this table
repl_table => $repl_table,
OptionParser => $o,
Quoter => $q,
);
# #########################################################
# XXX DO NOT CHANGE THE DB UNTIL THIS TABLE IS FINISHED XXX
# #########################################################
return $oktonibble; # continue nibbling table?
},
next_boundaries => sub {
@@ -6294,16 +6313,6 @@ sub main {
# be saved here. print_checksum_results() uses this info.
$tbl->{checksum_results} = {};
# USE the correct db while checksumming this table. The "correct"
# db is a complicated subject; see sub for comments.
use_repl_db(
dbh => $master_cxn->dbh(),
tbl => $tbl,
repl_table => $repl_table,
OptionParser => $o,
Quoter => $q,
);
# Set table's initial chunk size. If this is the first table,
# then total rate will be zero, so use --chunk-size. Or, if
# --chunk-time=0, then only use --chunk-size for every table.
@@ -6737,9 +6746,6 @@ sub check_repl_table {
#
# Returns:
# Nothing or dies on error
{
my $current_db;
sub use_repl_db {
my ( %args ) = @_;
my @required_args = qw(dbh repl_table OptionParser Quoter);
@@ -6747,6 +6753,7 @@ sub use_repl_db {
die "I need a $arg argument" unless $args{$arg};
}
my ($dbh, $repl_table, $o, $q) = @args{@required_args};
MKDEBUG && _d('use_repl_db');
my ($db, $tbl) = $q->split_unquote($repl_table);
if ( my $tbl = $args{tbl} ) {
@@ -6765,30 +6772,26 @@ sub use_repl_db {
$db = $o->get('replicate-database') if $o->get('replicate-database');
}
if ( !$current_db || $current_db ne $db ) {
eval {
my $sql = "USE " . $q->quote($db);
MKDEBUG && _d($sql);
$dbh->do($sql);
};
if ( $EVAL_ERROR ) {
# Report which option db really came from.
my $opt = $o->get('replicate-database') ? "--replicate-database"
: "--replicate database";
if ( $EVAL_ERROR =~ m/unknown database/i ) {
die "$opt $db does not exist. You need to create the "
. "database or specify a database for $opt that exists.\n";
}
else {
die "Error using $opt $db: $EVAL_ERROR\n";
}
eval {
my $sql = "USE " . $q->quote($db);
MKDEBUG && _d($sql);
$dbh->do($sql);
};
if ( $EVAL_ERROR ) {
# Report which option db really came from.
my $opt = $o->get('replicate-database') ? "--replicate-database"
: "--replicate database";
if ( $EVAL_ERROR =~ m/unknown database/i ) {
die "$opt $db does not exist. You need to create the "
. "database or specify a database for $opt that exists.\n";
}
else {
die "Error using $opt $db: $EVAL_ERROR\n";
}
$current_db = $db;
}
return;
}
}
sub create_repl_table {
my ( %args ) = @_;