PT-2340 - Support MySQL 8.4

- Updated modules and tests for pt-query-digest, pt-show-grants, pt-slave-delay, pt-slave-find, pt-slave-restart, pt-stalk, pt-summary, pt-table-checksum
This commit is contained in:
Sveta Smirnova
2024-07-30 18:35:36 +03:00
parent 76c1202cb5
commit d02355f89b
94 changed files with 2930 additions and 2306 deletions

View File

@@ -16,13 +16,14 @@ use Sandbox;
use SqlModes;
require "$trunk/bin/pt-show-grants";
require VersionParser;
my $dp = new DSNParser(opts=>$dsn_opts);
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
my $dbh = $sb->get_dbh_for('master');
my $dbh = $sb->get_dbh_for('source');
if ( !$dbh ) {
plan skip_all => 'Cannot connect to sandbox master';
plan skip_all => 'Cannot connect to sandbox source';
}
else {
plan tests => 3;
@@ -51,6 +52,20 @@ $modes->restore_original_modes;
$output = output(
sub { pt_show_grants::main('-F', $cnf, qw(--only bob --no-header)); }
);
my $expected_84 = <<'END_OUTPUT_6';
-- Grants for 'bob'@'%'
CREATE USER IF NOT EXISTS `bob`@`%`;
ALTER USER `bob`@`%` IDENTIFIED WITH 'caching_sha2_password' REQUIRE NONE PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT PASSWORD REQUIRE CURRENT DEFAULT;
GRANT USAGE ON *.* TO `bob`@`%`;
-- Grants for 'bob'@'192.168.1.1'
CREATE USER IF NOT EXISTS `bob`@`192.168.1.1`;
ALTER USER `bob`@`192.168.1.1` IDENTIFIED WITH 'caching_sha2_password' REQUIRE NONE PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT PASSWORD REQUIRE CURRENT DEFAULT;
GRANT USAGE ON *.* TO `bob`@`192.168.1.1`;
-- Grants for 'bob'@'localhost'
CREATE USER IF NOT EXISTS `bob`@`localhost`;
ALTER USER `bob`@`localhost` IDENTIFIED WITH 'caching_sha2_password' REQUIRE NONE PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT PASSWORD REQUIRE CURRENT DEFAULT;
GRANT USAGE ON *.* TO `bob`@`localhost`;
END_OUTPUT_6
my $expected_80 = <<'END_OUTPUT_0';
-- Grants for 'bob'@'%'
@@ -91,7 +106,7 @@ GRANT USAGE ON *.* TO 'bob'@'192.168.1.1';
GRANT USAGE ON *.* TO 'bob'@'localhost';
END_OUTPUT_2
my $expected = $sandbox_version < '5.7' ? $expected_56 : $sandbox_version < '8.0' ? $expected_57 : $expected_80;
my $expected = $sandbox_version < '5.7' ? $expected_56 : $sandbox_version < '8.0' ? $expected_57 : $sandbox_version < '8.4' ? $expected_80 : $expected_84;
is(
$output,
@@ -103,6 +118,13 @@ $output = output(
sub { pt_show_grants::main('-F', $cnf, qw(--only bob@192.168.1.1 --no-header)); }
);
$expected_84 = <<'END_OUTPUT_7';
-- Grants for 'bob'@'192.168.1.1'
CREATE USER IF NOT EXISTS `bob`@`192.168.1.1`;
ALTER USER `bob`@`192.168.1.1` IDENTIFIED WITH 'caching_sha2_password' REQUIRE NONE PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT PASSWORD REQUIRE CURRENT DEFAULT;
GRANT USAGE ON *.* TO `bob`@`192.168.1.1`;
END_OUTPUT_7
$expected_80 = <<'END_OUTPUT_5';
-- Grants for 'bob'@'192.168.1.1'
CREATE USER IF NOT EXISTS `bob`@`192.168.1.1`;
@@ -122,7 +144,7 @@ $expected_56 = <<'END_OUTPUT_4';
GRANT USAGE ON *.* TO 'bob'@'192.168.1.1';
END_OUTPUT_4
$expected = $sandbox_version < '5.7' ? $expected_56 : $sandbox_version < '8.0' ? $expected_57: $expected_80;
$expected = $sandbox_version < '5.7' ? $expected_56 : $sandbox_version < '8.0' ? $expected_57 : $sandbox_version < '8.4' ? $expected_80 : $expected_84;
is(
$output,

View File

@@ -15,13 +15,14 @@ use PerconaTest;
use Sandbox;
use SqlModes;
require "$trunk/bin/pt-show-grants";
require VersionParser;
my $dp = new DSNParser(opts=>$dsn_opts);
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
my $dbh = $sb->get_dbh_for('master');
my $dbh = $sb->get_dbh_for('source');
if ( !$dbh ) {
plan skip_all => 'Cannot connect to sandbox master';
plan skip_all => 'Cannot connect to sandbox source';
}
$sb->wipe_clean($dbh);
@@ -94,17 +95,17 @@ like(
$output,
qr/\d\d:\d\d:\d\d\n\z/,
'No output when all users skipped'
);
) or diag($output);
# #############################################################################
# pt-show-grant doesn't support column-level grants
# https://bugs.launchpad.net/percona-toolkit/+bug/866075
# #############################################################################
$sb->load_file('master', 't/pt-show-grants/samples/column-grants.sql');
$sb->load_file('source', 't/pt-show-grants/samples/column-grants.sql');
diag(`/tmp/12345/use -u root -e "CREATE USER 'sally'\@'%'"`);
diag(`/tmp/12345/use -u root -e "GRANT SELECT(DateCreated, PckPrice, PaymentStat, SANumber) ON test.t TO 'sally'\@'%'"`);
diag(`/tmp/12345/use -u root -e "GRANT SELECT(city_id), INSERT(city) ON sakila.city TO 'sally'\@'%'"`);
my $postfix = $sandbox_version >= '8.0' ? '-80' : $sandbox_version < '5.7' ? '' : '-57';
my $postfix = $sandbox_version >= '8.4' ? '-84' : $sandbox_version >= '8.0' ? '-80' : $sandbox_version < '5.7' ? '' : '-57';
# 11
ok(

View File

@@ -15,13 +15,14 @@ use PerconaTest;
use Sandbox;
use SqlModes;
require "$trunk/bin/pt-show-grants";
require VersionParser;
my $dp = new DSNParser(opts=>$dsn_opts);
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
my $dbh = $sb->get_dbh_for('master');
my $dbh = $sb->get_dbh_for('source');
if ( !$dbh ) {
plan skip_all => 'Cannot connect to sandbox master';
plan skip_all => 'Cannot connect to sandbox source';
}
else {
plan tests => 5;

View File

@@ -19,10 +19,10 @@ require "$trunk/bin/pt-show-grants";
my $dp = new DSNParser(opts=>$dsn_opts);
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
my $dbh = $sb->get_dbh_for('master');
my $dbh = $sb->get_dbh_for('source');
if ( !$dbh ) {
plan skip_all => 'Cannot connect to sandbox master';
plan skip_all => 'Cannot connect to sandbox source';
}
if ( VersionParser->new($dbh) lt '8.0.17') {

View File

@@ -19,10 +19,10 @@ require "$trunk/bin/pt-show-grants";
my $dp = new DSNParser(opts=>$dsn_opts);
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
my $dbh = $sb->get_dbh_for('master');
my $dbh = $sb->get_dbh_for('source');
if ( !$dbh ) {
plan skip_all => 'Cannot connect to sandbox master';
plan skip_all => 'Cannot connect to sandbox source';
}
if ( VersionParser->new($dbh)->flavor !~ m/maria/i ) {

View File

@@ -0,0 +1,6 @@
-- Grants for 'sally'@'%'
CREATE USER IF NOT EXISTS `sally`@`%`;
ALTER USER `sally`@`%` IDENTIFIED WITH 'caching_sha2_password' REQUIRE NONE PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT PASSWORD REQUIRE CURRENT DEFAULT;
GRANT INSERT (`city`), SELECT (`city_id`) ON `sakila`.`city` TO `sally`@`%`;
GRANT SELECT (`DateCreated`, `PaymentStat`, `PckPrice`, `SANumber`) ON `test`.`t` TO `sally`@`%`;
GRANT USAGE ON *.* TO `sally`@`%`;

View File

@@ -0,0 +1,6 @@
-- Grants for 'sally'@'%'
CREATE USER IF NOT EXISTS `sally`@`%`;
ALTER USER `sally`@`%` IDENTIFIED WITH 'caching_sha2_password' REQUIRE NONE PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT PASSWORD REQUIRE CURRENT DEFAULT;
GRANT INSERT (`city`), SELECT, SELECT (`city_id`) ON `sakila`.`city` TO `sally`@`%`;
GRANT SELECT (`DateCreated`, `PaymentStat`, `PckPrice`, `SANumber`) ON `test`.`t` TO `sally`@`%`;
GRANT USAGE ON *.* TO `sally`@`%`;

View File

@@ -0,0 +1,7 @@
-- Grants for 'sally'@'%'
CREATE USER IF NOT EXISTS `sally`@`%`;
ALTER USER `sally`@`%` IDENTIFIED WITH 'caching_sha2_password' REQUIRE NONE PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT PASSWORD REQUIRE CURRENT DEFAULT;
GRANT INSERT (`city`) ON `sakila`.`city` TO `sally`@`%`;
GRANT SELECT (`DateCreated`, `PaymentStat`, `PckPrice`, `SANumber`) ON `test`.`t` TO `sally`@`%`;
GRANT SELECT (`city_id`) ON `sakila`.`city` TO `sally`@`%`;
GRANT USAGE ON *.* TO `sally`@`%`;

View File

@@ -0,0 +1,12 @@
-- Revoke statements for 'sally'@'%'
REVOKE INSERT (`city`) ON `sakila`.`city` FROM `sally`@`%`;
REVOKE SELECT (`DateCreated`, `PaymentStat`, `PckPrice`, `SANumber`) ON `test`.`t` FROM `sally`@`%`;
REVOKE SELECT (`city_id`) ON `sakila`.`city` FROM `sally`@`%`;
REVOKE USAGE ON *.* FROM `sally`@`%`;
-- Grants for 'sally'@'%'
CREATE USER IF NOT EXISTS `sally`@`%`;
ALTER USER `sally`@`%` IDENTIFIED WITH 'caching_sha2_password' REQUIRE NONE PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT PASSWORD REQUIRE CURRENT DEFAULT;
GRANT INSERT (`city`) ON `sakila`.`city` TO `sally`@`%`;
GRANT SELECT (`DateCreated`, `PaymentStat`, `PckPrice`, `SANumber`) ON `test`.`t` TO `sally`@`%`;
GRANT SELECT (`city_id`) ON `sakila`.`city` TO `sally`@`%`;
GRANT USAGE ON *.* TO `sally`@`%`;