mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-11 21:51:21 +00:00
Merge ptc-privs-bug-916168.
This commit is contained in:
@@ -8177,15 +8177,8 @@ sub check_repl_table {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PTDEBUG && _d('--replicate table', $repl_table, 'already exists');
|
PTDEBUG && _d('--replicate table', $repl_table, 'already exists');
|
||||||
# Check it again but this time check the privs.
|
# We used to check the table privs here, but:
|
||||||
my $have_tbl_privs = $tp->check_table(
|
# https://bugs.launchpad.net/percona-toolkit/+bug/916168
|
||||||
dbh => $dbh,
|
|
||||||
db => $db,
|
|
||||||
tbl => $tbl,
|
|
||||||
all_privs => 1,
|
|
||||||
);
|
|
||||||
die "User does not have all privileges on --replicate table "
|
|
||||||
. "$repl_table.\n" unless $have_tbl_privs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check and wait for the repl table to appear on all slaves.
|
# Check and wait for the repl table to appear on all slaves.
|
||||||
|
@@ -42,7 +42,7 @@ elsif ( !@{$master_dbh->selectall_arrayref("show databases like 'sakila'")} ) {
|
|||||||
plan skip_all => 'sakila database is not loaded';
|
plan skip_all => 'sakila database is not loaded';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
plan tests => 3;
|
plan tests => 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
# The sandbox servers run with lock_wait_timeout=3 and it's not dynamic
|
# The sandbox servers run with lock_wait_timeout=3 and it's not dynamic
|
||||||
@@ -94,7 +94,31 @@ diag(`/tmp/12345/use -u root -e "drop user 'ro_checksum_user'\@'%'"`);
|
|||||||
wait_until(
|
wait_until(
|
||||||
sub {
|
sub {
|
||||||
my $rows=$slave2_dbh->selectall_arrayref("SELECT user FROM mysql.user");
|
my $rows=$slave2_dbh->selectall_arrayref("SELECT user FROM mysql.user");
|
||||||
return !grep { ($_->[0] || '') ne 'ro_checksum_user' } @$rows;
|
return !grep { ($_->[0] || '') eq 'ro_checksum_user' } @$rows;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
# #############################################################################
|
||||||
|
# Bug 916168: bug in pt-table-checksum privileges check
|
||||||
|
# #############################################################################
|
||||||
|
`/tmp/12345/use -u root < $trunk/t/pt-table-checksum/samples/privs-bug-916168.sql`;
|
||||||
|
|
||||||
|
$output = output(
|
||||||
|
sub { $exit_status = pt_table_checksum::main(@args,
|
||||||
|
"$master_dsn,u=test_user,p=foo", qw(-t sakila.country)) },
|
||||||
|
);
|
||||||
|
|
||||||
|
is(
|
||||||
|
PerconaTest::count_checksum_results($output, 'rows'),
|
||||||
|
109,
|
||||||
|
"test_user privs work (bug 916168)"
|
||||||
|
);
|
||||||
|
|
||||||
|
diag(`/tmp/12345/use -u root -e "drop user 'test_user'\@'%'"`);
|
||||||
|
wait_until(
|
||||||
|
sub {
|
||||||
|
my $rows=$slave2_dbh->selectall_arrayref("SELECT user FROM mysql.user");
|
||||||
|
return !grep { ($_->[0] || '') eq 'test_user' } @$rows;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
21
t/pt-table-checksum/samples/privs-bug-916168.sql
Normal file
21
t/pt-table-checksum/samples/privs-bug-916168.sql
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
grant select, replication slave, replication client, super, process on *.* to 'test_user'@'%' identified by 'foo';
|
||||||
|
grant all on percona.* to 'test_user'@'%';
|
||||||
|
create database if not exists percona;
|
||||||
|
use percona;
|
||||||
|
drop table if exists checksums;
|
||||||
|
CREATE TABLE `checksums` (
|
||||||
|
`db` char(64) NOT NULL,
|
||||||
|
`tbl` char(64) NOT NULL,
|
||||||
|
`chunk` int(11) NOT NULL,
|
||||||
|
`chunk_time` float DEFAULT NULL,
|
||||||
|
`chunk_index` varchar(200) DEFAULT NULL,
|
||||||
|
`lower_boundary` text,
|
||||||
|
`upper_boundary` text,
|
||||||
|
`this_crc` char(40) NOT NULL,
|
||||||
|
`this_cnt` int(11) NOT NULL,
|
||||||
|
`master_crc` char(40) DEFAULT NULL,
|
||||||
|
`master_cnt` int(11) DEFAULT NULL,
|
||||||
|
`ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||||
|
PRIMARY KEY (`db`,`tbl`,`chunk`),
|
||||||
|
KEY `ts_db_tbl` (`ts`,`db`,`tbl`)
|
||||||
|
) ENGINE=InnoDB;
|
Reference in New Issue
Block a user