Implement --replicate and --replicate-check at same time. Pass where arg to find_replication_differences().

This commit is contained in:
Daniel Nichter
2011-09-29 12:16:35 -06:00
parent c4092295a5
commit c794f5e119
2 changed files with 78 additions and 32 deletions

View File

@@ -453,21 +453,17 @@ sub find_replication_differences {
}
my ($dbh, $repl_table) = @args{@required_args};
(my $sql = <<" EOF") =~ s/\s+/ /gm;
SELECT
CONCAT(db, '.', tbl) AS `table`,
chunk, chunk_index, lower_boundary, upper_boundary,
COALESCE(this_cnt-master_cnt, 0) AS cnt_diff,
COALESCE(
this_crc <> master_crc OR ISNULL(master_crc) <> ISNULL(this_crc),
0
) AS crc_diff,
this_cnt, master_cnt, this_crc, master_crc
FROM $repl_table
WHERE master_cnt <> this_cnt OR master_crc <> this_crc
OR ISNULL(master_crc) <> ISNULL(this_crc)
EOF
my $sql
= "SELECT CONCAT(db, '.', tbl) AS `table`, "
. "chunk, chunk_index, lower_boundary, upper_boundary, "
. "COALESCE(this_cnt-master_cnt, 0) AS cnt_diff, "
. "COALESCE("
. "this_crc <> master_crc OR ISNULL(master_crc) <> ISNULL(this_crc), 0"
. ") AS crc_diff, this_cnt, master_cnt, this_crc, master_crc "
. "FROM $repl_table "
. "WHERE (master_cnt <> this_cnt OR master_crc <> this_crc "
. "OR ISNULL(master_crc) <> ISNULL(this_crc))"
. ($args{where} ? " AND ($args{where})" : "");
MKDEBUG && _d($sql);
my $diffs = $dbh->selectall_arrayref($sql, { Slice => {} });
return $diffs;