diff -Naur /root/mysql-8.0.32/sql/mysqld.cc sql/mysqld.cc --- /root/mysql-8.0.32/sql/mysqld.cc 2022-12-16 23:34:44.000000000 +0800 +++ sql/mysqld.cc 2023-02-24 16:24:39.266503970 +0800 @@ -1201,6 +1201,7 @@ ulong log_error_verbosity = 3; // have a non-zero value during early start-up bool opt_keyring_migration_to_component = false; bool opt_persist_sensitive_variables_in_plaintext{true}; +char *opt_prohibit_sqlstr = nullptr; #if defined(_WIN32) /* diff -Naur /root/mysql-8.0.32/sql/mysqld.h sql/mysqld.h --- /root/mysql-8.0.32/sql/mysqld.h 2022-12-16 23:34:44.000000000 +0800 +++ sql/mysqld.h 2023-02-24 16:25:35.235801113 +0800 @@ -195,6 +195,7 @@ #endif // _WIN32 extern bool opt_debugging; extern bool opt_validate_config; +extern char *opt_prohibit_sqlstr; enum enum_replica_type_conversions { REPLICA_TYPE_CONVERSIONS_ALL_LOSSY, diff -Naur /root/mysql-8.0.32/sql/sql_parse.cc sql/sql_parse.cc --- /root/mysql-8.0.32/sql/sql_parse.cc 2022-12-16 23:34:44.000000000 +0800 +++ sql/sql_parse.cc 2023-02-24 16:14:13.847009353 +0800 @@ -36,6 +36,7 @@ #include #include #include +#include #include "my_config.h" #ifdef HAVE_LSAN_DO_RECOVERABLE_LEAK_CHECK @@ -5198,6 +5199,15 @@ DBUG_EXECUTE_IF("parser_debug", turn_parser_debug_on();); + std::string str_prohibit=opt_prohibit_sqlstr; + std::string prohibit_sql= thd->query().str; + bool ret = std::regex_match(prohibit_sql,str_prohibit); + if (ret ) + { + DBUG_PRINT("find prohibit sqlist",("query: '%s'", thd->query().str)); + return ; + } + mysql_reset_thd_for_next_command(thd); // It is possible that rewritten query may not be empty (in case of // multiqueries). So reset it. diff -Naur /root/mysql-8.0.32/sql/sys_vars.cc sql/sys_vars.cc --- /root/mysql-8.0.32/sql/sys_vars.cc 2022-12-16 23:34:44.000000000 +0800 +++ sql/sys_vars.cc 2023-02-24 16:23:25.797801280 +0800 @@ -3595,6 +3595,13 @@ VALID_RANGE(IO_SIZE * 2, INT_MAX32), DEFAULT(128 * 1024), BLOCK_SIZE(IO_SIZE)); +static Sys_var_charptr Sys_prohibit_sqlstr( + "prohibit_sqlstr", + "the prohibit list sqlstr ", + READ_ONLY GLOBAL_VAR(opt_prohibit_sqlstr), CMD_LINE(REQUIRED_ARG), + IN_FS_CHARSET, DEFAULT("(.*)")); + + static bool check_read_only(sys_var *, THD *thd, set_var *) { /* Prevent self dead-lock */ if (thd->locked_tables_mode || thd->in_active_multi_stmt_transaction()) {