mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-21 03:14:58 +00:00
Pass --where to get_range_statistics().
This commit is contained in:
@@ -5560,6 +5560,7 @@ sub save_tbl_to_checksum {
|
|||||||
tbl => $tbl,
|
tbl => $tbl,
|
||||||
chunk_col => $chunk_col,
|
chunk_col => $chunk_col,
|
||||||
tbl_struct => $struct,
|
tbl_struct => $struct,
|
||||||
|
where => $final_o->get('where'),
|
||||||
);
|
);
|
||||||
if ( !grep { !defined $params{$_} } qw(min max rows_in_range) ) {
|
if ( !grep { !defined $params{$_} } qw(min max rows_in_range) ) {
|
||||||
@chunks = $ch->calculate_chunks(
|
@chunks = $ch->calculate_chunks(
|
||||||
|
@@ -27,7 +27,7 @@ if ( !$dbh ) {
|
|||||||
plan skip_all => 'Cannot connect to sandbox master';
|
plan skip_all => 'Cannot connect to sandbox master';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
plan tests => 86;
|
plan tests => 88;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sb->create_dbs($dbh, ['test']);
|
$sb->create_dbs($dbh, ['test']);
|
||||||
@@ -1231,6 +1231,30 @@ SKIP: {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# ############################################################################
|
||||||
|
# Bug 821673: pt-table-checksum doesn't included --where in min max queries
|
||||||
|
# ############################################################################
|
||||||
|
$sb->load_file('master', "t/pt-table-checksum/samples/where01.sql");
|
||||||
|
$t = $p->parse( $du->get_create_table($dbh, $q, 'test', 'checksum_test') );
|
||||||
|
%params = $c->get_range_statistics(
|
||||||
|
dbh => $dbh,
|
||||||
|
db => 'test',
|
||||||
|
tbl => 'checksum_test',
|
||||||
|
chunk_col => 'id',
|
||||||
|
tbl_struct => $t,
|
||||||
|
where => "date = '2011-03-03'",
|
||||||
|
);
|
||||||
|
is(
|
||||||
|
$params{min},
|
||||||
|
11,
|
||||||
|
'MIN range stats with --where (bug 821673)'
|
||||||
|
);
|
||||||
|
is(
|
||||||
|
$params{max},
|
||||||
|
15,
|
||||||
|
'MAX range stats with --where (bug 821673)'
|
||||||
|
);
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Done.
|
# Done.
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
|
@@ -24,7 +24,7 @@ if ( !$master_dbh ) {
|
|||||||
plan skip_all => 'Cannot connect to sandbox master';
|
plan skip_all => 'Cannot connect to sandbox master';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
plan tests => 12;
|
plan tests => 13;
|
||||||
}
|
}
|
||||||
|
|
||||||
my ($output, $output2);
|
my ($output, $output2);
|
||||||
@@ -120,6 +120,23 @@ ok(
|
|||||||
"--sleep doesn't sleep unless table is chunked"
|
"--sleep doesn't sleep unless table is chunked"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
# ############################################################################
|
||||||
|
# Bug 821673: pt-table-checksum doesn't included --where in min max queries
|
||||||
|
# ############################################################################
|
||||||
|
$sb->load_file('master', "t/pt-table-checksum/samples/where01.sql");
|
||||||
|
|
||||||
|
ok(
|
||||||
|
no_diff(
|
||||||
|
sub { pt_table_checksum::main(@args,
|
||||||
|
qw(--no-zero-chunk --chunk-size 5), '--where', "date = '2011-03-03'");
|
||||||
|
},
|
||||||
|
"t/pt-table-checksum/samples/where01.out",
|
||||||
|
trf => "awk '{print \$1 \" \" \$2 \" \" \$3}'",
|
||||||
|
),
|
||||||
|
"--where affects range stats (bug 821673)"
|
||||||
|
);
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Done.
|
# Done.
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
|
3
t/pt-table-checksum/samples/where01.out
Normal file
3
t/pt-table-checksum/samples/where01.out
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
DATABASE TABLE CHUNK
|
||||||
|
test checksum_test 0
|
||||||
|
test checksum_test 1
|
26
t/pt-table-checksum/samples/where01.sql
Normal file
26
t/pt-table-checksum/samples/where01.sql
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
drop database if exists test;
|
||||||
|
create database test;
|
||||||
|
use test;
|
||||||
|
|
||||||
|
CREATE TABLE `checksum_test` (
|
||||||
|
`id` int(11) NOT NULL DEFAULT '0',
|
||||||
|
`date` date DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
|
INSERT INTO `checksum_test` VALUES
|
||||||
|
(1, '2011-03-01'),
|
||||||
|
(2, '2011-03-01'),
|
||||||
|
(3, '2011-03-01'),
|
||||||
|
(4, '2011-03-01'),
|
||||||
|
(5, '2011-03-01'),
|
||||||
|
(6, '2011-03-02'),
|
||||||
|
(7, '2011-03-02'),
|
||||||
|
(8, '2011-03-02'),
|
||||||
|
(9, '2011-03-02'),
|
||||||
|
(10, '2011-03-02'),
|
||||||
|
(11, '2011-03-03'),
|
||||||
|
(12, '2011-03-03'),
|
||||||
|
(13, '2011-03-03'),
|
||||||
|
(14, '2011-03-03'),
|
||||||
|
(15, '2011-03-03');
|
Reference in New Issue
Block a user