4
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
5
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
6
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
10
use warnings FATAL => 'all';
11
use English qw(-no_match_vars);
16
require "$trunk/bin/pt-table-checksum";
18
my $vp = new VersionParser();
19
my $dp = new DSNParser(opts=>$dsn_opts);
20
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
21
my $dbh = $sb->get_dbh_for('master');
24
plan skip_all => 'Cannot connect to sandbox master';
31
my $cnf='/tmp/12345/my.sandbox.cnf';
32
my @args = ('-F', $cnf, 'h=127.1', qw(-d issue_519 --explain --chunk-size 3));
34
$sb->load_file('master', "t/pt-table-checksum/samples/issue_519.sql");
36
my $default_output = "issue_519 t SELECT /*issue_519.t:1/5*/ 0 AS chunk_num, COUNT(*) AS cnt, COALESCE(LOWER(CONV(BIT_XOR(CAST(CRC32(CONCAT_WS('#', `i`, `y`, `t`, CONCAT(ISNULL(`t`)))) AS UNSIGNED)), 10, 16)), 0) AS crc FROM `issue_519`.`t` FORCE INDEX (`PRIMARY`) WHERE (`i` = 0)
38
issue_519 t `i` > 0 AND `i` < '4'
39
issue_519 t `i` >= '4' AND `i` < '7'
40
issue_519 t `i` >= '7' AND `i` < '10'
41
issue_519 t `i` >= '10'
45
sub { mk_table_checksum::main(@args) },
51
"Chooses chunk column by default"
55
sub { mk_table_checksum::main(@args, qw(--chunk-column batman)) },
61
"Chooses chunk column if --chunk-column doesn't exist"
65
sub { mk_table_checksum::main(@args, qw(--chunk-column t)) },
71
"Chooses chunk column if --chunk-column isn't chunkable"
75
sub { mk_table_checksum::main(@args, qw(--chunk-column i --chunk-index y)) },
81
"Chooses chunk column if it isn't chunkable with --chunk-index",
85
sub { mk_table_checksum::main(@args, qw(--chunk-column y)) },
90
"issue_519 t SELECT /*issue_519.t:1/5*/ 0 AS chunk_num, COUNT(*) AS cnt, COALESCE(LOWER(CONV(BIT_XOR(CAST(CRC32(CONCAT_WS('#', `i`, `y`, `t`, CONCAT(ISNULL(`t`)))) AS UNSIGNED)), 10, 16)), 0) AS crc FROM `issue_519`.`t` FORCE INDEX (`y`) WHERE (`y` = 0)
92
issue_519 t `y` > 0 AND `y` < '2003'
93
issue_519 t `y` >= '2003' AND `y` < '2006'
94
issue_519 t `y` >= '2006' AND `y` < '2009'
95
issue_519 t `y` >= '2009'
100
# #############################################################################
102
# #############################################################################
103
$sb->wipe_clean($dbh);