summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/suite/binlog_encryption/rpl_skip_replication.result2
-rw-r--r--mysql-test/suite/rpl/r/rpl_skip_replication.result2
-rw-r--r--mysql-test/suite/sys_vars/r/init_slave_grant.result46
-rw-r--r--mysql-test/suite/sys_vars/r/read_binlog_speed_limit_grant.result46
-rw-r--r--mysql-test/suite/sys_vars/r/replicate_do_db_grant.result46
-rw-r--r--mysql-test/suite/sys_vars/r/replicate_do_table_grant.result46
-rw-r--r--mysql-test/suite/sys_vars/r/replicate_events_marked_for_skip_grant.result46
-rw-r--r--mysql-test/suite/sys_vars/r/replicate_ignore_db_grant.result46
-rw-r--r--mysql-test/suite/sys_vars/r/replicate_ignore_table_grant.result46
-rw-r--r--mysql-test/suite/sys_vars/r/replicate_wild_do_table_grant.result46
-rw-r--r--mysql-test/suite/sys_vars/r/replicate_wild_ignore_table_grant.result46
-rw-r--r--mysql-test/suite/sys_vars/r/slave_compressed_protocol_grant.result46
-rw-r--r--mysql-test/suite/sys_vars/r/slave_ddl_exec_mode_grant.result46
-rw-r--r--mysql-test/suite/sys_vars/r/slave_domain_parallel_threads_grant.result46
-rw-r--r--mysql-test/suite/sys_vars/r/slave_exec_mode_grant.result46
-rw-r--r--mysql-test/suite/sys_vars/r/slave_max_allowed_packet_grant.result46
-rw-r--r--mysql-test/suite/sys_vars/r/slave_net_timeout_grant.result46
-rw-r--r--mysql-test/suite/sys_vars/r/slave_parallel_max_queued_grant.result46
-rw-r--r--mysql-test/suite/sys_vars/r/slave_parallel_mode_grant.result46
-rw-r--r--mysql-test/suite/sys_vars/r/slave_parallel_threads_grant.result46
-rw-r--r--mysql-test/suite/sys_vars/r/slave_parallel_workers_grant.result46
-rw-r--r--mysql-test/suite/sys_vars/r/slave_run_triggers_for_rbr_grant.result46
-rw-r--r--mysql-test/suite/sys_vars/r/slave_sql_verify_checksum_grant.result46
-rw-r--r--mysql-test/suite/sys_vars/r/slave_transaction_retry_interval_grant.result46
-rw-r--r--mysql-test/suite/sys_vars/r/slave_type_conversions_grant.result46
-rw-r--r--mysql-test/suite/sys_vars/t/init_slave_grant.test9
-rw-r--r--mysql-test/suite/sys_vars/t/read_binlog_speed_limit_grant.test9
-rw-r--r--mysql-test/suite/sys_vars/t/replicate_do_db_grant.test9
-rw-r--r--mysql-test/suite/sys_vars/t/replicate_do_table_grant.test9
-rw-r--r--mysql-test/suite/sys_vars/t/replicate_events_marked_for_skip_grant.test9
-rw-r--r--mysql-test/suite/sys_vars/t/replicate_ignore_db_grant.test9
-rw-r--r--mysql-test/suite/sys_vars/t/replicate_ignore_table_grant.test9
-rw-r--r--mysql-test/suite/sys_vars/t/replicate_wild_do_table_grant.test9
-rw-r--r--mysql-test/suite/sys_vars/t/replicate_wild_ignore_table_grant.test9
-rw-r--r--mysql-test/suite/sys_vars/t/slave_compressed_protocol_grant.test9
-rw-r--r--mysql-test/suite/sys_vars/t/slave_ddl_exec_mode_grant.test9
-rw-r--r--mysql-test/suite/sys_vars/t/slave_domain_parallel_threads_grant.test9
-rw-r--r--mysql-test/suite/sys_vars/t/slave_exec_mode_grant.test9
-rw-r--r--mysql-test/suite/sys_vars/t/slave_max_allowed_packet_grant.test9
-rw-r--r--mysql-test/suite/sys_vars/t/slave_net_timeout_grant.test9
-rw-r--r--mysql-test/suite/sys_vars/t/slave_parallel_max_queued_grant.test9
-rw-r--r--mysql-test/suite/sys_vars/t/slave_parallel_mode_grant.test9
-rw-r--r--mysql-test/suite/sys_vars/t/slave_parallel_threads_grant.test9
-rw-r--r--mysql-test/suite/sys_vars/t/slave_parallel_workers_grant.test9
-rw-r--r--mysql-test/suite/sys_vars/t/slave_run_triggers_for_rbr_grant.test9
-rw-r--r--mysql-test/suite/sys_vars/t/slave_sql_verify_checksum_grant.test9
-rw-r--r--mysql-test/suite/sys_vars/t/slave_transaction_retry_interval_grant.test9
-rw-r--r--mysql-test/suite/sys_vars/t/slave_type_conversions_grant.test9
-rw-r--r--sql/privilege.h52
-rw-r--r--sql/sys_vars.cc86
-rw-r--r--sql/sys_vars.ic12
51 files changed, 1392 insertions, 27 deletions
diff --git a/mysql-test/suite/binlog_encryption/rpl_skip_replication.result b/mysql-test/suite/binlog_encryption/rpl_skip_replication.result
index ded85f3edd5..59d5b50e5cc 100644
--- a/mysql-test/suite/binlog_encryption/rpl_skip_replication.result
+++ b/mysql-test/suite/binlog_encryption/rpl_skip_replication.result
@@ -7,7 +7,7 @@ SELECT,UPDATE ON *.* TO 'nonsuperuser'@'127.0.0.1';
connect nonpriv, 127.0.0.1, nonsuperuser,, test, $SLAVE_MYPORT,;
connection nonpriv;
SET GLOBAL replicate_events_marked_for_skip=FILTER_ON_MASTER;
-ERROR 42000: Access denied; you need (at least one of) the SUPER privilege(s) for this operation
+ERROR 42000: Access denied; you need (at least one of) the SUPER, REPLICATION SLAVE ADMIN privilege(s) for this operation
disconnect nonpriv;
connection slave;
DROP USER'nonsuperuser'@'127.0.0.1';
diff --git a/mysql-test/suite/rpl/r/rpl_skip_replication.result b/mysql-test/suite/rpl/r/rpl_skip_replication.result
index ded85f3edd5..59d5b50e5cc 100644
--- a/mysql-test/suite/rpl/r/rpl_skip_replication.result
+++ b/mysql-test/suite/rpl/r/rpl_skip_replication.result
@@ -7,7 +7,7 @@ SELECT,UPDATE ON *.* TO 'nonsuperuser'@'127.0.0.1';
connect nonpriv, 127.0.0.1, nonsuperuser,, test, $SLAVE_MYPORT,;
connection nonpriv;
SET GLOBAL replicate_events_marked_for_skip=FILTER_ON_MASTER;
-ERROR 42000: Access denied; you need (at least one of) the SUPER privilege(s) for this operation
+ERROR 42000: Access denied; you need (at least one of) the SUPER, REPLICATION SLAVE ADMIN privilege(s) for this operation
disconnect nonpriv;
connection slave;
DROP USER'nonsuperuser'@'127.0.0.1';
diff --git a/mysql-test/suite/sys_vars/r/init_slave_grant.result b/mysql-test/suite/sys_vars/r/init_slave_grant.result
new file mode 100644
index 00000000000..59639b92482
--- /dev/null
+++ b/mysql-test/suite/sys_vars/r/init_slave_grant.result
@@ -0,0 +1,46 @@
+#
+# MDEV-21966 Bind REPLICATION SLAVE ADMIN to a number of global system variables
+#
+SET @global=@@global.init_slave;
+# Test that "SET init_slave" is not allowed without REPLICATION SLAVE ADMIN or SUPER
+CREATE USER user1@localhost;
+GRANT ALL PRIVILEGES ON *.* TO user1@localhost;
+REVOKE REPLICATION SLAVE ADMIN, SUPER ON *.* FROM user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL init_slave='SET @x=1';
+ERROR 42000: Access denied; you need (at least one of) the SUPER, REPLICATION SLAVE ADMIN privilege(s) for this operation
+SET init_slave='SET @x=1';
+ERROR HY000: Variable 'init_slave' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION init_slave='SET @x=1';
+ERROR HY000: Variable 'init_slave' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+# Test that "SET init_slave" is allowed with REPLICATION SLAVE ADMIN
+CREATE USER user1@localhost;
+GRANT REPLICATION SLAVE ADMIN ON *.* TO user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL init_slave='SET @x=1';
+SET init_slave='SET @x=1';
+ERROR HY000: Variable 'init_slave' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION init_slave='SET @x=1';
+ERROR HY000: Variable 'init_slave' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+# Test that "SET init_slave" is allowed with SUPER
+CREATE USER user1@localhost;
+GRANT SUPER ON *.* TO user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL init_slave='SET @x=1';
+SET init_slave='SET @x=1';
+ERROR HY000: Variable 'init_slave' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION init_slave='SET @x=1';
+ERROR HY000: Variable 'init_slave' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+SET @@global.init_slave=@global;
diff --git a/mysql-test/suite/sys_vars/r/read_binlog_speed_limit_grant.result b/mysql-test/suite/sys_vars/r/read_binlog_speed_limit_grant.result
new file mode 100644
index 00000000000..03536c1c371
--- /dev/null
+++ b/mysql-test/suite/sys_vars/r/read_binlog_speed_limit_grant.result
@@ -0,0 +1,46 @@
+#
+# MDEV-21966 Bind REPLICATION SLAVE ADMIN to a number of global system variables
+#
+SET @global=@@global.read_binlog_speed_limit;
+# Test that "SET read_binlog_speed_limit" is not allowed without REPLICATION SLAVE ADMIN or SUPER
+CREATE USER user1@localhost;
+GRANT ALL PRIVILEGES ON *.* TO user1@localhost;
+REVOKE REPLICATION SLAVE ADMIN, SUPER ON *.* FROM user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL read_binlog_speed_limit=65536;
+ERROR 42000: Access denied; you need (at least one of) the SUPER, REPLICATION SLAVE ADMIN privilege(s) for this operation
+SET read_binlog_speed_limit=65536;
+ERROR HY000: Variable 'read_binlog_speed_limit' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION read_binlog_speed_limit=65536;
+ERROR HY000: Variable 'read_binlog_speed_limit' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+# Test that "SET read_binlog_speed_limit" is allowed with REPLICATION SLAVE ADMIN
+CREATE USER user1@localhost;
+GRANT REPLICATION SLAVE ADMIN ON *.* TO user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL read_binlog_speed_limit=65536;
+SET read_binlog_speed_limit=65536;
+ERROR HY000: Variable 'read_binlog_speed_limit' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION read_binlog_speed_limit=65536;
+ERROR HY000: Variable 'read_binlog_speed_limit' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+# Test that "SET read_binlog_speed_limit" is allowed with SUPER
+CREATE USER user1@localhost;
+GRANT SUPER ON *.* TO user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL read_binlog_speed_limit=65536;
+SET read_binlog_speed_limit=65536;
+ERROR HY000: Variable 'read_binlog_speed_limit' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION read_binlog_speed_limit=65536;
+ERROR HY000: Variable 'read_binlog_speed_limit' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+SET @@global.read_binlog_speed_limit=@global;
diff --git a/mysql-test/suite/sys_vars/r/replicate_do_db_grant.result b/mysql-test/suite/sys_vars/r/replicate_do_db_grant.result
new file mode 100644
index 00000000000..1f352590072
--- /dev/null
+++ b/mysql-test/suite/sys_vars/r/replicate_do_db_grant.result
@@ -0,0 +1,46 @@
+#
+# MDEV-21966 Bind REPLICATION SLAVE ADMIN to a number of global system variables
+#
+SET @global=@@global.replicate_do_db;
+# Test that "SET replicate_do_db" is not allowed without REPLICATION SLAVE ADMIN or SUPER
+CREATE USER user1@localhost;
+GRANT ALL PRIVILEGES ON *.* TO user1@localhost;
+REVOKE REPLICATION SLAVE ADMIN, SUPER ON *.* FROM user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL replicate_do_db='';
+ERROR 42000: Access denied; you need (at least one of) the SUPER, REPLICATION SLAVE ADMIN privilege(s) for this operation
+SET replicate_do_db='';
+ERROR HY000: Variable 'replicate_do_db' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION replicate_do_db='';
+ERROR HY000: Variable 'replicate_do_db' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+# Test that "SET replicate_do_db" is allowed with REPLICATION SLAVE ADMIN
+CREATE USER user1@localhost;
+GRANT REPLICATION SLAVE ADMIN ON *.* TO user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL replicate_do_db='';
+SET replicate_do_db='';
+ERROR HY000: Variable 'replicate_do_db' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION replicate_do_db='';
+ERROR HY000: Variable 'replicate_do_db' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+# Test that "SET replicate_do_db" is allowed with SUPER
+CREATE USER user1@localhost;
+GRANT SUPER ON *.* TO user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL replicate_do_db='';
+SET replicate_do_db='';
+ERROR HY000: Variable 'replicate_do_db' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION replicate_do_db='';
+ERROR HY000: Variable 'replicate_do_db' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+SET @@global.replicate_do_db=@global;
diff --git a/mysql-test/suite/sys_vars/r/replicate_do_table_grant.result b/mysql-test/suite/sys_vars/r/replicate_do_table_grant.result
new file mode 100644
index 00000000000..31290979695
--- /dev/null
+++ b/mysql-test/suite/sys_vars/r/replicate_do_table_grant.result
@@ -0,0 +1,46 @@
+#
+# MDEV-21966 Bind REPLICATION SLAVE ADMIN to a number of global system variables
+#
+SET @global=@@global.replicate_do_table;
+# Test that "SET replicate_do_table" is not allowed without REPLICATION SLAVE ADMIN or SUPER
+CREATE USER user1@localhost;
+GRANT ALL PRIVILEGES ON *.* TO user1@localhost;
+REVOKE REPLICATION SLAVE ADMIN, SUPER ON *.* FROM user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL replicate_do_table='';
+ERROR 42000: Access denied; you need (at least one of) the SUPER, REPLICATION SLAVE ADMIN privilege(s) for this operation
+SET replicate_do_table='';
+ERROR HY000: Variable 'replicate_do_table' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION replicate_do_table='';
+ERROR HY000: Variable 'replicate_do_table' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+# Test that "SET replicate_do_table" is allowed with REPLICATION SLAVE ADMIN
+CREATE USER user1@localhost;
+GRANT REPLICATION SLAVE ADMIN ON *.* TO user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL replicate_do_table='';
+SET replicate_do_table='';
+ERROR HY000: Variable 'replicate_do_table' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION replicate_do_table='';
+ERROR HY000: Variable 'replicate_do_table' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+# Test that "SET replicate_do_table" is allowed with SUPER
+CREATE USER user1@localhost;
+GRANT SUPER ON *.* TO user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL replicate_do_table='';
+SET replicate_do_table='';
+ERROR HY000: Variable 'replicate_do_table' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION replicate_do_table='';
+ERROR HY000: Variable 'replicate_do_table' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+SET @@global.replicate_do_table=@global;
diff --git a/mysql-test/suite/sys_vars/r/replicate_events_marked_for_skip_grant.result b/mysql-test/suite/sys_vars/r/replicate_events_marked_for_skip_grant.result
new file mode 100644
index 00000000000..f649294f7e5
--- /dev/null
+++ b/mysql-test/suite/sys_vars/r/replicate_events_marked_for_skip_grant.result
@@ -0,0 +1,46 @@
+#
+# MDEV-21966 Bind REPLICATION SLAVE ADMIN to a number of global system variables
+#
+SET @global=@@global.replicate_events_marked_for_skip;
+# Test that "SET replicate_events_marked_for_skip" is not allowed without REPLICATION SLAVE ADMIN or SUPER
+CREATE USER user1@localhost;
+GRANT ALL PRIVILEGES ON *.* TO user1@localhost;
+REVOKE REPLICATION SLAVE ADMIN, SUPER ON *.* FROM user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL replicate_events_marked_for_skip=REPLICATE;
+ERROR 42000: Access denied; you need (at least one of) the SUPER, REPLICATION SLAVE ADMIN privilege(s) for this operation
+SET replicate_events_marked_for_skip=REPLICATE;
+ERROR HY000: Variable 'replicate_events_marked_for_skip' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION replicate_events_marked_for_skip=REPLICATE;
+ERROR HY000: Variable 'replicate_events_marked_for_skip' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+# Test that "SET replicate_events_marked_for_skip" is allowed with REPLICATION SLAVE ADMIN
+CREATE USER user1@localhost;
+GRANT REPLICATION SLAVE ADMIN ON *.* TO user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL replicate_events_marked_for_skip=REPLICATE;
+SET replicate_events_marked_for_skip=REPLICATE;
+ERROR HY000: Variable 'replicate_events_marked_for_skip' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION replicate_events_marked_for_skip=REPLICATE;
+ERROR HY000: Variable 'replicate_events_marked_for_skip' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+# Test that "SET replicate_events_marked_for_skip" is allowed with SUPER
+CREATE USER user1@localhost;
+GRANT SUPER ON *.* TO user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL replicate_events_marked_for_skip=REPLICATE;
+SET replicate_events_marked_for_skip=REPLICATE;
+ERROR HY000: Variable 'replicate_events_marked_for_skip' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION replicate_events_marked_for_skip=REPLICATE;
+ERROR HY000: Variable 'replicate_events_marked_for_skip' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+SET @@global.replicate_events_marked_for_skip=@global;
diff --git a/mysql-test/suite/sys_vars/r/replicate_ignore_db_grant.result b/mysql-test/suite/sys_vars/r/replicate_ignore_db_grant.result
new file mode 100644
index 00000000000..612fab62771
--- /dev/null
+++ b/mysql-test/suite/sys_vars/r/replicate_ignore_db_grant.result
@@ -0,0 +1,46 @@
+#
+# MDEV-21966 Bind REPLICATION SLAVE ADMIN to a number of global system variables
+#
+SET @global=@@global.replicate_ignore_db;
+# Test that "SET replicate_ignore_db" is not allowed without REPLICATION SLAVE ADMIN or SUPER
+CREATE USER user1@localhost;
+GRANT ALL PRIVILEGES ON *.* TO user1@localhost;
+REVOKE REPLICATION SLAVE ADMIN, SUPER ON *.* FROM user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL replicate_ignore_db='';
+ERROR 42000: Access denied; you need (at least one of) the SUPER, REPLICATION SLAVE ADMIN privilege(s) for this operation
+SET replicate_ignore_db='';
+ERROR HY000: Variable 'replicate_ignore_db' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION replicate_ignore_db='';
+ERROR HY000: Variable 'replicate_ignore_db' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+# Test that "SET replicate_ignore_db" is allowed with REPLICATION SLAVE ADMIN
+CREATE USER user1@localhost;
+GRANT REPLICATION SLAVE ADMIN ON *.* TO user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL replicate_ignore_db='';
+SET replicate_ignore_db='';
+ERROR HY000: Variable 'replicate_ignore_db' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION replicate_ignore_db='';
+ERROR HY000: Variable 'replicate_ignore_db' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+# Test that "SET replicate_ignore_db" is allowed with SUPER
+CREATE USER user1@localhost;
+GRANT SUPER ON *.* TO user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL replicate_ignore_db='';
+SET replicate_ignore_db='';
+ERROR HY000: Variable 'replicate_ignore_db' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION replicate_ignore_db='';
+ERROR HY000: Variable 'replicate_ignore_db' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+SET @@global.replicate_ignore_db=@global;
diff --git a/mysql-test/suite/sys_vars/r/replicate_ignore_table_grant.result b/mysql-test/suite/sys_vars/r/replicate_ignore_table_grant.result
new file mode 100644
index 00000000000..9f2354a8704
--- /dev/null
+++ b/mysql-test/suite/sys_vars/r/replicate_ignore_table_grant.result
@@ -0,0 +1,46 @@
+#
+# MDEV-21966 Bind REPLICATION SLAVE ADMIN to a number of global system variables
+#
+SET @global=@@global.replicate_ignore_table;
+# Test that "SET replicate_ignore_table" is not allowed without REPLICATION SLAVE ADMIN or SUPER
+CREATE USER user1@localhost;
+GRANT ALL PRIVILEGES ON *.* TO user1@localhost;
+REVOKE REPLICATION SLAVE ADMIN, SUPER ON *.* FROM user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL replicate_ignore_table='';
+ERROR 42000: Access denied; you need (at least one of) the SUPER, REPLICATION SLAVE ADMIN privilege(s) for this operation
+SET replicate_ignore_table='';
+ERROR HY000: Variable 'replicate_ignore_table' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION replicate_ignore_table='';
+ERROR HY000: Variable 'replicate_ignore_table' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+# Test that "SET replicate_ignore_table" is allowed with REPLICATION SLAVE ADMIN
+CREATE USER user1@localhost;
+GRANT REPLICATION SLAVE ADMIN ON *.* TO user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL replicate_ignore_table='';
+SET replicate_ignore_table='';
+ERROR HY000: Variable 'replicate_ignore_table' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION replicate_ignore_table='';
+ERROR HY000: Variable 'replicate_ignore_table' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+# Test that "SET replicate_ignore_table" is allowed with SUPER
+CREATE USER user1@localhost;
+GRANT SUPER ON *.* TO user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL replicate_ignore_table='';
+SET replicate_ignore_table='';
+ERROR HY000: Variable 'replicate_ignore_table' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION replicate_ignore_table='';
+ERROR HY000: Variable 'replicate_ignore_table' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+SET @@global.replicate_ignore_table=@global;
diff --git a/mysql-test/suite/sys_vars/r/replicate_wild_do_table_grant.result b/mysql-test/suite/sys_vars/r/replicate_wild_do_table_grant.result
new file mode 100644
index 00000000000..1c9e12ded65
--- /dev/null
+++ b/mysql-test/suite/sys_vars/r/replicate_wild_do_table_grant.result
@@ -0,0 +1,46 @@
+#
+# MDEV-21966 Bind REPLICATION SLAVE ADMIN to a number of global system variables
+#
+SET @global=@@global.replicate_wild_do_table;
+# Test that "SET replicate_wild_do_table" is not allowed without REPLICATION SLAVE ADMIN or SUPER
+CREATE USER user1@localhost;
+GRANT ALL PRIVILEGES ON *.* TO user1@localhost;
+REVOKE REPLICATION SLAVE ADMIN, SUPER ON *.* FROM user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL replicate_wild_do_table='';
+ERROR 42000: Access denied; you need (at least one of) the SUPER, REPLICATION SLAVE ADMIN privilege(s) for this operation
+SET replicate_wild_do_table='';
+ERROR HY000: Variable 'replicate_wild_do_table' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION replicate_wild_do_table='';
+ERROR HY000: Variable 'replicate_wild_do_table' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+# Test that "SET replicate_wild_do_table" is allowed with REPLICATION SLAVE ADMIN
+CREATE USER user1@localhost;
+GRANT REPLICATION SLAVE ADMIN ON *.* TO user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL replicate_wild_do_table='';
+SET replicate_wild_do_table='';
+ERROR HY000: Variable 'replicate_wild_do_table' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION replicate_wild_do_table='';
+ERROR HY000: Variable 'replicate_wild_do_table' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+# Test that "SET replicate_wild_do_table" is allowed with SUPER
+CREATE USER user1@localhost;
+GRANT SUPER ON *.* TO user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL replicate_wild_do_table='';
+SET replicate_wild_do_table='';
+ERROR HY000: Variable 'replicate_wild_do_table' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION replicate_wild_do_table='';
+ERROR HY000: Variable 'replicate_wild_do_table' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+SET @@global.replicate_wild_do_table=@global;
diff --git a/mysql-test/suite/sys_vars/r/replicate_wild_ignore_table_grant.result b/mysql-test/suite/sys_vars/r/replicate_wild_ignore_table_grant.result
new file mode 100644
index 00000000000..27a82173d50
--- /dev/null
+++ b/mysql-test/suite/sys_vars/r/replicate_wild_ignore_table_grant.result
@@ -0,0 +1,46 @@
+#
+# MDEV-21966 Bind REPLICATION SLAVE ADMIN to a number of global system variables
+#
+SET @global=@@global.replicate_wild_ignore_table;
+# Test that "SET replicate_wild_ignore_table" is not allowed without REPLICATION SLAVE ADMIN or SUPER
+CREATE USER user1@localhost;
+GRANT ALL PRIVILEGES ON *.* TO user1@localhost;
+REVOKE REPLICATION SLAVE ADMIN, SUPER ON *.* FROM user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL replicate_wild_ignore_table='';
+ERROR 42000: Access denied; you need (at least one of) the SUPER, REPLICATION SLAVE ADMIN privilege(s) for this operation
+SET replicate_wild_ignore_table='';
+ERROR HY000: Variable 'replicate_wild_ignore_table' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION replicate_wild_ignore_table='';
+ERROR HY000: Variable 'replicate_wild_ignore_table' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+# Test that "SET replicate_wild_ignore_table" is allowed with REPLICATION SLAVE ADMIN
+CREATE USER user1@localhost;
+GRANT REPLICATION SLAVE ADMIN ON *.* TO user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL replicate_wild_ignore_table='';
+SET replicate_wild_ignore_table='';
+ERROR HY000: Variable 'replicate_wild_ignore_table' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION replicate_wild_ignore_table='';
+ERROR HY000: Variable 'replicate_wild_ignore_table' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+# Test that "SET replicate_wild_ignore_table" is allowed with SUPER
+CREATE USER user1@localhost;
+GRANT SUPER ON *.* TO user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL replicate_wild_ignore_table='';
+SET replicate_wild_ignore_table='';
+ERROR HY000: Variable 'replicate_wild_ignore_table' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION replicate_wild_ignore_table='';
+ERROR HY000: Variable 'replicate_wild_ignore_table' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+SET @@global.replicate_wild_ignore_table=@global;
diff --git a/mysql-test/suite/sys_vars/r/slave_compressed_protocol_grant.result b/mysql-test/suite/sys_vars/r/slave_compressed_protocol_grant.result
new file mode 100644
index 00000000000..2f3f52982ea
--- /dev/null
+++ b/mysql-test/suite/sys_vars/r/slave_compressed_protocol_grant.result
@@ -0,0 +1,46 @@
+#
+# MDEV-21966 Bind REPLICATION SLAVE ADMIN to a number of global system variables
+#
+SET @global=@@global.slave_compressed_protocol;
+# Test that "SET slave_compressed_protocol" is not allowed without REPLICATION SLAVE ADMIN or SUPER
+CREATE USER user1@localhost;
+GRANT ALL PRIVILEGES ON *.* TO user1@localhost;
+REVOKE REPLICATION SLAVE ADMIN, SUPER ON *.* FROM user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL slave_compressed_protocol=1;
+ERROR 42000: Access denied; you need (at least one of) the SUPER, REPLICATION SLAVE ADMIN privilege(s) for this operation
+SET slave_compressed_protocol=1;
+ERROR HY000: Variable 'slave_compressed_protocol' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION slave_compressed_protocol=1;
+ERROR HY000: Variable 'slave_compressed_protocol' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+# Test that "SET slave_compressed_protocol" is allowed with REPLICATION SLAVE ADMIN
+CREATE USER user1@localhost;
+GRANT REPLICATION SLAVE ADMIN ON *.* TO user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL slave_compressed_protocol=1;
+SET slave_compressed_protocol=1;
+ERROR HY000: Variable 'slave_compressed_protocol' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION slave_compressed_protocol=1;
+ERROR HY000: Variable 'slave_compressed_protocol' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+# Test that "SET slave_compressed_protocol" is allowed with SUPER
+CREATE USER user1@localhost;
+GRANT SUPER ON *.* TO user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL slave_compressed_protocol=1;
+SET slave_compressed_protocol=1;
+ERROR HY000: Variable 'slave_compressed_protocol' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION slave_compressed_protocol=1;
+ERROR HY000: Variable 'slave_compressed_protocol' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+SET @@global.slave_compressed_protocol=@global;
diff --git a/mysql-test/suite/sys_vars/r/slave_ddl_exec_mode_grant.result b/mysql-test/suite/sys_vars/r/slave_ddl_exec_mode_grant.result
new file mode 100644
index 00000000000..d4f21f1e0ea
--- /dev/null
+++ b/mysql-test/suite/sys_vars/r/slave_ddl_exec_mode_grant.result
@@ -0,0 +1,46 @@
+#
+# MDEV-21966 Bind REPLICATION SLAVE ADMIN to a number of global system variables
+#
+SET @global=@@global.slave_ddl_exec_mode;
+# Test that "SET slave_ddl_exec_mode" is not allowed without REPLICATION SLAVE ADMIN or SUPER
+CREATE USER user1@localhost;
+GRANT ALL PRIVILEGES ON *.* TO user1@localhost;
+REVOKE REPLICATION SLAVE ADMIN, SUPER ON *.* FROM user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL slave_ddl_exec_mode=STRICT;
+ERROR 42000: Access denied; you need (at least one of) the SUPER, REPLICATION SLAVE ADMIN privilege(s) for this operation
+SET slave_ddl_exec_mode=STRICT;
+ERROR HY000: Variable 'slave_ddl_exec_mode' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION slave_ddl_exec_mode=STRICT;
+ERROR HY000: Variable 'slave_ddl_exec_mode' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+# Test that "SET slave_ddl_exec_mode" is allowed with REPLICATION SLAVE ADMIN
+CREATE USER user1@localhost;
+GRANT REPLICATION SLAVE ADMIN ON *.* TO user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL slave_ddl_exec_mode=STRICT;
+SET slave_ddl_exec_mode=STRICT;
+ERROR HY000: Variable 'slave_ddl_exec_mode' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION slave_ddl_exec_mode=STRICT;
+ERROR HY000: Variable 'slave_ddl_exec_mode' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+# Test that "SET slave_ddl_exec_mode" is allowed with SUPER
+CREATE USER user1@localhost;
+GRANT SUPER ON *.* TO user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL slave_ddl_exec_mode=STRICT;
+SET slave_ddl_exec_mode=STRICT;
+ERROR HY000: Variable 'slave_ddl_exec_mode' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION slave_ddl_exec_mode=STRICT;
+ERROR HY000: Variable 'slave_ddl_exec_mode' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+SET @@global.slave_ddl_exec_mode=@global;
diff --git a/mysql-test/suite/sys_vars/r/slave_domain_parallel_threads_grant.result b/mysql-test/suite/sys_vars/r/slave_domain_parallel_threads_grant.result
new file mode 100644
index 00000000000..f31e48e276d
--- /dev/null
+++ b/mysql-test/suite/sys_vars/r/slave_domain_parallel_threads_grant.result
@@ -0,0 +1,46 @@
+#
+# MDEV-21966 Bind REPLICATION SLAVE ADMIN to a number of global system variables
+#
+SET @global=@@global.slave_domain_parallel_threads;
+# Test that "SET slave_domain_parallel_threads" is not allowed without REPLICATION SLAVE ADMIN or SUPER
+CREATE USER user1@localhost;
+GRANT ALL PRIVILEGES ON *.* TO user1@localhost;
+REVOKE REPLICATION SLAVE ADMIN, SUPER ON *.* FROM user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL slave_domain_parallel_threads=0;
+ERROR 42000: Access denied; you need (at least one of) the SUPER, REPLICATION SLAVE ADMIN privilege(s) for this operation
+SET slave_domain_parallel_threads=0;
+ERROR HY000: Variable 'slave_domain_parallel_threads' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION slave_domain_parallel_threads=0;
+ERROR HY000: Variable 'slave_domain_parallel_threads' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+# Test that "SET slave_domain_parallel_threads" is allowed with REPLICATION SLAVE ADMIN
+CREATE USER user1@localhost;
+GRANT REPLICATION SLAVE ADMIN ON *.* TO user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL slave_domain_parallel_threads=0;
+SET slave_domain_parallel_threads=0;
+ERROR HY000: Variable 'slave_domain_parallel_threads' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION slave_domain_parallel_threads=0;
+ERROR HY000: Variable 'slave_domain_parallel_threads' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+# Test that "SET slave_domain_parallel_threads" is allowed with SUPER
+CREATE USER user1@localhost;
+GRANT SUPER ON *.* TO user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL slave_domain_parallel_threads=0;
+SET slave_domain_parallel_threads=0;
+ERROR HY000: Variable 'slave_domain_parallel_threads' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION slave_domain_parallel_threads=0;
+ERROR HY000: Variable 'slave_domain_parallel_threads' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+SET @@global.slave_domain_parallel_threads=@global;
diff --git a/mysql-test/suite/sys_vars/r/slave_exec_mode_grant.result b/mysql-test/suite/sys_vars/r/slave_exec_mode_grant.result
new file mode 100644
index 00000000000..c1cfdba7c2a
--- /dev/null
+++ b/mysql-test/suite/sys_vars/r/slave_exec_mode_grant.result
@@ -0,0 +1,46 @@
+#
+# MDEV-21966 Bind REPLICATION SLAVE ADMIN to a number of global system variables
+#
+SET @global=@@global.slave_exec_mode;
+# Test that "SET slave_exec_mode" is not allowed without REPLICATION SLAVE ADMIN or SUPER
+CREATE USER user1@localhost;
+GRANT ALL PRIVILEGES ON *.* TO user1@localhost;
+REVOKE REPLICATION SLAVE ADMIN, SUPER ON *.* FROM user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL slave_exec_mode=STRICT;
+ERROR 42000: Access denied; you need (at least one of) the SUPER, REPLICATION SLAVE ADMIN privilege(s) for this operation
+SET slave_exec_mode=STRICT;
+ERROR HY000: Variable 'slave_exec_mode' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION slave_exec_mode=STRICT;
+ERROR HY000: Variable 'slave_exec_mode' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+# Test that "SET slave_exec_mode" is allowed with REPLICATION SLAVE ADMIN
+CREATE USER user1@localhost;
+GRANT REPLICATION SLAVE ADMIN ON *.* TO user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL slave_exec_mode=STRICT;
+SET slave_exec_mode=STRICT;
+ERROR HY000: Variable 'slave_exec_mode' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION slave_exec_mode=STRICT;
+ERROR HY000: Variable 'slave_exec_mode' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+# Test that "SET slave_exec_mode" is allowed with SUPER
+CREATE USER user1@localhost;
+GRANT SUPER ON *.* TO user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL slave_exec_mode=STRICT;
+SET slave_exec_mode=STRICT;
+ERROR HY000: Variable 'slave_exec_mode' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION slave_exec_mode=STRICT;
+ERROR HY000: Variable 'slave_exec_mode' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+SET @@global.slave_exec_mode=@global;
diff --git a/mysql-test/suite/sys_vars/r/slave_max_allowed_packet_grant.result b/mysql-test/suite/sys_vars/r/slave_max_allowed_packet_grant.result
new file mode 100644
index 00000000000..664d580e1a6
--- /dev/null
+++ b/mysql-test/suite/sys_vars/r/slave_max_allowed_packet_grant.result
@@ -0,0 +1,46 @@
+#
+# MDEV-21966 Bind REPLICATION SLAVE ADMIN to a number of global system variables
+#
+SET @global=@@global.slave_max_allowed_packet;
+# Test that "SET slave_max_allowed_packet" is not allowed without REPLICATION SLAVE ADMIN or SUPER
+CREATE USER user1@localhost;
+GRANT ALL PRIVILEGES ON *.* TO user1@localhost;
+REVOKE REPLICATION SLAVE ADMIN, SUPER ON *.* FROM user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL slave_max_allowed_packet=65536;
+ERROR 42000: Access denied; you need (at least one of) the SUPER, REPLICATION SLAVE ADMIN privilege(s) for this operation
+SET slave_max_allowed_packet=65536;
+ERROR HY000: Variable 'slave_max_allowed_packet' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION slave_max_allowed_packet=65536;
+ERROR HY000: Variable 'slave_max_allowed_packet' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+# Test that "SET slave_max_allowed_packet" is allowed with REPLICATION SLAVE ADMIN
+CREATE USER user1@localhost;
+GRANT REPLICATION SLAVE ADMIN ON *.* TO user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL slave_max_allowed_packet=65536;
+SET slave_max_allowed_packet=65536;
+ERROR HY000: Variable 'slave_max_allowed_packet' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION slave_max_allowed_packet=65536;
+ERROR HY000: Variable 'slave_max_allowed_packet' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+# Test that "SET slave_max_allowed_packet" is allowed with SUPER
+CREATE USER user1@localhost;
+GRANT SUPER ON *.* TO user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL slave_max_allowed_packet=65536;
+SET slave_max_allowed_packet=65536;
+ERROR HY000: Variable 'slave_max_allowed_packet' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION slave_max_allowed_packet=65536;
+ERROR HY000: Variable 'slave_max_allowed_packet' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+SET @@global.slave_max_allowed_packet=@global;
diff --git a/mysql-test/suite/sys_vars/r/slave_net_timeout_grant.result b/mysql-test/suite/sys_vars/r/slave_net_timeout_grant.result
new file mode 100644
index 00000000000..2b6664ab31f
--- /dev/null
+++ b/mysql-test/suite/sys_vars/r/slave_net_timeout_grant.result
@@ -0,0 +1,46 @@
+#
+# MDEV-21966 Bind REPLICATION SLAVE ADMIN to a number of global system variables
+#
+SET @global=@@global.slave_net_timeout;
+# Test that "SET slave_net_timeout" is not allowed without REPLICATION SLAVE ADMIN or SUPER
+CREATE USER user1@localhost;
+GRANT ALL PRIVILEGES ON *.* TO user1@localhost;
+REVOKE REPLICATION SLAVE ADMIN, SUPER ON *.* FROM user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL slave_net_timeout=60;
+ERROR 42000: Access denied; you need (at least one of) the SUPER, REPLICATION SLAVE ADMIN privilege(s) for this operation
+SET slave_net_timeout=60;
+ERROR HY000: Variable 'slave_net_timeout' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION slave_net_timeout=60;
+ERROR HY000: Variable 'slave_net_timeout' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+# Test that "SET slave_net_timeout" is allowed with REPLICATION SLAVE ADMIN
+CREATE USER user1@localhost;
+GRANT REPLICATION SLAVE ADMIN ON *.* TO user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL slave_net_timeout=60;
+SET slave_net_timeout=60;
+ERROR HY000: Variable 'slave_net_timeout' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION slave_net_timeout=60;
+ERROR HY000: Variable 'slave_net_timeout' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+# Test that "SET slave_net_timeout" is allowed with SUPER
+CREATE USER user1@localhost;
+GRANT SUPER ON *.* TO user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL slave_net_timeout=60;
+SET slave_net_timeout=60;
+ERROR HY000: Variable 'slave_net_timeout' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION slave_net_timeout=60;
+ERROR HY000: Variable 'slave_net_timeout' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+SET @@global.slave_net_timeout=@global;
diff --git a/mysql-test/suite/sys_vars/r/slave_parallel_max_queued_grant.result b/mysql-test/suite/sys_vars/r/slave_parallel_max_queued_grant.result
new file mode 100644
index 00000000000..315de47853b
--- /dev/null
+++ b/mysql-test/suite/sys_vars/r/slave_parallel_max_queued_grant.result
@@ -0,0 +1,46 @@
+#
+# MDEV-21966 Bind REPLICATION SLAVE ADMIN to a number of global system variables
+#
+SET @global=@@global.slave_parallel_max_queued;
+# Test that "SET slave_parallel_max_queued" is not allowed without REPLICATION SLAVE ADMIN or SUPER
+CREATE USER user1@localhost;
+GRANT ALL PRIVILEGES ON *.* TO user1@localhost;
+REVOKE REPLICATION SLAVE ADMIN, SUPER ON *.* FROM user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL slave_parallel_max_queued=65536;
+ERROR 42000: Access denied; you need (at least one of) the SUPER, REPLICATION SLAVE ADMIN privilege(s) for this operation
+SET slave_parallel_max_queued=65536;
+ERROR HY000: Variable 'slave_parallel_max_queued' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION slave_parallel_max_queued=65536;
+ERROR HY000: Variable 'slave_parallel_max_queued' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+# Test that "SET slave_parallel_max_queued" is allowed with REPLICATION SLAVE ADMIN
+CREATE USER user1@localhost;
+GRANT REPLICATION SLAVE ADMIN ON *.* TO user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL slave_parallel_max_queued=65536;
+SET slave_parallel_max_queued=65536;
+ERROR HY000: Variable 'slave_parallel_max_queued' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION slave_parallel_max_queued=65536;
+ERROR HY000: Variable 'slave_parallel_max_queued' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+# Test that "SET slave_parallel_max_queued" is allowed with SUPER
+CREATE USER user1@localhost;
+GRANT SUPER ON *.* TO user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL slave_parallel_max_queued=65536;
+SET slave_parallel_max_queued=65536;
+ERROR HY000: Variable 'slave_parallel_max_queued' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION slave_parallel_max_queued=65536;
+ERROR HY000: Variable 'slave_parallel_max_queued' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+SET @@global.slave_parallel_max_queued=@global;
diff --git a/mysql-test/suite/sys_vars/r/slave_parallel_mode_grant.result b/mysql-test/suite/sys_vars/r/slave_parallel_mode_grant.result
new file mode 100644
index 00000000000..6d5da37da7a
--- /dev/null
+++ b/mysql-test/suite/sys_vars/r/slave_parallel_mode_grant.result
@@ -0,0 +1,46 @@
+#
+# MDEV-21966 Bind REPLICATION SLAVE ADMIN to a number of global system variables
+#
+SET @global=@@global.slave_parallel_mode;
+# Test that "SET slave_parallel_mode" is not allowed without REPLICATION SLAVE ADMIN or SUPER
+CREATE USER user1@localhost;
+GRANT ALL PRIVILEGES ON *.* TO user1@localhost;
+REVOKE REPLICATION SLAVE ADMIN, SUPER ON *.* FROM user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL slave_parallel_mode=1;
+ERROR 42000: Access denied; you need (at least one of) the SUPER, REPLICATION SLAVE ADMIN privilege(s) for this operation
+SET slave_parallel_mode=1;
+ERROR HY000: Variable 'slave_parallel_mode' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION slave_parallel_mode=1;
+ERROR HY000: Variable 'slave_parallel_mode' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+# Test that "SET slave_parallel_mode" is allowed with REPLICATION SLAVE ADMIN
+CREATE USER user1@localhost;
+GRANT REPLICATION SLAVE ADMIN ON *.* TO user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL slave_parallel_mode=1;
+SET slave_parallel_mode=1;
+ERROR HY000: Variable 'slave_parallel_mode' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION slave_parallel_mode=1;
+ERROR HY000: Variable 'slave_parallel_mode' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+# Test that "SET slave_parallel_mode" is allowed with SUPER
+CREATE USER user1@localhost;
+GRANT SUPER ON *.* TO user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL slave_parallel_mode=1;
+SET slave_parallel_mode=1;
+ERROR HY000: Variable 'slave_parallel_mode' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION slave_parallel_mode=1;
+ERROR HY000: Variable 'slave_parallel_mode' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+SET @@global.slave_parallel_mode=@global;
diff --git a/mysql-test/suite/sys_vars/r/slave_parallel_threads_grant.result b/mysql-test/suite/sys_vars/r/slave_parallel_threads_grant.result
new file mode 100644
index 00000000000..147252f78e3
--- /dev/null
+++ b/mysql-test/suite/sys_vars/r/slave_parallel_threads_grant.result
@@ -0,0 +1,46 @@
+#
+# MDEV-21966 Bind REPLICATION SLAVE ADMIN to a number of global system variables
+#
+SET @global=@@global.slave_parallel_threads;
+# Test that "SET slave_parallel_threads" is not allowed without REPLICATION SLAVE ADMIN or SUPER
+CREATE USER user1@localhost;
+GRANT ALL PRIVILEGES ON *.* TO user1@localhost;
+REVOKE REPLICATION SLAVE ADMIN, SUPER ON *.* FROM user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL slave_parallel_threads=256;
+ERROR 42000: Access denied; you need (at least one of) the SUPER, REPLICATION SLAVE ADMIN privilege(s) for this operation
+SET slave_parallel_threads=256;
+ERROR HY000: Variable 'slave_parallel_threads' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION slave_parallel_threads=256;
+ERROR HY000: Variable 'slave_parallel_threads' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+# Test that "SET slave_parallel_threads" is allowed with REPLICATION SLAVE ADMIN
+CREATE USER user1@localhost;
+GRANT REPLICATION SLAVE ADMIN ON *.* TO user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL slave_parallel_threads=256;
+SET slave_parallel_threads=256;
+ERROR HY000: Variable 'slave_parallel_threads' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION slave_parallel_threads=256;
+ERROR HY000: Variable 'slave_parallel_threads' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+# Test that "SET slave_parallel_threads" is allowed with SUPER
+CREATE USER user1@localhost;
+GRANT SUPER ON *.* TO user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL slave_parallel_threads=256;
+SET slave_parallel_threads=256;
+ERROR HY000: Variable 'slave_parallel_threads' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION slave_parallel_threads=256;
+ERROR HY000: Variable 'slave_parallel_threads' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+SET @@global.slave_parallel_threads=@global;
diff --git a/mysql-test/suite/sys_vars/r/slave_parallel_workers_grant.result b/mysql-test/suite/sys_vars/r/slave_parallel_workers_grant.result
new file mode 100644
index 00000000000..1985cc429e5
--- /dev/null
+++ b/mysql-test/suite/sys_vars/r/slave_parallel_workers_grant.result
@@ -0,0 +1,46 @@
+#
+# MDEV-21966 Bind REPLICATION SLAVE ADMIN to a number of global system variables
+#
+SET @global=@@global.slave_parallel_workers;
+# Test that "SET slave_parallel_workers" is not allowed without REPLICATION SLAVE ADMIN or SUPER
+CREATE USER user1@localhost;
+GRANT ALL PRIVILEGES ON *.* TO user1@localhost;
+REVOKE REPLICATION SLAVE ADMIN, SUPER ON *.* FROM user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL slave_parallel_workers=256;
+ERROR 42000: Access denied; you need (at least one of) the SUPER, REPLICATION SLAVE ADMIN privilege(s) for this operation
+SET slave_parallel_workers=256;
+ERROR HY000: Variable 'slave_parallel_workers' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION slave_parallel_workers=256;
+ERROR HY000: Variable 'slave_parallel_workers' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+# Test that "SET slave_parallel_workers" is allowed with REPLICATION SLAVE ADMIN
+CREATE USER user1@localhost;
+GRANT REPLICATION SLAVE ADMIN ON *.* TO user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL slave_parallel_workers=256;
+SET slave_parallel_workers=256;
+ERROR HY000: Variable 'slave_parallel_workers' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION slave_parallel_workers=256;
+ERROR HY000: Variable 'slave_parallel_workers' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+# Test that "SET slave_parallel_workers" is allowed with SUPER
+CREATE USER user1@localhost;
+GRANT SUPER ON *.* TO user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL slave_parallel_workers=256;
+SET slave_parallel_workers=256;
+ERROR HY000: Variable 'slave_parallel_workers' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION slave_parallel_workers=256;
+ERROR HY000: Variable 'slave_parallel_workers' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+SET @@global.slave_parallel_workers=@global;
diff --git a/mysql-test/suite/sys_vars/r/slave_run_triggers_for_rbr_grant.result b/mysql-test/suite/sys_vars/r/slave_run_triggers_for_rbr_grant.result
new file mode 100644
index 00000000000..fd33c95f768
--- /dev/null
+++ b/mysql-test/suite/sys_vars/r/slave_run_triggers_for_rbr_grant.result
@@ -0,0 +1,46 @@
+#
+# MDEV-21966 Bind REPLICATION SLAVE ADMIN to a number of global system variables
+#
+SET @global=@@global.slave_run_triggers_for_rbr;
+# Test that "SET slave_run_triggers_for_rbr" is not allowed without REPLICATION SLAVE ADMIN or SUPER
+CREATE USER user1@localhost;
+GRANT ALL PRIVILEGES ON *.* TO user1@localhost;
+REVOKE REPLICATION SLAVE ADMIN, SUPER ON *.* FROM user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL slave_run_triggers_for_rbr=YES;
+ERROR 42000: Access denied; you need (at least one of) the SUPER, REPLICATION SLAVE ADMIN privilege(s) for this operation
+SET slave_run_triggers_for_rbr=YES;
+ERROR HY000: Variable 'slave_run_triggers_for_rbr' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION slave_run_triggers_for_rbr=YES;
+ERROR HY000: Variable 'slave_run_triggers_for_rbr' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+# Test that "SET slave_run_triggers_for_rbr" is allowed with REPLICATION SLAVE ADMIN
+CREATE USER user1@localhost;
+GRANT REPLICATION SLAVE ADMIN ON *.* TO user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL slave_run_triggers_for_rbr=YES;
+SET slave_run_triggers_for_rbr=YES;
+ERROR HY000: Variable 'slave_run_triggers_for_rbr' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION slave_run_triggers_for_rbr=YES;
+ERROR HY000: Variable 'slave_run_triggers_for_rbr' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+# Test that "SET slave_run_triggers_for_rbr" is allowed with SUPER
+CREATE USER user1@localhost;
+GRANT SUPER ON *.* TO user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL slave_run_triggers_for_rbr=YES;
+SET slave_run_triggers_for_rbr=YES;
+ERROR HY000: Variable 'slave_run_triggers_for_rbr' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION slave_run_triggers_for_rbr=YES;
+ERROR HY000: Variable 'slave_run_triggers_for_rbr' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+SET @@global.slave_run_triggers_for_rbr=@global;
diff --git a/mysql-test/suite/sys_vars/r/slave_sql_verify_checksum_grant.result b/mysql-test/suite/sys_vars/r/slave_sql_verify_checksum_grant.result
new file mode 100644
index 00000000000..1cc4f3f3ef9
--- /dev/null
+++ b/mysql-test/suite/sys_vars/r/slave_sql_verify_checksum_grant.result
@@ -0,0 +1,46 @@
+#
+# MDEV-21966 Bind REPLICATION SLAVE ADMIN to a number of global system variables
+#
+SET @global=@@global.slave_sql_verify_checksum;
+# Test that "SET slave_sql_verify_checksum" is not allowed without REPLICATION SLAVE ADMIN or SUPER
+CREATE USER user1@localhost;
+GRANT ALL PRIVILEGES ON *.* TO user1@localhost;
+REVOKE REPLICATION SLAVE ADMIN, SUPER ON *.* FROM user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL slave_sql_verify_checksum=1;
+ERROR 42000: Access denied; you need (at least one of) the SUPER, REPLICATION SLAVE ADMIN privilege(s) for this operation
+SET slave_sql_verify_checksum=1;
+ERROR HY000: Variable 'slave_sql_verify_checksum' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION slave_sql_verify_checksum=1;
+ERROR HY000: Variable 'slave_sql_verify_checksum' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+# Test that "SET slave_sql_verify_checksum" is allowed with REPLICATION SLAVE ADMIN
+CREATE USER user1@localhost;
+GRANT REPLICATION SLAVE ADMIN ON *.* TO user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL slave_sql_verify_checksum=1;
+SET slave_sql_verify_checksum=1;
+ERROR HY000: Variable 'slave_sql_verify_checksum' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION slave_sql_verify_checksum=1;
+ERROR HY000: Variable 'slave_sql_verify_checksum' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+# Test that "SET slave_sql_verify_checksum" is allowed with SUPER
+CREATE USER user1@localhost;
+GRANT SUPER ON *.* TO user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL slave_sql_verify_checksum=1;
+SET slave_sql_verify_checksum=1;
+ERROR HY000: Variable 'slave_sql_verify_checksum' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION slave_sql_verify_checksum=1;
+ERROR HY000: Variable 'slave_sql_verify_checksum' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+SET @@global.slave_sql_verify_checksum=@global;
diff --git a/mysql-test/suite/sys_vars/r/slave_transaction_retry_interval_grant.result b/mysql-test/suite/sys_vars/r/slave_transaction_retry_interval_grant.result
new file mode 100644
index 00000000000..e2e5e3963b5
--- /dev/null
+++ b/mysql-test/suite/sys_vars/r/slave_transaction_retry_interval_grant.result
@@ -0,0 +1,46 @@
+#
+# MDEV-21966 Bind REPLICATION SLAVE ADMIN to a number of global system variables
+#
+SET @global=@@global.slave_transaction_retry_interval;
+# Test that "SET slave_transaction_retry_interval" is not allowed without REPLICATION SLAVE ADMIN or SUPER
+CREATE USER user1@localhost;
+GRANT ALL PRIVILEGES ON *.* TO user1@localhost;
+REVOKE REPLICATION SLAVE ADMIN, SUPER ON *.* FROM user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL slave_transaction_retry_interval=256;
+ERROR 42000: Access denied; you need (at least one of) the SUPER, REPLICATION SLAVE ADMIN privilege(s) for this operation
+SET slave_transaction_retry_interval=256;
+ERROR HY000: Variable 'slave_transaction_retry_interval' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION slave_transaction_retry_interval=256;
+ERROR HY000: Variable 'slave_transaction_retry_interval' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+# Test that "SET slave_transaction_retry_interval" is allowed with REPLICATION SLAVE ADMIN
+CREATE USER user1@localhost;
+GRANT REPLICATION SLAVE ADMIN ON *.* TO user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL slave_transaction_retry_interval=256;
+SET slave_transaction_retry_interval=256;
+ERROR HY000: Variable 'slave_transaction_retry_interval' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION slave_transaction_retry_interval=256;
+ERROR HY000: Variable 'slave_transaction_retry_interval' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+# Test that "SET slave_transaction_retry_interval" is allowed with SUPER
+CREATE USER user1@localhost;
+GRANT SUPER ON *.* TO user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL slave_transaction_retry_interval=256;
+SET slave_transaction_retry_interval=256;
+ERROR HY000: Variable 'slave_transaction_retry_interval' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION slave_transaction_retry_interval=256;
+ERROR HY000: Variable 'slave_transaction_retry_interval' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+SET @@global.slave_transaction_retry_interval=@global;
diff --git a/mysql-test/suite/sys_vars/r/slave_type_conversions_grant.result b/mysql-test/suite/sys_vars/r/slave_type_conversions_grant.result
new file mode 100644
index 00000000000..01022e73dcb
--- /dev/null
+++ b/mysql-test/suite/sys_vars/r/slave_type_conversions_grant.result
@@ -0,0 +1,46 @@
+#
+# MDEV-21966 Bind REPLICATION SLAVE ADMIN to a number of global system variables
+#
+SET @global=@@global.slave_type_conversions;
+# Test that "SET slave_type_conversions" is not allowed without REPLICATION SLAVE ADMIN or SUPER
+CREATE USER user1@localhost;
+GRANT ALL PRIVILEGES ON *.* TO user1@localhost;
+REVOKE REPLICATION SLAVE ADMIN, SUPER ON *.* FROM user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL slave_type_conversions=ALL_NON_LOSSY;
+ERROR 42000: Access denied; you need (at least one of) the SUPER, REPLICATION SLAVE ADMIN privilege(s) for this operation
+SET slave_type_conversions=ALL_NON_LOSSY;
+ERROR HY000: Variable 'slave_type_conversions' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION slave_type_conversions=ALL_NON_LOSSY;
+ERROR HY000: Variable 'slave_type_conversions' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+# Test that "SET slave_type_conversions" is allowed with REPLICATION SLAVE ADMIN
+CREATE USER user1@localhost;
+GRANT REPLICATION SLAVE ADMIN ON *.* TO user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL slave_type_conversions=ALL_NON_LOSSY;
+SET slave_type_conversions=ALL_NON_LOSSY;
+ERROR HY000: Variable 'slave_type_conversions' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION slave_type_conversions=ALL_NON_LOSSY;
+ERROR HY000: Variable 'slave_type_conversions' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+# Test that "SET slave_type_conversions" is allowed with SUPER
+CREATE USER user1@localhost;
+GRANT SUPER ON *.* TO user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
+SET GLOBAL slave_type_conversions=ALL_NON_LOSSY;
+SET slave_type_conversions=ALL_NON_LOSSY;
+ERROR HY000: Variable 'slave_type_conversions' is a GLOBAL variable and should be set with SET GLOBAL
+SET SESSION slave_type_conversions=ALL_NON_LOSSY;
+ERROR HY000: Variable 'slave_type_conversions' is a GLOBAL variable and should be set with SET GLOBAL
+disconnect user1;
+connection default;
+DROP USER user1@localhost;
+SET @@global.slave_type_conversions=@global;
diff --git a/mysql-test/suite/sys_vars/t/init_slave_grant.test b/mysql-test/suite/sys_vars/t/init_slave_grant.test
new file mode 100644
index 00000000000..b2efbd1336c
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/init_slave_grant.test
@@ -0,0 +1,9 @@
+--echo #
+--echo # MDEV-21966 Bind REPLICATION SLAVE ADMIN to a number of global system variables
+--echo #
+
+--let var = init_slave
+--let grant = REPLICATION SLAVE ADMIN
+--let value = 'SET @x=1'
+
+--source suite/sys_vars/inc/sysvar_global_grant.inc
diff --git a/mysql-test/suite/sys_vars/t/read_binlog_speed_limit_grant.test b/mysql-test/suite/sys_vars/t/read_binlog_speed_limit_grant.test
new file mode 100644
index 00000000000..cb060e6c420
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/read_binlog_speed_limit_grant.test
@@ -0,0 +1,9 @@
+--echo #
+--echo # MDEV-21966 Bind REPLICATION SLAVE ADMIN to a number of global system variables
+--echo #
+
+--let var = read_binlog_speed_limit
+--let grant = REPLICATION SLAVE ADMIN
+--let value = 65536
+
+--source suite/sys_vars/inc/sysvar_global_grant.inc
diff --git a/mysql-test/suite/sys_vars/t/replicate_do_db_grant.test b/mysql-test/suite/sys_vars/t/replicate_do_db_grant.test
new file mode 100644
index 00000000000..fa6023ce73e
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/replicate_do_db_grant.test
@@ -0,0 +1,9 @@
+--echo #
+--echo # MDEV-21966 Bind REPLICATION SLAVE ADMIN to a number of global system variables
+--echo #
+
+--let var = replicate_do_db
+--let grant = REPLICATION SLAVE ADMIN
+--let value = ''
+
+--source suite/sys_vars/inc/sysvar_global_grant.inc
diff --git a/mysql-test/suite/sys_vars/t/replicate_do_table_grant.test b/mysql-test/suite/sys_vars/t/replicate_do_table_grant.test
new file mode 100644
index 00000000000..7dc800a331f
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/replicate_do_table_grant.test
@@ -0,0 +1,9 @@
+--echo #
+--echo # MDEV-21966 Bind REPLICATION SLAVE ADMIN to a number of global system variables
+--echo #
+
+--let var = replicate_do_table
+--let grant = REPLICATION SLAVE ADMIN
+--let value = ''
+
+--source suite/sys_vars/inc/sysvar_global_grant.inc
diff --git a/mysql-test/suite/sys_vars/t/replicate_events_marked_for_skip_grant.test b/mysql-test/suite/sys_vars/t/replicate_events_marked_for_skip_grant.test
new file mode 100644
index 00000000000..1baed3fecaa
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/replicate_events_marked_for_skip_grant.test
@@ -0,0 +1,9 @@
+--echo #
+--echo # MDEV-21966 Bind REPLICATION SLAVE ADMIN to a number of global system variables
+--echo #
+
+--let var = replicate_events_marked_for_skip
+--let grant = REPLICATION SLAVE ADMIN
+--let value = REPLICATE
+
+--source suite/sys_vars/inc/sysvar_global_grant.inc
diff --git a/mysql-test/suite/sys_vars/t/replicate_ignore_db_grant.test b/mysql-test/suite/sys_vars/t/replicate_ignore_db_grant.test
new file mode 100644
index 00000000000..c073ccf2b7d
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/replicate_ignore_db_grant.test
@@ -0,0 +1,9 @@
+--echo #
+--echo # MDEV-21966 Bind REPLICATION SLAVE ADMIN to a number of global system variables
+--echo #
+
+--let var = replicate_ignore_db
+--let grant = REPLICATION SLAVE ADMIN
+--let value = ''
+
+--source suite/sys_vars/inc/sysvar_global_grant.inc
diff --git a/mysql-test/suite/sys_vars/t/replicate_ignore_table_grant.test b/mysql-test/suite/sys_vars/t/replicate_ignore_table_grant.test
new file mode 100644
index 00000000000..d34a95cc55b
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/replicate_ignore_table_grant.test
@@ -0,0 +1,9 @@
+--echo #
+--echo # MDEV-21966 Bind REPLICATION SLAVE ADMIN to a number of global system variables
+--echo #
+
+--let var = replicate_ignore_table
+--let grant = REPLICATION SLAVE ADMIN
+--let value = ''
+
+--source suite/sys_vars/inc/sysvar_global_grant.inc
diff --git a/mysql-test/suite/sys_vars/t/replicate_wild_do_table_grant.test b/mysql-test/suite/sys_vars/t/replicate_wild_do_table_grant.test
new file mode 100644
index 00000000000..f787b3336e6
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/replicate_wild_do_table_grant.test
@@ -0,0 +1,9 @@
+--echo #
+--echo # MDEV-21966 Bind REPLICATION SLAVE ADMIN to a number of global system variables
+--echo #
+
+--let var = replicate_wild_do_table
+--let grant = REPLICATION SLAVE ADMIN
+--let value = ''
+
+--source suite/sys_vars/inc/sysvar_global_grant.inc
diff --git a/mysql-test/suite/sys_vars/t/replicate_wild_ignore_table_grant.test b/mysql-test/suite/sys_vars/t/replicate_wild_ignore_table_grant.test
new file mode 100644
index 00000000000..f4ed0cc5072
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/replicate_wild_ignore_table_grant.test
@@ -0,0 +1,9 @@
+--echo #
+--echo # MDEV-21966 Bind REPLICATION SLAVE ADMIN to a number of global system variables
+--echo #
+
+--let var = replicate_wild_ignore_table
+--let grant = REPLICATION SLAVE ADMIN
+--let value = ''
+
+--source suite/sys_vars/inc/sysvar_global_grant.inc
diff --git a/mysql-test/suite/sys_vars/t/slave_compressed_protocol_grant.test b/mysql-test/suite/sys_vars/t/slave_compressed_protocol_grant.test
new file mode 100644
index 00000000000..2db1a0f4fe0
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/slave_compressed_protocol_grant.test
@@ -0,0 +1,9 @@
+--echo #
+--echo # MDEV-21966 Bind REPLICATION SLAVE ADMIN to a number of global system variables
+--echo #
+
+--let var = slave_compressed_protocol
+--let grant = REPLICATION SLAVE ADMIN
+--let value = 1
+
+--source suite/sys_vars/inc/sysvar_global_grant.inc
diff --git a/mysql-test/suite/sys_vars/t/slave_ddl_exec_mode_grant.test b/mysql-test/suite/sys_vars/t/slave_ddl_exec_mode_grant.test
new file mode 100644
index 00000000000..b6cee5ce18a
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/slave_ddl_exec_mode_grant.test
@@ -0,0 +1,9 @@
+--echo #
+--echo # MDEV-21966 Bind REPLICATION SLAVE ADMIN to a number of global system variables
+--echo #
+
+--let var = slave_ddl_exec_mode
+--let grant = REPLICATION SLAVE ADMIN
+--let value = STRICT
+
+--source suite/sys_vars/inc/sysvar_global_grant.inc
diff --git a/mysql-test/suite/sys_vars/t/slave_domain_parallel_threads_grant.test b/mysql-test/suite/sys_vars/t/slave_domain_parallel_threads_grant.test
new file mode 100644
index 00000000000..138a8bfacb2
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/slave_domain_parallel_threads_grant.test
@@ -0,0 +1,9 @@
+--echo #
+--echo # MDEV-21966 Bind REPLICATION SLAVE ADMIN to a number of global system variables
+--echo #
+
+--let var = slave_domain_parallel_threads
+--let grant = REPLICATION SLAVE ADMIN
+--let value = 0
+
+--source suite/sys_vars/inc/sysvar_global_grant.inc
diff --git a/mysql-test/suite/sys_vars/t/slave_exec_mode_grant.test b/mysql-test/suite/sys_vars/t/slave_exec_mode_grant.test
new file mode 100644
index 00000000000..47634ea3bd3
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/slave_exec_mode_grant.test
@@ -0,0 +1,9 @@
+--echo #
+--echo # MDEV-21966 Bind REPLICATION SLAVE ADMIN to a number of global system variables
+--echo #
+
+--let var = slave_exec_mode
+--let grant = REPLICATION SLAVE ADMIN
+--let value = STRICT
+
+--source suite/sys_vars/inc/sysvar_global_grant.inc
diff --git a/mysql-test/suite/sys_vars/t/slave_max_allowed_packet_grant.test b/mysql-test/suite/sys_vars/t/slave_max_allowed_packet_grant.test
new file mode 100644
index 00000000000..2a873f11c71
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/slave_max_allowed_packet_grant.test
@@ -0,0 +1,9 @@
+--echo #
+--echo # MDEV-21966 Bind REPLICATION SLAVE ADMIN to a number of global system variables
+--echo #
+
+--let var = slave_max_allowed_packet
+--let grant = REPLICATION SLAVE ADMIN
+--let value = 65536
+
+--source suite/sys_vars/inc/sysvar_global_grant.inc
diff --git a/mysql-test/suite/sys_vars/t/slave_net_timeout_grant.test b/mysql-test/suite/sys_vars/t/slave_net_timeout_grant.test
new file mode 100644
index 00000000000..3cb6f9a9fdb
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/slave_net_timeout_grant.test
@@ -0,0 +1,9 @@
+--echo #
+--echo # MDEV-21966 Bind REPLICATION SLAVE ADMIN to a number of global system variables
+--echo #
+
+--let var = slave_net_timeout
+--let grant = REPLICATION SLAVE ADMIN
+--let value = 60
+
+--source suite/sys_vars/inc/sysvar_global_grant.inc
diff --git a/mysql-test/suite/sys_vars/t/slave_parallel_max_queued_grant.test b/mysql-test/suite/sys_vars/t/slave_parallel_max_queued_grant.test
new file mode 100644
index 00000000000..e23fe1a3dd4
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/slave_parallel_max_queued_grant.test
@@ -0,0 +1,9 @@
+--echo #
+--echo # MDEV-21966 Bind REPLICATION SLAVE ADMIN to a number of global system variables
+--echo #
+
+--let var = slave_parallel_max_queued
+--let grant = REPLICATION SLAVE ADMIN
+--let value = 65536
+
+--source suite/sys_vars/inc/sysvar_global_grant.inc
diff --git a/mysql-test/suite/sys_vars/t/slave_parallel_mode_grant.test b/mysql-test/suite/sys_vars/t/slave_parallel_mode_grant.test
new file mode 100644
index 00000000000..a61640ede49
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/slave_parallel_mode_grant.test
@@ -0,0 +1,9 @@
+--echo #
+--echo # MDEV-21966 Bind REPLICATION SLAVE ADMIN to a number of global system variables
+--echo #
+
+--let var = slave_parallel_mode
+--let grant = REPLICATION SLAVE ADMIN
+--let value = 1
+
+--source suite/sys_vars/inc/sysvar_global_grant.inc
diff --git a/mysql-test/suite/sys_vars/t/slave_parallel_threads_grant.test b/mysql-test/suite/sys_vars/t/slave_parallel_threads_grant.test
new file mode 100644
index 00000000000..8a8511223ae
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/slave_parallel_threads_grant.test
@@ -0,0 +1,9 @@
+--echo #
+--echo # MDEV-21966 Bind REPLICATION SLAVE ADMIN to a number of global system variables
+--echo #
+
+--let var = slave_parallel_threads
+--let grant = REPLICATION SLAVE ADMIN
+--let value = 256
+
+--source suite/sys_vars/inc/sysvar_global_grant.inc
diff --git a/mysql-test/suite/sys_vars/t/slave_parallel_workers_grant.test b/mysql-test/suite/sys_vars/t/slave_parallel_workers_grant.test
new file mode 100644
index 00000000000..05974560dde
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/slave_parallel_workers_grant.test
@@ -0,0 +1,9 @@
+--echo #
+--echo # MDEV-21966 Bind REPLICATION SLAVE ADMIN to a number of global system variables
+--echo #
+
+--let var = slave_parallel_workers
+--let grant = REPLICATION SLAVE ADMIN
+--let value = 256
+
+--source suite/sys_vars/inc/sysvar_global_grant.inc
diff --git a/mysql-test/suite/sys_vars/t/slave_run_triggers_for_rbr_grant.test b/mysql-test/suite/sys_vars/t/slave_run_triggers_for_rbr_grant.test
new file mode 100644
index 00000000000..91acd1ff918
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/slave_run_triggers_for_rbr_grant.test
@@ -0,0 +1,9 @@
+--echo #
+--echo # MDEV-21966 Bind REPLICATION SLAVE ADMIN to a number of global system variables
+--echo #
+
+--let var = slave_run_triggers_for_rbr
+--let grant = REPLICATION SLAVE ADMIN
+--let value = YES
+
+--source suite/sys_vars/inc/sysvar_global_grant.inc
diff --git a/mysql-test/suite/sys_vars/t/slave_sql_verify_checksum_grant.test b/mysql-test/suite/sys_vars/t/slave_sql_verify_checksum_grant.test
new file mode 100644
index 00000000000..683d53a6fef
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/slave_sql_verify_checksum_grant.test
@@ -0,0 +1,9 @@
+--echo #
+--echo # MDEV-21966 Bind REPLICATION SLAVE ADMIN to a number of global system variables
+--echo #
+
+--let var = slave_sql_verify_checksum
+--let grant = REPLICATION SLAVE ADMIN
+--let value = 1
+
+--source suite/sys_vars/inc/sysvar_global_grant.inc
diff --git a/mysql-test/suite/sys_vars/t/slave_transaction_retry_interval_grant.test b/mysql-test/suite/sys_vars/t/slave_transaction_retry_interval_grant.test
new file mode 100644
index 00000000000..47a51fc9c2b
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/slave_transaction_retry_interval_grant.test
@@ -0,0 +1,9 @@
+--echo #
+--echo # MDEV-21966 Bind REPLICATION SLAVE ADMIN to a number of global system variables
+--echo #
+
+--let var = slave_transaction_retry_interval
+--let grant = REPLICATION SLAVE ADMIN
+--let value = 256
+
+--source suite/sys_vars/inc/sysvar_global_grant.inc
diff --git a/mysql-test/suite/sys_vars/t/slave_type_conversions_grant.test b/mysql-test/suite/sys_vars/t/slave_type_conversions_grant.test
new file mode 100644
index 00000000000..d3c9b239def
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/slave_type_conversions_grant.test
@@ -0,0 +1,9 @@
+--echo #
+--echo # MDEV-21966 Bind REPLICATION SLAVE ADMIN to a number of global system variables
+--echo #
+
+--let var = slave_type_conversions
+--let grant = REPLICATION SLAVE ADMIN
+--let value = ALL_NON_LOSSY
+
+--source suite/sys_vars/inc/sysvar_global_grant.inc
diff --git a/sql/privilege.h b/sql/privilege.h
index fef44315d4f..098a0e15c0b 100644
--- a/sql/privilege.h
+++ b/sql/privilege.h
@@ -477,6 +477,58 @@ constexpr privilege_t PRIV_STMT_BINLOG= REPL_SLAVE_ADMIN_ACL | SUPER_ACL;
constexpr privilege_t PRIV_STMT_SHOW_RELAYLOG_EVENTS= REPL_SLAVE_ADMIN_ACL;
+/*
+ Privileges for slave related global variables.
+ Were SUPER prior to 10.5.2.
+*/
+constexpr privilege_t PRIV_SET_SYSTEM_GLOBAL_VAR_REPLICATE_EVENTS_MARKED_FOR_SKIP=
+ REPL_SLAVE_ADMIN_ACL | SUPER_ACL;
+constexpr privilege_t PRIV_SET_SYSTEM_GLOBAL_VAR_REPLICATE_DO_DB=
+ REPL_SLAVE_ADMIN_ACL | SUPER_ACL;
+constexpr privilege_t PRIV_SET_SYSTEM_GLOBAL_VAR_REPLICATE_DO_TABLE=
+ REPL_SLAVE_ADMIN_ACL | SUPER_ACL;
+constexpr privilege_t PRIV_SET_SYSTEM_GLOBAL_VAR_REPLICATE_IGNORE_DB=
+ REPL_SLAVE_ADMIN_ACL | SUPER_ACL;
+constexpr privilege_t PRIV_SET_SYSTEM_GLOBAL_VAR_REPLICATE_IGNORE_TABLE=
+ REPL_SLAVE_ADMIN_ACL | SUPER_ACL;
+constexpr privilege_t PRIV_SET_SYSTEM_GLOBAL_VAR_REPLICATE_WILD_DO_TABLE=
+ REPL_SLAVE_ADMIN_ACL | SUPER_ACL;
+constexpr privilege_t PRIV_SET_SYSTEM_GLOBAL_VAR_REPLICATE_WILD_IGNORE_TABLE=
+ REPL_SLAVE_ADMIN_ACL | SUPER_ACL;
+constexpr privilege_t PRIV_SET_SYSTEM_GLOBAL_VAR_READ_BINLOG_SPEED_LIMIT=
+ REPL_SLAVE_ADMIN_ACL | SUPER_ACL;
+constexpr privilege_t PRIV_SET_SYSTEM_GLOBAL_VAR_SLAVE_COMPRESSED_PROTOCOL=
+ REPL_SLAVE_ADMIN_ACL | SUPER_ACL;
+constexpr privilege_t PRIV_SET_SYSTEM_GLOBAL_VAR_SLAVE_DDL_EXEC_MODE=
+ REPL_SLAVE_ADMIN_ACL | SUPER_ACL;
+constexpr privilege_t PRIV_SET_SYSTEM_GLOBAL_VAR_SLAVE_DOMAIN_PARALLEL_THREADS=
+ REPL_SLAVE_ADMIN_ACL | SUPER_ACL;
+constexpr privilege_t PRIV_SET_SYSTEM_GLOBAL_VAR_SLAVE_EXEC_MODE=
+ REPL_SLAVE_ADMIN_ACL | SUPER_ACL;
+constexpr privilege_t PRIV_SET_SYSTEM_GLOBAL_VAR_SLAVE_MAX_ALLOWED_PACKET=
+ REPL_SLAVE_ADMIN_ACL | SUPER_ACL;
+constexpr privilege_t PRIV_SET_SYSTEM_GLOBAL_VAR_SLAVE_NET_TIMEOUT=
+ REPL_SLAVE_ADMIN_ACL | SUPER_ACL;
+constexpr privilege_t PRIV_SET_SYSTEM_GLOBAL_VAR_SLAVE_PARALLEL_MAX_QUEUED=
+ REPL_SLAVE_ADMIN_ACL | SUPER_ACL;
+constexpr privilege_t PRIV_SET_SYSTEM_GLOBAL_VAR_SLAVE_PARALLEL_MODE=
+ REPL_SLAVE_ADMIN_ACL | SUPER_ACL;
+constexpr privilege_t PRIV_SET_SYSTEM_GLOBAL_VAR_SLAVE_PARALLEL_THREADS=
+ REPL_SLAVE_ADMIN_ACL | SUPER_ACL;
+constexpr privilege_t PRIV_SET_SYSTEM_GLOBAL_VAR_SLAVE_PARALLEL_WORKERS=
+ REPL_SLAVE_ADMIN_ACL | SUPER_ACL;
+constexpr privilege_t PRIV_SET_SYSTEM_GLOBAL_VAR_SLAVE_RUN_TRIGGERS_FOR_RBR=
+ REPL_SLAVE_ADMIN_ACL | SUPER_ACL;
+constexpr privilege_t PRIV_SET_SYSTEM_GLOBAL_VAR_SLAVE_SQL_VERIFY_CHECKSUM=
+ REPL_SLAVE_ADMIN_ACL | SUPER_ACL;
+constexpr privilege_t PRIV_SET_SYSTEM_GLOBAL_VAR_SLAVE_TRANSACTION_RETRY_INTERVAL=
+ REPL_SLAVE_ADMIN_ACL | SUPER_ACL;
+constexpr privilege_t PRIV_SET_SYSTEM_GLOBAL_VAR_SLAVE_TYPE_CONVERSIONS=
+ REPL_SLAVE_ADMIN_ACL | SUPER_ACL;
+constexpr privilege_t PRIV_SET_SYSTEM_GLOBAL_VAR_INIT_SLAVE=
+ REPL_SLAVE_ADMIN_ACL | SUPER_ACL;
+
+
/* Privileges for federated database related statements */
// Was SUPER_ACL prior to 10.5.2
constexpr privilege_t PRIV_STMT_CREATE_SERVER= FEDERATED_ADMIN_ACL | SUPER_ACL;
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index 87e7da9dedd..8c2278db8d1 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -1285,7 +1285,9 @@ static Sys_var_charptr_fscs Sys_init_file(
DEFAULT(0));
static PolyLock_rwlock PLock_sys_init_slave(&LOCK_sys_init_slave);
-static Sys_var_lexstring Sys_init_slave(
+static Sys_var_on_access_global<Sys_var_lexstring,
+ PRIV_SET_SYSTEM_GLOBAL_VAR_INIT_SLAVE>
+Sys_init_slave(
"init_slave", "Command(s) that are executed by a slave server "
"each time the SQL thread starts", GLOBAL_VAR(opt_init_slave),
CMD_LINE(REQUIRED_ARG),
@@ -1593,7 +1595,9 @@ static Sys_var_ulong Sys_max_allowed_packet(
BLOCK_SIZE(1024), NO_MUTEX_GUARD, NOT_IN_BINLOG,
ON_CHECK(check_max_allowed_packet));
-static Sys_var_ulong Sys_slave_max_allowed_packet(
+static Sys_var_on_access_global<Sys_var_ulong,
+ PRIV_SET_SYSTEM_GLOBAL_VAR_SLAVE_MAX_ALLOWED_PACKET>
+Sys_slave_max_allowed_packet(
"slave_max_allowed_packet",
"The maximum packet length to sent successfully from the master to slave.",
GLOBAL_VAR(slave_max_allowed_packet), CMD_LINE(REQUIRED_ARG),
@@ -2154,7 +2158,9 @@ fix_slave_parallel_threads(sys_var *self, THD *thd, enum_var_type type)
}
-static Sys_var_ulong Sys_slave_parallel_threads(
+static Sys_var_on_access_global<Sys_var_ulong,
+ PRIV_SET_SYSTEM_GLOBAL_VAR_SLAVE_PARALLEL_THREADS>
+Sys_slave_parallel_threads(
"slave_parallel_threads",
"If non-zero, number of threads to spawn to apply in parallel events "
"on the slave that were group-committed on the master or were logged "
@@ -2167,7 +2173,9 @@ static Sys_var_ulong Sys_slave_parallel_threads(
ON_UPDATE(fix_slave_parallel_threads));
/* Alias for @@slave_parallel_threads to match what MySQL 5.7 uses. */
-static Sys_var_ulong Sys_slave_parallel_workers(
+static Sys_var_on_access_global<Sys_var_ulong,
+ PRIV_SET_SYSTEM_GLOBAL_VAR_SLAVE_PARALLEL_WORKERS>
+Sys_slave_parallel_workers(
"slave_parallel_workers",
"Alias for slave_parallel_threads",
GLOBAL_VAR(opt_slave_parallel_threads), CMD_LINE(REQUIRED_ARG),
@@ -2195,7 +2203,9 @@ fix_slave_domain_parallel_threads(sys_var *self, THD *thd, enum_var_type type)
}
-static Sys_var_ulong Sys_slave_domain_parallel_threads(
+static Sys_var_on_access_global<Sys_var_ulong,
+ PRIV_SET_SYSTEM_GLOBAL_VAR_SLAVE_DOMAIN_PARALLEL_THREADS>
+Sys_slave_domain_parallel_threads(
"slave_domain_parallel_threads",
"Maximum number of parallel threads to use on slave for events in a "
"single replication domain. When using multiple domains, this can be "
@@ -2209,7 +2219,9 @@ static Sys_var_ulong Sys_slave_domain_parallel_threads(
ON_UPDATE(fix_slave_domain_parallel_threads));
-static Sys_var_ulong Sys_slave_parallel_max_queued(
+static Sys_var_on_access_global<Sys_var_ulong,
+ PRIV_SET_SYSTEM_GLOBAL_VAR_SLAVE_PARALLEL_MAX_QUEUED>
+Sys_slave_parallel_max_queued(
"slave_parallel_max_queued",
"Limit on how much memory SQL threads should use per parallel "
"replication thread when reading ahead in the relay log looking for "
@@ -2306,7 +2318,9 @@ export TYPELIB slave_parallel_mode_typelib = {
NULL
};
-static Sys_var_slave_parallel_mode Sys_slave_parallel_mode(
+static Sys_var_on_access_global<Sys_var_slave_parallel_mode,
+ PRIV_SET_SYSTEM_GLOBAL_VAR_SLAVE_PARALLEL_MODE>
+Sys_slave_parallel_mode(
"slave_parallel_mode",
"Controls what transactions are applied in parallel when using "
"--slave-parallel-threads. Possible values: \"optimistic\" tries to "
@@ -3204,7 +3218,9 @@ static Sys_var_ulong Sys_server_id(
VALID_RANGE(1, UINT_MAX32), DEFAULT(1), BLOCK_SIZE(1), NO_MUTEX_GUARD,
NOT_IN_BINLOG, ON_CHECK(check_has_super), ON_UPDATE(fix_server_id));
-static Sys_var_mybool Sys_slave_compressed_protocol(
+static Sys_var_on_access_global<Sys_var_mybool,
+ PRIV_SET_SYSTEM_GLOBAL_VAR_SLAVE_COMPRESSED_PROTOCOL>
+Sys_slave_compressed_protocol(
"slave_compressed_protocol",
"Use compression on master/slave protocol",
GLOBAL_VAR(opt_slave_compressed_protocol), CMD_LINE(OPT_ARG),
@@ -3212,7 +3228,9 @@ static Sys_var_mybool Sys_slave_compressed_protocol(
#ifdef HAVE_REPLICATION
static const char *slave_exec_mode_names[]= {"STRICT", "IDEMPOTENT", 0};
-static Sys_var_enum Slave_exec_mode(
+static Sys_var_on_access_global<Sys_var_enum,
+ PRIV_SET_SYSTEM_GLOBAL_VAR_SLAVE_EXEC_MODE>
+Slave_exec_mode(
"slave_exec_mode",
"How replication events should be executed. Legal values "
"are STRICT (default) and IDEMPOTENT. In IDEMPOTENT mode, "
@@ -3224,7 +3242,9 @@ static Sys_var_enum Slave_exec_mode(
GLOBAL_VAR(slave_exec_mode_options), CMD_LINE(REQUIRED_ARG),
slave_exec_mode_names, DEFAULT(SLAVE_EXEC_MODE_STRICT));
-static Sys_var_enum Slave_ddl_exec_mode(
+static Sys_var_on_access_global<Sys_var_enum,
+ PRIV_SET_SYSTEM_GLOBAL_VAR_SLAVE_DDL_EXEC_MODE>
+Slave_ddl_exec_mode(
"slave_ddl_exec_mode",
"How replication events should be executed. Legal values "
"are STRICT and IDEMPOTENT (default). In IDEMPOTENT mode, "
@@ -3236,7 +3256,9 @@ static Sys_var_enum Slave_ddl_exec_mode(
static const char *slave_run_triggers_for_rbr_names[]=
{"NO", "YES", "LOGGING", "ENFORCE", 0};
-static Sys_var_enum Slave_run_triggers_for_rbr(
+static Sys_var_on_access_global<Sys_var_enum,
+ PRIV_SET_SYSTEM_GLOBAL_VAR_SLAVE_RUN_TRIGGERS_FOR_RBR>
+Slave_run_triggers_for_rbr(
"slave_run_triggers_for_rbr",
"Modes for how triggers in row-base replication on slave side will be "
"executed. Legal values are NO (default), YES, LOGGING and ENFORCE. NO means "
@@ -3251,7 +3273,9 @@ static Sys_var_enum Slave_run_triggers_for_rbr(
DEFAULT(SLAVE_RUN_TRIGGERS_FOR_RBR_NO));
static const char *slave_type_conversions_name[]= {"ALL_LOSSY", "ALL_NON_LOSSY", 0};
-static Sys_var_set Slave_type_conversions(
+static Sys_var_on_access_global<Sys_var_set,
+ PRIV_SET_SYSTEM_GLOBAL_VAR_SLAVE_TYPE_CONVERSIONS>
+Slave_type_conversions(
"slave_type_conversions",
"Set of slave type conversions that are enabled."
" If the variable is empty, no conversions are"
@@ -3260,7 +3284,9 @@ static Sys_var_set Slave_type_conversions(
slave_type_conversions_name,
DEFAULT(0));
-static Sys_var_mybool Sys_slave_sql_verify_checksum(
+static Sys_var_on_access_global<Sys_var_mybool,
+ PRIV_SET_SYSTEM_GLOBAL_VAR_SLAVE_SQL_VERIFY_CHECKSUM>
+Sys_slave_sql_verify_checksum(
"slave_sql_verify_checksum",
"Force checksum verification of replication events after reading them "
"from relay log. Note: Events are always checksum-verified by slave on "
@@ -3294,7 +3320,9 @@ Sys_var_replicate_events_marked_for_skip::global_update(THD *thd, set_var *var)
DBUG_RETURN(result);
}
-static Sys_var_replicate_events_marked_for_skip Replicate_events_marked_for_skip
+static Sys_var_on_access_global<Sys_var_replicate_events_marked_for_skip,
+ PRIV_SET_SYSTEM_GLOBAL_VAR_REPLICATE_EVENTS_MARKED_FOR_SKIP>
+Replicate_events_marked_for_skip
("replicate_events_marked_for_skip",
"Whether the slave should replicate events that were created with "
"@@skip_replication=1 on the master. Default REPLICATE (no events are "
@@ -5240,12 +5268,14 @@ static Sys_var_rpl_filter Sys_replicate_do_db(
"statement-based replication, only the default database (that "
"is, the one selected by USE) is considered, not any explicitly "
"mentioned tables in the query. For row-based replication, the "
- "actual names of table(s) being updated are checked.");
+ "actual names of table(s) being updated are checked.",
+ PRIV_SET_SYSTEM_GLOBAL_VAR_REPLICATE_DO_DB);
static Sys_var_rpl_filter Sys_replicate_do_table(
"replicate_do_table", OPT_REPLICATE_DO_TABLE,
"Tells the slave to restrict replication to tables in the "
- "comma-separated list.");
+ "comma-separated list.",
+ PRIV_SET_SYSTEM_GLOBAL_VAR_REPLICATE_DO_TABLE);
static Sys_var_rpl_filter Sys_replicate_ignore_db(
"replicate_ignore_db", OPT_REPLICATE_IGNORE_DB,
@@ -5254,24 +5284,28 @@ static Sys_var_rpl_filter Sys_replicate_ignore_db(
"statement-based replication, only the default database (that "
"is, the one selected by USE) is considered, not any explicitly "
"mentioned tables in the query. For row-based replication, the "
- "actual names of table(s) being updated are checked.");
+ "actual names of table(s) being updated are checked.",
+ PRIV_SET_SYSTEM_GLOBAL_VAR_REPLICATE_IGNORE_DB);
static Sys_var_rpl_filter Sys_replicate_ignore_table(
"replicate_ignore_table", OPT_REPLICATE_IGNORE_TABLE,
"Tells the slave thread not to replicate any statement that "
"updates the specified table, even if any other tables might be "
- "updated by the same statement.");
+ "updated by the same statement.",
+ PRIV_SET_SYSTEM_GLOBAL_VAR_REPLICATE_IGNORE_TABLE);
static Sys_var_rpl_filter Sys_replicate_wild_do_table(
"replicate_wild_do_table", OPT_REPLICATE_WILD_DO_TABLE,
"Tells the slave thread to restrict replication to statements "
"where any of the updated tables match the specified database "
- "and table name patterns.");
+ "and table name patterns.",
+ PRIV_SET_SYSTEM_GLOBAL_VAR_REPLICATE_WILD_DO_TABLE);
static Sys_var_rpl_filter Sys_replicate_wild_ignore_table(
"replicate_wild_ignore_table", OPT_REPLICATE_WILD_IGNORE_TABLE,
"Tells the slave thread to not replicate to the tables that "
- "match the given wildcard pattern.");
+ "match the given wildcard pattern.",
+ PRIV_SET_SYSTEM_GLOBAL_VAR_REPLICATE_WILD_IGNORE_TABLE);
static Sys_var_charptr_fscs Sys_slave_load_tmpdir(
"slave_load_tmpdir", "The location where the slave should put "
@@ -5279,7 +5313,9 @@ static Sys_var_charptr_fscs Sys_slave_load_tmpdir(
READ_ONLY GLOBAL_VAR(slave_load_tmpdir), CMD_LINE(REQUIRED_ARG),
DEFAULT(0));
-static Sys_var_uint Sys_slave_net_timeout(
+static Sys_var_on_access_global<Sys_var_uint,
+ PRIV_SET_SYSTEM_GLOBAL_VAR_SLAVE_NET_TIMEOUT>
+Sys_slave_net_timeout(
"slave_net_timeout", "Number of seconds to wait for more data "
"from any master/slave connection before aborting the read",
GLOBAL_VAR(slave_net_timeout), CMD_LINE(REQUIRED_ARG),
@@ -5397,7 +5433,9 @@ static Sys_var_charptr Sys_slave_skip_errors(
READ_ONLY GLOBAL_VAR(opt_slave_skip_errors), CMD_LINE(REQUIRED_ARG),
DEFAULT(0));
-static Sys_var_ulonglong Sys_read_binlog_speed_limit(
+static Sys_var_on_access_global<Sys_var_ulonglong,
+ PRIV_SET_SYSTEM_GLOBAL_VAR_READ_BINLOG_SPEED_LIMIT>
+Sys_read_binlog_speed_limit(
"read_binlog_speed_limit", "Maximum speed(KB/s) to read binlog from"
" master (0 = no limit)",
GLOBAL_VAR(opt_read_binlog_speed_limit), CMD_LINE(REQUIRED_ARG),
@@ -5455,7 +5493,9 @@ static Sys_var_ulong Sys_slave_trans_retries(
GLOBAL_VAR(slave_trans_retries), CMD_LINE(REQUIRED_ARG),
VALID_RANGE(0, UINT_MAX), DEFAULT(10), BLOCK_SIZE(1));
-static Sys_var_ulong Sys_slave_trans_retry_interval(
+static Sys_var_on_access_global<Sys_var_ulong,
+ PRIV_SET_SYSTEM_GLOBAL_VAR_SLAVE_TRANSACTION_RETRY_INTERVAL>
+Sys_slave_trans_retry_interval(
"slave_transaction_retry_interval", "Interval of the slave SQL "
"thread will retry a transaction in case it failed with a deadlock "
"or elapsed lock wait timeout or listed in "
diff --git a/sql/sys_vars.ic b/sql/sys_vars.ic
index acfbf3e9b49..b61183e1f5a 100644
--- a/sql/sys_vars.ic
+++ b/sql/sys_vars.ic
@@ -735,12 +735,15 @@ class Sys_var_rpl_filter: public sys_var
{
private:
int opt_id;
+ privilege_t m_access_global;
public:
- Sys_var_rpl_filter(const char *name, int getopt_id, const char *comment)
+ Sys_var_rpl_filter(const char *name, int getopt_id, const char *comment,
+ privilege_t access_global)
: sys_var(&all_sys_vars, name, comment, sys_var::GLOBAL, 0, NO_GETOPT,
NO_ARG, SHOW_CHAR, 0, NULL, VARIABLE_NOT_IN_BINLOG,
- NULL, NULL, NULL), opt_id(getopt_id)
+ NULL, NULL, NULL), opt_id(getopt_id),
+ m_access_global(access_global)
{
option.var_type|= GET_STR | GET_ASK_ADDR;
}
@@ -763,6 +766,11 @@ public:
bool global_update(THD *thd, set_var *var);
+ bool on_check_access_global(THD *thd) const override
+ {
+ return check_global_access(thd, m_access_global);
+ }
+
protected:
uchar *global_value_ptr(THD *thd, const LEX_CSTRING *base);
bool set_filter_value(const char *value, Master_info *mi);