From 6080ef0f1739d59e963edf9169cb7ca7b44d8b9c Mon Sep 17 00:00:00 2001 From: Brandon Nesterenko Date: Tue, 26 Apr 2022 19:51:42 -0600 Subject: MDEV-28294: set default role bypasses Replicate_Wild_Ignore_Table: mysql.% Problem: ======== When replicating SET DEFAULT ROLE, the pre-update check (i.e. that in set_var_default_role::check()) tries to validate the existence of the given rules/user even when the targeted tables are ignored. When previously issued CREATE USER/ROLE commands are ignored by the replica because of the replication filtering rules, this results in an error because the targeted data does not exist. Solution: ======== Before checking that the given rules/user exist of a SET DEFAULT ROLE command, first ensure that the mysql.user and mysql.roles_mapping tables are not excluded by replication filters. Reviewed By ============ Andrei Elkin --- sql/sql_parse.cc | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'sql/sql_parse.cc') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 6a1b849b912..2b718972fc6 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -3661,6 +3661,39 @@ mysql_execute_command(THD *thd) MYF(0)); DBUG_RETURN(0); } + + /* + Check if the SET command will modify a table that should be ignored in + replication. + */ + if (lex->sql_command == SQLCOM_SET_OPTION) + { + List *lex_var_list= &lex->var_list; + List_iterator_fast it(*lex_var_list); + set_var_base *set_var; + while ((set_var=it++)) + { + TABLE_LIST *tables; + set_var->get_modified_tables(&tables); + if (tables && all_tables_not_ok(thd, tables)) + { + /* + Used in MTR to prove that the event was ignored _here_ + */ + DBUG_EXECUTE_IF( + "sync_set_var_rpl_filtered", + DBUG_ASSERT(!debug_sync_set_action( + thd, STRING_WITH_LEN("now SIGNAL ignoring_event WAIT_FOR " + "ack_event_ignored")));); + /* warn the slave SQL thread */ + my_message(ER_SLAVE_IGNORED_TABLE, + ER_THD(thd, ER_SLAVE_IGNORED_TABLE), MYF(0)); + DBUG_RETURN(0); + } + } + } + + /* Execute deferred events first */ -- cgit v1.2.1