Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions mysql-test/r/all_persisted_variables.result
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@ include/assert.inc [Expect 500+ variables in the table. Due to open Bugs, we are

# Test SET PERSIST

include/assert.inc [Expect 489 persisted variables in the table.]
include/assert.inc [Expect 490 persisted variables in the table.]

************************************************************
* 3. Restart server, it must preserve the persisted variable
* settings. Verify persisted configuration.
************************************************************
# restart

include/assert.inc [Expect 489 persisted variables in persisted_variables table.]
include/assert.inc [Expect 489 persisted variables shown as PERSISTED in variables_info table.]
include/assert.inc [Expect 489 persisted variables with matching peristed and global values.]
include/assert.inc [Expect 490 persisted variables in persisted_variables table.]
include/assert.inc [Expect 490 persisted variables shown as PERSISTED in variables_info table.]
include/assert.inc [Expect 490 persisted variables with matching peristed and global values.]

************************************************************
* 4. Test RESET PERSIST IF EXISTS. Verify persisted variable
Expand Down
7 changes: 7 additions & 0 deletions mysql-test/r/mysqld--help-notwin.result
Original file line number Diff line number Diff line change
Expand Up @@ -1269,6 +1269,12 @@ The following options may be given as the first argument:
Number of times the replication applier will retry a
transaction in case it failed with a deadlock or other
transient error, before it gives up and stops.
--replica-translate-deprecated-priv
Rewrite replicated SET_USER_ID to
SET_ANY_DEFINER,ALLOW_NONEXISTENT_DEFINER in the replica
SQL applier. Disabled by default, does not affect
user-issued GRANT/REVOKE, and can be changed only while
the replica SQL thread is stopped.
--replica-type-conversions=name
Set of type conversions that may be used by the
replication applier thread for row events. Allowed values
Expand Down Expand Up @@ -2082,6 +2088,7 @@ replica-preserve-commit-order TRUE
replica-skip-errors (No default value)
replica-sql-verify-checksum TRUE
replica-transaction-retries 10
replica-translate-deprecated-priv FALSE
replica-type-conversions
replicate-same-server-id FALSE
replication-optimize-for-static-plugin-config FALSE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ INSERT INTO aliases(name) VALUES
('slave_parallel_workers'), ('slave_pending_jobs_size_max'),
('pseudo_slave_mode'), ('skip_slave_start');

include/assert.inc [Expect 113 variables in the table.]
include/assert.inc [Expect 114 variables in the table.]

# Test SET PERSIST_ONLY
SET PERSIST_ONLY binlog_cache_size = @@GLOBAL.binlog_cache_size;
Expand Down Expand Up @@ -164,6 +164,7 @@ SET PERSIST_ONLY replica_preserve_commit_order = @@GLOBAL.replica_preserve_commi
SET PERSIST_ONLY replica_skip_errors = @@GLOBAL.replica_skip_errors;
SET PERSIST_ONLY replica_sql_verify_checksum = @@GLOBAL.replica_sql_verify_checksum;
SET PERSIST_ONLY replica_transaction_retries = @@GLOBAL.replica_transaction_retries;
SET PERSIST_ONLY replica_translate_deprecated_priv = @@GLOBAL.replica_translate_deprecated_priv;
SET PERSIST_ONLY replica_type_conversions = @@GLOBAL.replica_type_conversions;
SET PERSIST_ONLY replication_optimize_for_static_plugin_config = @@GLOBAL.replication_optimize_for_static_plugin_config;
SET PERSIST_ONLY replication_sender_observe_commit_only = @@GLOBAL.replication_sender_observe_commit_only;
Expand Down Expand Up @@ -267,16 +268,16 @@ Warning 1287 '@@sync_relay_log_info' is deprecated and will be removed in a futu
Warning 1287 '@@sync_relay_log_info' is deprecated and will be removed in a future release.
SET PERSIST_ONLY sync_source_info = @@GLOBAL.sync_source_info;

include/assert.inc [Expect 100 persisted variables in persisted_variables table.]
include/assert.inc [Expect 101 persisted variables in persisted_variables table.]

############################################################
# 2. Restart server, it must preserve the persisted variable
# settings. Verify persisted configuration.
# restart

include/assert.inc [Expect 100 persisted variables in persisted_variables table.]
include/assert.inc [Expect 100 persisted variables shown as PERSISTED in variables_info table.]
include/assert.inc [Expect 100 persisted variables with matching persisted and global values.]
include/assert.inc [Expect 101 persisted variables in persisted_variables table.]
include/assert.inc [Expect 101 persisted variables shown as PERSISTED in variables_info table.]
include/assert.inc [Expect 101 persisted variables with matching persisted and global values.]

############################################################
# 3. Test RESET PERSIST. Verify persisted variable settings
Expand Down Expand Up @@ -361,6 +362,7 @@ RESET PERSIST replica_preserve_commit_order;
RESET PERSIST replica_skip_errors;
RESET PERSIST replica_sql_verify_checksum;
RESET PERSIST replica_transaction_retries;
RESET PERSIST replica_translate_deprecated_priv;
RESET PERSIST replica_type_conversions;
RESET PERSIST replication_optimize_for_static_plugin_config;
RESET PERSIST replication_sender_observe_commit_only;
Expand Down
12 changes: 7 additions & 5 deletions mysql-test/suite/binlog_nogtid/r/binlog_persist_variables.result
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ VARIABLE_NAME LIKE '%source%') AND
(VARIABLE_NAME NOT LIKE 'innodb%')
ORDER BY VARIABLE_NAME;

include/assert.inc [Expect 113 variables in the table.]
include/assert.inc [Expect 114 variables in the table.]

# Test SET PERSIST
SET PERSIST binlog_cache_size = @@GLOBAL.binlog_cache_size;
Expand Down Expand Up @@ -145,6 +145,7 @@ SET PERSIST replica_skip_errors = @@GLOBAL.replica_skip_errors;
ERROR HY000: Variable 'replica_skip_errors' is a read only variable
SET PERSIST replica_sql_verify_checksum = @@GLOBAL.replica_sql_verify_checksum;
SET PERSIST replica_transaction_retries = @@GLOBAL.replica_transaction_retries;
SET PERSIST replica_translate_deprecated_priv = @@GLOBAL.replica_translate_deprecated_priv;
SET PERSIST replica_type_conversions = @@GLOBAL.replica_type_conversions;
SET PERSIST replication_optimize_for_static_plugin_config = @@GLOBAL.replication_optimize_for_static_plugin_config;
SET PERSIST replication_sender_observe_commit_only = @@GLOBAL.replication_sender_observe_commit_only;
Expand Down Expand Up @@ -245,16 +246,16 @@ Warning 1287 '@@sync_relay_log_info' is deprecated and will be removed in a futu
Warning 1287 '@@sync_relay_log_info' is deprecated and will be removed in a future release.
SET PERSIST sync_source_info = @@GLOBAL.sync_source_info;

include/assert.inc [Expect 88 persisted variables in persisted_variables table.]
include/assert.inc [Expect 89 persisted variables in persisted_variables table.]

############################################################
# 2. Restart server, it must preserve the persisted variable
# settings. Verify persisted configuration.
# restart

include/assert.inc [Expect 88 persisted variables in persisted_variables table.']
include/assert.inc [Expect 88 persisted variables shown as PERSISTED in variables_info table.']
include/assert.inc [Expect 88 persisted variables with matching persisted and global values.]
include/assert.inc [Expect 89 persisted variables in persisted_variables table.']
include/assert.inc [Expect 89 persisted variables shown as PERSISTED in variables_info table.']
include/assert.inc [Expect 89 persisted variables with matching persisted and global values.]

############################################################
# 3. Test RESET PERSIST IF EXISTS. Verify persisted variable
Expand Down Expand Up @@ -377,6 +378,7 @@ Warnings:
Warning 3615 Variable replica_skip_errors does not exist in persisted config file
RESET PERSIST IF EXISTS replica_sql_verify_checksum;
RESET PERSIST IF EXISTS replica_transaction_retries;
RESET PERSIST IF EXISTS replica_translate_deprecated_priv;
RESET PERSIST IF EXISTS replica_type_conversions;
RESET PERSIST IF EXISTS replication_optimize_for_static_plugin_config;
RESET PERSIST IF EXISTS replication_sender_observe_commit_only;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ INSERT INTO aliases(name) VALUES
# If this count differs, it means a variable has been added or removed.
# In that case, this testcase needs to be updated accordingly.
--echo
--let $expected = 113
--let $expected = 114
--let $assert_text = Expect $expected variables in the table.
--let $assert_cond = [SELECT COUNT(*) as count FROM rplvars, count, 1] = $expected
--source include/assert.inc
Expand Down Expand Up @@ -115,7 +115,7 @@ while ( $varid <= $countvars )
}

--echo
--let $expected = 100
--let $expected = 101
--let $assert_text = Expect $expected persisted variables in persisted_variables table.
--let $assert_cond = [SELECT COUNT(*) as count FROM performance_schema.persisted_variables, count, 1] = $expected
--source include/assert.inc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ INSERT INTO rplvars (varname, varvalue)
# If this count differs, it means a variable has been added or removed.
# In that case, this testcase needs to be updated accordingly.
--echo
--let $expected = 113
--let $expected = 114
--let $assert_text = Expect $expected variables in the table.
--let $assert_cond = [SELECT COUNT(*) as count FROM rplvars, count, 1] = $expected
--source include/assert.inc
Expand All @@ -84,7 +84,7 @@ while ( $varid <= $countvars )
}

--echo
--let $expected = 88
--let $expected = 89
--let $assert_text = Expect $expected persisted variables in persisted_variables table.
--let $assert_cond = [SELECT COUNT(*) as count FROM performance_schema.persisted_variables, count, 1] = $expected
--source include/assert.inc
Expand Down
147 changes: 147 additions & 0 deletions mysql-test/suite/rpl/r/rpl_grant_set_user_id_compat.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
include/rpl/init_source_replica.inc
Warnings:
Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
Note #### Storing MySQL user name or password information in the connection metadata repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START REPLICA; see the 'START REPLICA Syntax' in the MySQL Manual for more information.
[connection master]
#
# Sanity: SET_USER_ID is (re-)registered on the source, but not on
# the replica (this is what makes the test cross-version-like).
#
include/assert_grep.inc ["SET_USER_ID should be defined"]
[connection slave]
include/assert_grep.inc ["SET_USER_ID should not be defined"]
CALL mtr.add_suppression(
"Replica applier rewrote removed dynamic privilege 'SET_USER_ID' into ");
#
# Sanity: the new gate variable exists and defaults to OFF (opt-in).
# Save the current value so we can restore it before deinit.
#
SET @save_translate_deprecated_priv =
@@global.replica_translate_deprecated_priv;
SELECT @@global.replica_translate_deprecated_priv;
@@global.replica_translate_deprecated_priv
0
#
# R5. The grammar/parser is not touched by the fix: a user thread
# executing GRANT SET_USER_ID directly on the replica must still be
# rejected with ER_SYNTAX_ERROR. Verified here while the gate is
# still at its OFF default, on a regular user connection (not the
# SQL applier thread).
#
CREATE USER rpl_psuid@localhost;
GRANT SET_USER_ID ON *.* TO rpl_psuid@localhost;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use
DROP USER rpl_psuid@localhost;
#
# Opt in to the rewrite for the R1..R6 tests below. The gate can
# only be changed while the replication SQL thread is stopped, so
# stop replication, flip it ON, and start again.
#
include/rpl/stop_replica.inc
SET @@global.replica_translate_deprecated_priv = ON;
include/rpl/start_replica.inc
#
# R1, R2. GRANT SET_USER_ID on the source is binlogged as-is; the
# replica rewrites it before applying and ends up with the two
# modern privileges granted.
#
[connection master]
CREATE USER rpl_psuid@localhost;
GRANT SET_USER_ID ON *.* TO rpl_psuid@localhost;
include/rpl/sync_to_replica.inc
[connection slave]
SHOW GRANTS FOR rpl_psuid@localhost;
Grants for rpl_psuid@localhost
GRANT USAGE ON *.* TO `rpl_psuid`@`localhost`
GRANT ALLOW_NONEXISTENT_DEFINER,SET_ANY_DEFINER ON *.* TO `rpl_psuid`@`localhost`
#
# R2 (GRANT OPTION preserved): the WITH GRANT OPTION flag carried by
# the source statement must apply to both translated privileges.
#
[connection master]
GRANT SET_USER_ID ON *.* TO rpl_psuid@localhost WITH GRANT OPTION;
include/rpl/sync_to_replica.inc
[connection slave]
SHOW GRANTS FOR rpl_psuid@localhost;
Grants for rpl_psuid@localhost
GRANT USAGE ON *.* TO `rpl_psuid`@`localhost`
GRANT ALLOW_NONEXISTENT_DEFINER,SET_ANY_DEFINER ON *.* TO `rpl_psuid`@`localhost` WITH GRANT OPTION
#
# R3. REVOKE SET_USER_ID coming from the source revokes both
# SET_ANY_DEFINER and ALLOW_NONEXISTENT_DEFINER on the replica.
#
[connection master]
REVOKE SET_USER_ID ON *.* FROM rpl_psuid@localhost;
include/rpl/sync_to_replica.inc
[connection slave]
SHOW GRANTS FOR rpl_psuid@localhost;
Grants for rpl_psuid@localhost
GRANT USAGE ON *.* TO `rpl_psuid`@`localhost`
#
# R4. A DB literally named "set_user_id" (backtick-quoted) is not a
# GRANT of the SET_USER_ID privilege; the table-level GRANT must
# round-trip unmodified. Use a static privilege (SELECT) to make
# this a regular table-scope GRANT, unaffected by the dynamic
# privilege rewrite.
#
[connection master]
CREATE DATABASE `set_user_id`;
CREATE TABLE `set_user_id`.t (i INT);
GRANT SELECT ON `set_user_id`.* TO rpl_psuid@localhost;
include/rpl/sync_to_replica.inc
[connection slave]
SHOW GRANTS FOR rpl_psuid@localhost;
Grants for rpl_psuid@localhost
GRANT USAGE ON *.* TO `rpl_psuid`@`localhost`
GRANT SELECT ON `set_user_id`.* TO `rpl_psuid`@`localhost`
#
# Cleanup of the ON-mode test artifacts
#
[connection master]
DROP DATABASE `set_user_id`;
DROP USER rpl_psuid@localhost;
include/rpl/sync_to_replica.inc
#
# R7. Turn the gate back OFF. The same kind of statement that just
# round-tripped successfully must now stop the SQL applier with
# ER_SYNTAX_ERROR, proving the rewrite is gated. The gate can only
# be changed while the replication SQL thread is stopped.
#
[connection slave]
include/rpl/stop_replica.inc
SET @@global.replica_translate_deprecated_priv = OFF;
include/rpl/start_replica.inc
CALL mtr.add_suppression(
"Worker .* failed executing transaction");
CALL mtr.add_suppression(
"The replica coordinator and worker threads are stopped");
CALL mtr.add_suppression(
"Replica SQL for channel.*Error 'You have an error in your SQL syntax");
[connection master]
CREATE USER rpl_psuid_off@localhost;
GRANT SET_USER_ID ON *.* TO rpl_psuid_off@localhost;
[connection slave]
include/rpl/wait_for_applier_error.inc [errno=1149]
#
# Recover: the CREATE USER ran successfully on the replica (it
# preceded the failing GRANT in the relay log), so the user is
# still there even after the SQL thread stopped. Stop replication,
# drop the user on both sides, wipe the source's binlog so the
# replica is not asked to re-apply the same failing event, then
# restart replication.
#
include/rpl/stop_replica.inc
RESET REPLICA;
DROP USER rpl_psuid_off@localhost;
[connection master]
DROP USER rpl_psuid_off@localhost;
RESET BINARY LOGS AND GTIDS;
#
# Restore the gate to its saved (default) value while the SQL thread
# is still stopped, then resume replication.
#
[connection slave]
SET @@global.replica_translate_deprecated_priv =
@save_translate_deprecated_priv;
include/rpl/start_replica.inc
include/rpl/deinit.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--loose-debug=+d,register_legacy_set_user_id_priv
Loading