From eb8dc23dad7a89f5311e50470ccdb474523ca9a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Tue, 11 May 2021 01:55:57 +0200 Subject: [PATCH 1/6] Code cleanup for MySQL variables --- include/MySQL_Thread.h | 8 + lib/MySQL_Thread.cpp | 465 ++++++++--------------------------------- 2 files changed, 97 insertions(+), 376 deletions(-) diff --git a/include/MySQL_Thread.h b/include/MySQL_Thread.h index d158497e3..27e285b71 100644 --- a/include/MySQL_Thread.h +++ b/include/MySQL_Thread.h @@ -361,6 +361,14 @@ class MySQL_Threads_Handler pthread_rwlock_t rwlock; PtrArray *bind_fds; MySQL_Listeners_Manager *MLM; + // VariablesPointers_int stores: + // key: variable name + // tuple: + // variable address + // min value + // max value + // special variable : if true, min and max values are ignored, and further input validation is required + std::unordered_map> VariablesPointers_int; public: struct { int monitor_history; diff --git a/lib/MySQL_Thread.cpp b/lib/MySQL_Thread.cpp index 4bb97ef23..c9d1c5a45 100644 --- a/lib/MySQL_Thread.cpp +++ b/lib/MySQL_Thread.cpp @@ -1365,45 +1365,38 @@ unsigned int MySQL_Threads_Handler::get_variable_uint(char *name) { } int MySQL_Threads_Handler::get_variable_int(const char *name) { + + if (!strcasecmp(name,"max_transaction_idle_time")) { + PROXY_TRACE(); + } + // convert name to string, and lowercase + std::string nameS = string(name); + std::transform(nameS.begin(), nameS.end(), nameS.begin(), [](unsigned char c){ return std::tolower(c); }); + { + std::unordered_map>::const_iterator it = VariablesPointers_int.find(nameS); + if (it != VariablesPointers_int.end()) { + int * v = std::get<0>(it->second); + return *v; + } + } + + //VALGRIND_DISABLE_ERROR_REPORTING; if (name[0]=='m' && (strncmp(name,"monitor_",8)==0)) { char a = name[8]; - if (a == 'r') { - if (!strcmp(name,"monitor_read_only_interval")) return (int)variables.monitor_read_only_interval; - if (!strcmp(name,"monitor_read_only_timeout")) return (int)variables.monitor_read_only_timeout; - if (!strcmp(name,"monitor_read_only_max_timeout_count")) return (int)variables.monitor_read_only_max_timeout_count; - if (!strcmp(name,"monitor_replication_lag_interval")) return (int)variables.monitor_replication_lag_interval; - if (!strcmp(name,"monitor_replication_lag_timeout")) return (int)variables.monitor_replication_lag_timeout; - if (!strcmp(name,"monitor_replication_lag_count")) return (int)variables.monitor_replication_lag_count; - } if (a == 'g') { char b = name[9]; - if (b == 'r') { - if (!strcmp(name,"monitor_groupreplication_healthcheck_interval")) return (int)variables.monitor_groupreplication_healthcheck_interval; - if (!strcmp(name,"monitor_groupreplication_healthcheck_timeout")) return (int)variables.monitor_groupreplication_healthcheck_timeout; - if (!strcmp(name,"monitor_groupreplication_healthcheck_max_timeout_count")) return (int)variables.monitor_groupreplication_healthcheck_max_timeout_count; - if (!strcmp(name,"monitor_groupreplication_max_transactions_behind_count")) return (int)variables.monitor_groupreplication_max_transactions_behind_count; - } if (b == 'a') { if (!strcmp(name,"monitor_galera_healthcheck_interval")) return (int)variables.monitor_galera_healthcheck_interval; if (!strcmp(name,"monitor_galera_healthcheck_timeout")) return (int)variables.monitor_galera_healthcheck_timeout; if (!strcmp(name,"monitor_galera_healthcheck_max_timeout_count")) return (int)variables.monitor_galera_healthcheck_max_timeout_count; } } - if (a == 'p') { - if (!strcmp(name,"monitor_ping_interval")) return (int)variables.monitor_ping_interval; - if (!strcmp(name,"monitor_ping_max_failures")) return (int)variables.monitor_ping_max_failures; - if (!strcmp(name,"monitor_ping_timeout")) return (int)variables.monitor_ping_timeout; - } if (a == 't') { if (!strcmp(name,"monitor_threads_min")) return (int)variables.monitor_threads_min; if (!strcmp(name,"monitor_threads_max")) return (int)variables.monitor_threads_max; if (!strcmp(name,"monitor_threads_queue_maxsize")) return (int)variables.monitor_threads_queue_maxsize; } - if (a == 'c') { - if (!strcmp(name,"monitor_connect_interval")) return (int)variables.monitor_connect_interval; - if (!strcmp(name,"monitor_connect_timeout")) return (int)variables.monitor_connect_timeout; - } if (a == 'q') { if (!strcmp(name,"monitor_query_interval")) return (int)variables.monitor_query_interval; if (!strcmp(name,"monitor_query_timeout")) return (int)variables.monitor_query_timeout; @@ -1415,9 +1408,6 @@ int MySQL_Threads_Handler::get_variable_int(const char *name) { if (a == 'e') { if (!strcmp(name,"monitor_enabled")) return (int)variables.monitor_enabled; } - if (a == 'h') { - if (!strcmp(name,"monitor_history")) return (int)variables.monitor_history; - } if (a == 's') { if (!strcmp(name,"monitor_slave_lag_when_null")) return (int)variables.monitor_slave_lag_when_null; } @@ -1475,7 +1465,6 @@ int MySQL_Threads_Handler::get_variable_int(const char *name) { case 'h': if (!strcmp(name,"have_compress")) return (int)variables.have_compress; if (!strcmp(name,"have_ssl")) return (int)variables.have_ssl; - if (!strcmp(name,"hostgroup_manager_verbose")) return (int)variables.hostgroup_manager_verbose; break; case 'k': if (!strcmp(name,"kill_backend_connection_when_disconnect")) return (int)variables.kill_backend_connection_when_disconnect; @@ -1487,12 +1476,9 @@ int MySQL_Threads_Handler::get_variable_int(const char *name) { break; case 'm': if (name[3]=='_') { - if (!strcmp(name,"max_allowed_packet")) return (int)variables.max_allowed_packet; if (!strcmp(name,"max_connections")) return (int)variables.max_connections; if (!strcmp(name,"max_stmts_cache")) return (int)variables.max_stmts_cache; if (!strcmp(name,"max_stmts_per_connection")) return (int)variables.max_stmts_per_connection; - if (!strcmp(name,"max_transaction_idle_time")) return (int)variables.max_transaction_idle_time; - if (!strcmp(name,"max_transaction_time")) return (int)variables.max_transaction_time; if (!strcmp(name,"min_num_servers_lantency_awareness")) return (int)variables.min_num_servers_lantency_awareness; } if (!strcmp(name,"mirror_max_concurrency")) return (int)variables.mirror_max_concurrency; @@ -1513,13 +1499,10 @@ int MySQL_Threads_Handler::get_variable_int(const char *name) { if (name[6]=='d') { if (!strcmp(name,"query_digests")) return (int)variables.query_digests; if (!strcmp(name,"query_digests_lowercase")) return (int)variables.query_digests_lowercase; - if (!strcmp(name,"query_digests_max_digest_length")) return (int)variables.query_digests_max_digest_length; - if (!strcmp(name,"query_digests_max_query_length")) return (int)variables.query_digests_max_query_length; if (!strcmp(name,"query_digests_no_digits")) return (int)variables.query_digests_no_digits; if (!strcmp(name,"query_digests_normalize_digest_text")) return (int)variables.query_digests_normalize_digest_text; if (!strcmp(name,"query_digests_replace_null")) return (int)variables.query_digests_replace_null; if (!strcmp(name,"query_digests_track_hostname")) return (int)variables.query_digests_track_hostname; - if (!strcmp(name,"query_digests_grouping_limit")) return (int)variables.query_digests_grouping_limit; } if (name[6]=='p') { if (!strcmp(name,"query_processor_iterations")) return (int)variables.query_processor_iterations; @@ -1556,14 +1539,9 @@ int MySQL_Threads_Handler::get_variable_int(const char *name) { break; case 't': if (name[8] == '_') { - if (!strcmp(name,"throttle_connections_per_sec_to_hostgroup")) return (int)variables.throttle_connections_per_sec_to_hostgroup; if (!strcmp(name,"throttle_max_bytes_per_second_to_client")) return (int)variables.throttle_max_bytes_per_second_to_client; if (!strcmp(name,"throttle_ratio_server_to_client")) return (int)variables.throttle_ratio_server_to_client; } - if (name[9] == '_') { - if (!strcmp(name,"threshold_query_length")) return (int)variables.threshold_query_length; - if (!strcmp(name,"threshold_resultset_size")) return (int)variables.threshold_resultset_size; - } if (!strcmp(name,"tcp_keepalive_time")) return (int)variables.tcp_keepalive_time; break; case 'u': @@ -1587,6 +1565,20 @@ char * MySQL_Threads_Handler::get_variable(char *name) { // this is the public f //VALGRIND_DISABLE_ERROR_REPORTING; #define INTBUFSIZE 4096 char intbuf[INTBUFSIZE]; + + // convert name to string, and lowercase + std::string nameS = string(name); + std::transform(nameS.begin(), nameS.end(), nameS.begin(), [](unsigned char c){ return std::tolower(c); }); + { + std::unordered_map>::const_iterator it = VariablesPointers_int.find(nameS); + if (it != VariablesPointers_int.end()) { + int * v = std::get<0>(it->second); + sprintf(intbuf,"%d", *v); + return strdup(intbuf); + } + } + + if (!strcasecmp(name,"firewall_whitelist_errormsg")) { if (variables.firewall_whitelist_errormsg==NULL || strlen(variables.firewall_whitelist_errormsg)==0) { return NULL; @@ -1692,70 +1684,6 @@ char * MySQL_Threads_Handler::get_variable(char *name) { // this is the public f if (!strcasecmp(name,"monitor_enabled")) { return strdup((variables.monitor_enabled ? "true" : "false")); } - if (!strcasecmp(name,"monitor_history")) { - sprintf(intbuf,"%d",variables.monitor_history); - return strdup(intbuf); - } - if (!strcasecmp(name,"monitor_connect_interval")) { - sprintf(intbuf,"%d",variables.monitor_connect_interval); - return strdup(intbuf); - } - if (!strcasecmp(name,"monitor_connect_timeout")) { - sprintf(intbuf,"%d",variables.monitor_connect_timeout); - return strdup(intbuf); - } - if (!strcasecmp(name,"monitor_ping_interval")) { - sprintf(intbuf,"%d",variables.monitor_ping_interval); - return strdup(intbuf); - } - if (!strcasecmp(name,"monitor_ping_max_failures")) { - sprintf(intbuf,"%d",variables.monitor_ping_max_failures); - return strdup(intbuf); - } - if (!strcasecmp(name,"monitor_ping_timeout")) { - sprintf(intbuf,"%d",variables.monitor_ping_timeout); - return strdup(intbuf); - } - if (!strcasecmp(name,"monitor_read_only_interval")) { - sprintf(intbuf,"%d",variables.monitor_read_only_interval); - return strdup(intbuf); - } - if (!strcasecmp(name,"monitor_read_only_timeout")) { - sprintf(intbuf,"%d",variables.monitor_read_only_timeout); - return strdup(intbuf); - } - if (!strcasecmp(name,"monitor_read_only_max_timeout_count")) { - sprintf(intbuf,"%d",variables.monitor_read_only_max_timeout_count); - return strdup(intbuf); - } - if (!strcasecmp(name,"monitor_replication_lag_interval")) { - sprintf(intbuf,"%d",variables.monitor_replication_lag_interval); - return strdup(intbuf); - } - if (!strcasecmp(name,"monitor_replication_lag_timeout")) { - sprintf(intbuf,"%d",variables.monitor_replication_lag_timeout); - return strdup(intbuf); - } - if (!strcasecmp(name,"monitor_replication_lag_count")) { - sprintf(intbuf,"%d",variables.monitor_replication_lag_count); - return strdup(intbuf); - } - if (!strcasecmp(name,"monitor_groupreplication_healthcheck_interval")) { - sprintf(intbuf,"%d",variables.monitor_groupreplication_healthcheck_interval); - return strdup(intbuf); - } - if (!strcasecmp(name,"monitor_groupreplication_healthcheck_timeout")) { - sprintf(intbuf,"%d",variables.monitor_groupreplication_healthcheck_timeout); - return strdup(intbuf); - } - if (!strcasecmp(name,"monitor_groupreplication_healthcheck_max_timeout_count")) { - sprintf(intbuf,"%d",variables.monitor_groupreplication_healthcheck_max_timeout_count); - return strdup(intbuf); - } - if (!strcasecmp(name,"monitor_groupreplication_max_transactions_behind_count")) { - sprintf(intbuf,"%d",variables.monitor_groupreplication_max_transactions_behind_count); - return strdup(intbuf); - } if (!strcasecmp(name,"monitor_galera_healthcheck_interval")) { sprintf(intbuf,"%d",variables.monitor_galera_healthcheck_interval); return strdup(intbuf); @@ -1876,10 +1804,6 @@ char * MySQL_Threads_Handler::get_variable(char *name) { // this is the public f sprintf(intbuf,"%d",variables.auditlog_filesize); return strdup(intbuf); } - if (!strcasecmp(name,"max_allowed_packet")) { - sprintf(intbuf,"%d",variables.max_allowed_packet); - return strdup(intbuf); - } if (!strcasecmp(name,"tcp_keepalive_time")) { sprintf(intbuf,"%d",variables.tcp_keepalive_time); return strdup(intbuf); @@ -1905,46 +1829,10 @@ char * MySQL_Threads_Handler::get_variable(char *name) { // this is the public f if (!strcasecmp(name,"log_mysql_warnings_enabled")) { return strdup((variables.log_mysql_warnings_enabled? "true" : "false")); } - if (!strcasecmp(name,"throttle_connections_per_sec_to_hostgroup")) { - sprintf(intbuf,"%d",variables.throttle_connections_per_sec_to_hostgroup); - return strdup(intbuf); - } - if (!strcasecmp(name,"max_transaction_idle_time")) { - sprintf(intbuf,"%d",variables.max_transaction_idle_time); - return strdup(intbuf); - } - if (!strcasecmp(name,"max_transaction_time")) { - sprintf(intbuf,"%d",variables.max_transaction_time); - return strdup(intbuf); - } - if (!strcasecmp(name,"hostgroup_manager_verbose")) { - sprintf(intbuf,"%d",variables.hostgroup_manager_verbose); - return strdup(intbuf); - } if (!strcasecmp(name,"binlog_reader_connect_retry_msec")) { sprintf(intbuf,"%d",variables.binlog_reader_connect_retry_msec); return strdup(intbuf); } - if (!strcasecmp(name,"threshold_query_length")) { - sprintf(intbuf,"%d",variables.threshold_query_length); - return strdup(intbuf); - } - if (!strcasecmp(name,"threshold_resultset_size")) { - sprintf(intbuf,"%d",variables.threshold_resultset_size); - return strdup(intbuf); - } - if (!strcasecmp(name,"query_digests_max_digest_length")) { - sprintf(intbuf,"%d",variables.query_digests_max_digest_length); - return strdup(intbuf); - } - if (!strcasecmp(name,"query_digests_max_query_length")) { - sprintf(intbuf,"%d",variables.query_digests_max_query_length); - return strdup(intbuf); - } - if (!strcasecmp(name,"query_digests_grouping_limit")) { - sprintf(intbuf,"%d",variables.query_digests_grouping_limit); - return strdup(intbuf); - } if (!strcasecmp(name,"wait_timeout")) { sprintf(intbuf,"%d",variables.wait_timeout); return strdup(intbuf); @@ -2156,6 +2044,28 @@ bool MySQL_Threads_Handler::set_variable(char *name, const char *value) { // thi if (!value) return false; size_t vallen=strlen(value); + + // convert name to string, and lowercase + std::string nameS = string(name); + std::transform(nameS.begin(), nameS.end(), nameS.begin(), [](unsigned char c){ return std::tolower(c); }); + { + std::unordered_map>::const_iterator it = VariablesPointers_int.find(nameS); + if (it != VariablesPointers_int.end()) { + bool special_variable = std::get<3>(it->second); // if special_variable is true, min and max values are ignored, and more input validation is needed + if (special_variable == false) { + int intv=atoi(value); + if (intv >= std::get<1>(it->second) && intv <= std::get<2>(it->second)) { + int * v = std::get<0>(it->second); + *v = intv; + return true; + } + return false; + } else { + // we need to perform input validation + } + } + } + // monitor variables if (!strncasecmp(name,"monitor_",8)) { if (!strcasecmp(name,"monitor_username")) { @@ -2207,150 +2117,6 @@ bool MySQL_Threads_Handler::set_variable(char *name, const char *value) { // thi } return false; } - if (!strcasecmp(name,"monitor_history")) { - int intv=atoi(value); - if (intv >= 1000 && intv <= 7*24*3600*1000) { - variables.monitor_history=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"monitor_connect_interval")) { - int intv=atoi(value); - if (intv >= 100 && intv <= 7*24*3600*1000) { - variables.monitor_connect_interval=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"monitor_connect_timeout")) { - int intv=atoi(value); - if (intv >= 100 && intv <= 600*1000) { - variables.monitor_connect_timeout=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"monitor_ping_interval")) { - int intv=atoi(value); - if (intv >= 100 && intv <= 7*24*3600*1000) { - variables.monitor_ping_interval=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"monitor_ping_max_failures")) { - int intv=atoi(value); - if (intv >= 1 && intv <= 1000*1000) { - variables.monitor_ping_max_failures=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"monitor_ping_timeout")) { - int intv=atoi(value); - if (intv >= 100 && intv <= 600*1000) { - variables.monitor_ping_timeout=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"monitor_read_only_interval")) { - int intv=atoi(value); - if (intv >= 100 && intv <= 7*24*3600*1000) { - variables.monitor_read_only_interval=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"monitor_read_only_timeout")) { - int intv=atoi(value); - if (intv >= 100 && intv <= 600*1000) { - variables.monitor_read_only_timeout=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"monitor_read_only_max_timeout_count")) { - int intv=atoi(value); - if (intv >= 1 && intv <= 1000*1000) { - variables.monitor_read_only_max_timeout_count=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"monitor_replication_lag_interval")) { - int intv=atoi(value); - if (intv >= 100 && intv <= 7*24*3600*1000) { - variables.monitor_replication_lag_interval=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"monitor_replication_lag_timeout")) { - int intv=atoi(value); - if (intv >= 100 && intv <= 600*1000) { - variables.monitor_replication_lag_timeout=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"monitor_replication_lag_count")) { - int intv=atoi(value); - if (intv >= 1 && intv <= 10) { - variables.monitor_replication_lag_count=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"monitor_groupreplication_healthcheck_interval")) { - int intv=atoi(value); - if (intv >= 50 && intv <= 7*24*3600*1000) { - variables.monitor_groupreplication_healthcheck_interval=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"monitor_groupreplication_healthcheck_timeout")) { - int intv=atoi(value); - if (intv >= 50 && intv <= 600*1000) { - variables.monitor_groupreplication_healthcheck_timeout=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"monitor_groupreplication_healthcheck_max_timeout_count")) { - int intv=atoi(value); - if (intv >= 1 && intv <= 10) { - variables.monitor_groupreplication_healthcheck_max_timeout_count=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"monitor_groupreplication_max_transactions_behind_count")) { - int intv=atoi(value); - if (intv >= 1 && intv <= 10) { - variables.monitor_groupreplication_max_transactions_behind_count=intv; - return true; - } else { - return false; - } - } if (!strcasecmp(name,"monitor_galera_healthcheck_interval")) { int intv=atoi(value); if (intv >= 50 && intv <= 7*24*3600*1000) { @@ -2455,51 +2221,6 @@ bool MySQL_Threads_Handler::set_variable(char *name, const char *value) { // thi return false; } } - if (!strcasecmp(name,"max_allowed_packet")) { - int intv=atoi(value); - if (intv >= 8192 && intv <= 1024*1024*1024) { - variables.max_allowed_packet=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"max_transaction_idle_time")) { - int intv=atoi(value); - if (intv >= 1000 && intv <= 20*24*3600*1000) { - variables.max_transaction_idle_time=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"max_transaction_time")) { - int intv=atoi(value); - if (intv >= 1000 && intv <= 20*24*3600*1000) { - variables.max_transaction_time=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"throttle_connections_per_sec_to_hostgroup")) { - int intv=atoi(value); - if (intv >= 1 && intv <= 100*1000*1000) { - variables.throttle_connections_per_sec_to_hostgroup=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"hostgroup_manager_verbose")) { - int intv=atoi(value); - if (intv >= 0 && intv <= 2) { - variables.hostgroup_manager_verbose=intv; - return true; - } else { - return false; - } - } if (!strcasecmp(name,"binlog_reader_connect_retry_msec")) { int intv=atoi(value); if (intv >= 200 && intv <= 120000) { @@ -2509,51 +2230,6 @@ bool MySQL_Threads_Handler::set_variable(char *name, const char *value) { // thi return false; } } - if (!strcasecmp(name,"threshold_query_length")) { - int intv=atoi(value); - if (intv >= 1024 && intv <= 1*1024*1024*1024) { - variables.threshold_query_length=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"threshold_resultset_size")) { - int intv=atoi(value); - if (intv >= 1024 && intv <= 1*1024*1024*1024) { - variables.threshold_resultset_size=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"query_digests_max_digest_length")) { - int intv=atoi(value); - if (intv >= 16 && intv <= 1*1024*1024) { - variables.query_digests_max_digest_length=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"query_digests_max_query_length")) { - int intv=atoi(value); - if (intv >= 16 && intv <= 16*1024*1024) { - variables.query_digests_max_query_length=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"query_digests_grouping_limit")) { - int intv=atoi(value); - if (intv >= 1 && intv <= 2089) { - variables.query_digests_grouping_limit=intv; - return true; - } else { - return false; - } - } if (!strcasecmp(name,"wait_timeout")) { int intv=atoi(value); if (intv >= 0 && intv <= 20*24*3600*1000) { @@ -3612,6 +3288,43 @@ bool MySQL_Threads_Handler::set_variable(char *name, const char *value) { // thi // return variables from both mysql_thread_variables_names AND mysql_tracked_variables char ** MySQL_Threads_Handler::get_variables_list() { + + + // initialize VariablesPointers_int + // it is safe to do it here because get_variables_list() is the first function called during start time + if (VariablesPointers_int.size() == 0) { + VariablesPointers_int["max_allowed_packet"] = make_tuple(&variables.max_allowed_packet, 8192, 1024*1024*1024, false); + VariablesPointers_int["max_transaction_idle_time"] = make_tuple(&variables.max_transaction_idle_time, 1000, 20*24*3600*1000, false); + VariablesPointers_int["max_transaction_time"] = make_tuple(&variables.max_transaction_time, 1000, 20*24*3600*1000, false); + VariablesPointers_int["throttle_connections_per_sec_to_hostgroup"] = make_tuple(&variables.throttle_connections_per_sec_to_hostgroup, 1, 100*1000*1000, false); + VariablesPointers_int["hostgroup_manager_verbose"] = make_tuple(&variables.hostgroup_manager_verbose, 1, 2, false); + VariablesPointers_int["threshold_query_length"] = make_tuple(&variables.threshold_query_length, 1024, 1*1024*1024*1024, false); + VariablesPointers_int["threshold_resultset_size"] = make_tuple(&variables.threshold_resultset_size, 1024, 1*1024*1024*1024, false); + VariablesPointers_int["query_digests_max_digest_length"] = make_tuple(&variables.query_digests_max_digest_length, 16, 1*1024*1024, false); + VariablesPointers_int["query_digests_max_query_length"] = make_tuple(&variables.query_digests_max_query_length, 16, 1*1024*1024, false); + VariablesPointers_int["query_digests_grouping_limit"] = make_tuple(&variables.query_digests_grouping_limit, 1, 2089, false); + + + VariablesPointers_int["monitor_history"] = make_tuple(&variables.monitor_history, 1000, 7*24*3600*1000, false); + VariablesPointers_int["monitor_connect_interval"] = make_tuple(&variables.monitor_connect_interval, 100, 7*24*3600*1000, false); + VariablesPointers_int["monitor_connect_timeout"] = make_tuple(&variables.monitor_connect_timeout, 100, 600*1000, false); + VariablesPointers_int["monitor_ping_interval"] = make_tuple(&variables.monitor_ping_interval, 100, 7*24*3600*1000, false); + VariablesPointers_int["monitor_ping_timeout"] = make_tuple(&variables.monitor_ping_timeout, 100, 600*1000, false); + VariablesPointers_int["monitor_ping_max_failures"] = make_tuple(&variables.monitor_ping_max_failures, 1, 1000*1000, false); + VariablesPointers_int["monitor_read_only_interval"] = make_tuple(&variables.monitor_read_only_interval, 100, 7*24*3600*1000, false); + VariablesPointers_int["monitor_read_only_timeout"] = make_tuple(&variables.monitor_read_only_timeout, 100, 600*1000, false); + VariablesPointers_int["monitor_read_only_max_timeout_count"] = make_tuple(&variables.monitor_read_only_max_timeout_count, 1, 1000*1000, false); + VariablesPointers_int["monitor_replication_lag_interval"] = make_tuple(&variables.monitor_replication_lag_interval, 100, 7*24*3600*1000, false); + VariablesPointers_int["monitor_replication_lag_timeout"] = make_tuple(&variables.monitor_replication_lag_timeout, 100, 600*1000, false); + VariablesPointers_int["monitor_replication_lag_count"] = make_tuple(&variables.monitor_replication_lag_count , 1, 10, false); + + VariablesPointers_int["monitor_groupreplication_healthcheck_interval"] = make_tuple(&variables.monitor_groupreplication_healthcheck_interval, 100, 7*24*3600*1000, false); + VariablesPointers_int["monitor_groupreplication_healthcheck_timeout"] = make_tuple(&variables.monitor_groupreplication_healthcheck_timeout, 100, 600*1000, false); + VariablesPointers_int["monitor_groupreplication_healthcheck_max_timeout_count"] = make_tuple(&variables.monitor_groupreplication_healthcheck_max_timeout_count, 1, 10, false); + VariablesPointers_int["monitor_groupreplication_max_transactions_behind_count"] = make_tuple(&variables.monitor_groupreplication_max_transactions_behind_count, 1, 10, false); + } + + const size_t l=sizeof(mysql_thread_variables_names)/sizeof(char *); unsigned int i; size_t ltv = 0; From 9e3d939ed3cc028542f5e8cebbca720a7eae3203 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Tue, 11 May 2021 18:15:39 +0200 Subject: [PATCH 2/6] More code cleanup for MySQL variables --- include/MySQL_Thread.h | 6 + lib/MySQL_Thread.cpp | 1397 ++++++---------------------------------- 2 files changed, 202 insertions(+), 1201 deletions(-) diff --git a/include/MySQL_Thread.h b/include/MySQL_Thread.h index 27e285b71..4d56c70cd 100644 --- a/include/MySQL_Thread.h +++ b/include/MySQL_Thread.h @@ -369,6 +369,12 @@ class MySQL_Threads_Handler // max value // special variable : if true, min and max values are ignored, and further input validation is required std::unordered_map> VariablesPointers_int; + // VariablesPointers_bool stores: + // key: variable name + // tuple: + // variable address + // special variable : if true, further input validation is required + std::unordered_map> VariablesPointers_bool; public: struct { int monitor_history; diff --git a/lib/MySQL_Thread.cpp b/lib/MySQL_Thread.cpp index c9d1c5a45..2864d52a4 100644 --- a/lib/MySQL_Thread.cpp +++ b/lib/MySQL_Thread.cpp @@ -1373,146 +1373,54 @@ int MySQL_Threads_Handler::get_variable_int(const char *name) { std::string nameS = string(name); std::transform(nameS.begin(), nameS.end(), nameS.begin(), [](unsigned char c){ return std::tolower(c); }); { + // integer variable std::unordered_map>::const_iterator it = VariablesPointers_int.find(nameS); if (it != VariablesPointers_int.end()) { int * v = std::get<0>(it->second); return *v; } } + { + // bool variable + std::unordered_map>::const_iterator it = VariablesPointers_bool.find(nameS); + if (it != VariablesPointers_bool.end()) { + bool * v = std::get<0>(it->second); + int a = (int)*v; + return a; + } + } //VALGRIND_DISABLE_ERROR_REPORTING; - if (name[0]=='m' && (strncmp(name,"monitor_",8)==0)) { - char a = name[8]; - if (a == 'g') { - char b = name[9]; - if (b == 'a') { - if (!strcmp(name,"monitor_galera_healthcheck_interval")) return (int)variables.monitor_galera_healthcheck_interval; - if (!strcmp(name,"monitor_galera_healthcheck_timeout")) return (int)variables.monitor_galera_healthcheck_timeout; - if (!strcmp(name,"monitor_galera_healthcheck_max_timeout_count")) return (int)variables.monitor_galera_healthcheck_max_timeout_count; - } - } - if (a == 't') { - if (!strcmp(name,"monitor_threads_min")) return (int)variables.monitor_threads_min; - if (!strcmp(name,"monitor_threads_max")) return (int)variables.monitor_threads_max; - if (!strcmp(name,"monitor_threads_queue_maxsize")) return (int)variables.monitor_threads_queue_maxsize; - } - if (a == 'q') { - if (!strcmp(name,"monitor_query_interval")) return (int)variables.monitor_query_interval; - if (!strcmp(name,"monitor_query_timeout")) return (int)variables.monitor_query_timeout; - } - if (a == 'w') { - if (!strcmp(name,"monitor_wait_timeout")) return (int)variables.monitor_wait_timeout; - if (!strcmp(name,"monitor_writer_is_also_reader")) return (int)variables.monitor_writer_is_also_reader; - } - if (a == 'e') { - if (!strcmp(name,"monitor_enabled")) return (int)variables.monitor_enabled; - } - if (a == 's') { - if (!strcmp(name,"monitor_slave_lag_when_null")) return (int)variables.monitor_slave_lag_when_null; - } - } char a = name[0]; switch (a) { case 'a': - if (!strcmp(name,"auditlog_filesize")) return (int)variables.auditlog_filesize; if (!strcmp(name,"aurora_max_lag_ms_only_read_from_replicas")) return variables.aurora_max_lag_ms_only_read_from_replicas; - if (!strcmp(name,"auto_increment_delay_multiplex")) return (int)variables.auto_increment_delay_multiplex; - if (!strcmp(name,"autocommit_false_is_transaction")) return (int)variables.autocommit_false_is_transaction; - if (!strcmp(name,"autocommit_false_not_reusable")) return (int)variables.autocommit_false_not_reusable; - if (!strcmp(name,"automatic_detect_sqli")) return (int)variables.automatic_detect_sqli; break; case 'b': if (!strcmp(name,"binlog_reader_connect_retry_msec")) return (int)variables.binlog_reader_connect_retry_msec; break; case 'c': - if (name[1]=='l') { - if (!strcmp(name,"client_found_rows")) return (int)variables.client_found_rows; - if (!strcmp(name,"client_multi_statements")) return (int)variables.client_multi_statements; - if (!strcmp(name,"client_session_track_gtid")) return (int)variables.client_session_track_gtid; - } if (name[1]=='o') { - if (!strcmp(name,"commands_stats")) return (int)variables.commands_stats; - if (!strcmp(name,"connect_retries_delay")) return (int)variables.connect_retries_delay; - if (!strcmp(name,"connect_retries_on_failure")) return (int)variables.connect_retries_on_failure; - if (!strcmp(name,"connect_timeout_client")) return (int)variables.connect_timeout_client; - if (!strcmp(name,"connect_timeout_server")) return (int)variables.connect_timeout_server; - if (!strcmp(name,"connect_timeout_server_max")) return (int)variables.connect_timeout_server_max; - if (!strcmp(name,"connection_delay_multiplex_ms")) return (int)variables.connection_delay_multiplex_ms; - if (!strcmp(name,"connection_max_age_ms")) return (int)variables.connection_max_age_ms; - if (!strcmp(name,"connection_warming")) return (int)variables.connection_warming; if (!strcmp(name,"connpoll_reset_queue_length")) return (int)variables.connpoll_reset_queue_length; } break; - case 'd': - if (!strcmp(name,"default_max_latency_ms")) return (int)variables.default_max_latency_ms; - if (!strcmp(name,"default_query_delay")) return (int)variables.default_query_delay; - if (!strcmp(name,"default_query_timeout")) return (int)variables.default_query_timeout; - if (!strcmp(name,"default_reconnect")) return (int)variables.default_reconnect; - break; case 'e': - if (!strcmp(name,"enforce_autocommit_on_reads")) return (int)variables.enforce_autocommit_on_reads; - if (!strcmp(name,"eventslog_default_log")) return (int)variables.eventslog_default_log; - if (!strcmp(name,"eventslog_filesize")) return (int)variables.eventslog_filesize; if (!strcmp(name,"eventslog_format")) return (int)variables.eventslog_format; - if (!strcmp(name,"enable_client_deprecate_eof")) return (int)variables.enable_client_deprecate_eof; - if (!strcmp(name,"enable_server_deprecate_eof")) return (int)variables.enable_server_deprecate_eof; - break; - case 'f': - if (!strcmp(name,"free_connections_pct")) return (int)variables.free_connections_pct; - if (!strcmp(name,"firewall_whitelist_enabled")) return (int)variables.firewall_whitelist_enabled; break; case 'h': if (!strcmp(name,"have_compress")) return (int)variables.have_compress; if (!strcmp(name,"have_ssl")) return (int)variables.have_ssl; break; - case 'k': - if (!strcmp(name,"kill_backend_connection_when_disconnect")) return (int)variables.kill_backend_connection_when_disconnect; - break; - case 'l': - if (!strcmp(name,"long_query_time")) return (int)variables.long_query_time; - if (!strcmp(name,"log_unhealthy_connections")) return (int)variables.log_unhealthy_connections; - if (!strcmp(name,"log_mysql_warnings_enabled")) return (int)variables.log_mysql_warnings_enabled; - break; case 'm': if (name[3]=='_') { - if (!strcmp(name,"max_connections")) return (int)variables.max_connections; - if (!strcmp(name,"max_stmts_cache")) return (int)variables.max_stmts_cache; - if (!strcmp(name,"max_stmts_per_connection")) return (int)variables.max_stmts_per_connection; if (!strcmp(name,"min_num_servers_lantency_awareness")) return (int)variables.min_num_servers_lantency_awareness; } - if (!strcmp(name,"mirror_max_concurrency")) return (int)variables.mirror_max_concurrency; - if (!strcmp(name,"mirror_max_queue_length")) return (int)variables.mirror_max_queue_length; - if (!strcmp(name,"multiplexing")) return (int)variables.multiplexing; break; case 'p': - if (!strcmp(name,"ping_interval_server_msec")) return (int)variables.ping_interval_server_msec; - if (!strcmp(name,"ping_timeout_server")) return (int)variables.ping_timeout_server; if (!strcmp(name,"poll_timeout")) return variables.poll_timeout; if (!strcmp(name,"poll_timeout_on_failure")) return variables.poll_timeout_on_failure; break; - case 'q': - if (name[6]=='c') { - if (!strcmp(name,"query_cache_size_MB")) return (int)variables.query_cache_size_MB; - if (!strcmp(name,"query_cache_stores_empty_result")) return (int)variables.query_cache_stores_empty_result; - } - if (name[6]=='d') { - if (!strcmp(name,"query_digests")) return (int)variables.query_digests; - if (!strcmp(name,"query_digests_lowercase")) return (int)variables.query_digests_lowercase; - if (!strcmp(name,"query_digests_no_digits")) return (int)variables.query_digests_no_digits; - if (!strcmp(name,"query_digests_normalize_digest_text")) return (int)variables.query_digests_normalize_digest_text; - if (!strcmp(name,"query_digests_replace_null")) return (int)variables.query_digests_replace_null; - if (!strcmp(name,"query_digests_track_hostname")) return (int)variables.query_digests_track_hostname; - } - if (name[6]=='p') { - if (!strcmp(name,"query_processor_iterations")) return (int)variables.query_processor_iterations; - if (!strcmp(name,"query_processor_regex")) return (int)variables.query_processor_regex; - } - if (!strcmp(name,"query_retries_on_failure")) return (int)variables.query_retries_on_failure; - break; - case 'r': - if (!strcmp(name,"reset_connection_algorithm")) return (int)variables.reset_connection_algorithm; - break; case 's': if (name[1]=='e') { #ifdef DEBUG @@ -1522,34 +1430,14 @@ int MySQL_Threads_Handler::get_variable_int(const char *name) { if (!strcmp(name,"session_idle_ms")) return (int)variables.session_idle_ms; if (!strcmp(name,"session_idle_show_processlist")) return (int)variables.session_idle_show_processlist; #endif // IDLE_THREADS - if (!strcmp(name,"sessions_sort")) return (int)variables.sessions_sort; - if (!strcmp(name,"servers_stats")) return (int)variables.servers_stats; - if (!strcmp(name,"set_query_lock_on_hostgroup")) return (int)variables.set_query_lock_on_hostgroup; } if (name[1]=='h') { if (!strcmp(name,"show_processlist_extended")) return (int)variables.show_processlist_extended; - if (!strcmp(name,"shun_on_failures")) return (int)variables.shun_on_failures; - if (!strcmp(name,"shun_recovery_time_sec")) return (int)variables.shun_recovery_time_sec; } if (name[1]=='t') { if (!strcmp(name,"stacksize")) return ( stacksize ? stacksize : DEFAULT_STACK_SIZE); - if (!strcmp(name,"stats_time_backend_query")) return (int)variables.stats_time_backend_query; - if (!strcmp(name,"stats_time_query_processor")) return (int)variables.stats_time_query_processor; } break; - case 't': - if (name[8] == '_') { - if (!strcmp(name,"throttle_max_bytes_per_second_to_client")) return (int)variables.throttle_max_bytes_per_second_to_client; - if (!strcmp(name,"throttle_ratio_server_to_client")) return (int)variables.throttle_ratio_server_to_client; - } - if (!strcmp(name,"tcp_keepalive_time")) return (int)variables.tcp_keepalive_time; - break; - case 'u': - if (!strcmp(name,"use_tcp_keepalive")) return (int)variables.use_tcp_keepalive; - break; - case 'v': - if (!strcmp(name,"verbose_query_error")) return (int)variables.verbose_query_error; - break; case 'w': if (!strcmp(name,"wait_timeout")) return (int)variables.wait_timeout; break; @@ -1569,7 +1457,9 @@ char * MySQL_Threads_Handler::get_variable(char *name) { // this is the public f // convert name to string, and lowercase std::string nameS = string(name); std::transform(nameS.begin(), nameS.end(), nameS.begin(), [](unsigned char c){ return std::tolower(c); }); + { + // integer variable std::unordered_map>::const_iterator it = VariablesPointers_int.find(nameS); if (it != VariablesPointers_int.end()) { int * v = std::get<0>(it->second); @@ -1577,6 +1467,14 @@ char * MySQL_Threads_Handler::get_variable(char *name) { // this is the public f return strdup(intbuf); } } + { + // bool variable + std::unordered_map>::const_iterator it = VariablesPointers_bool.find(nameS); + if (it != VariablesPointers_bool.end()) { + bool * v = std::get<0>(it->second); + return strdup((*v ? "true" : "false")); + } + } if (!strcasecmp(name,"firewall_whitelist_errormsg")) { @@ -1681,154 +1579,25 @@ char * MySQL_Threads_Handler::get_variable(char *name) { // this is the public f if (!strcasecmp(name,"monitor_username")) return strdup(variables.monitor_username); if (!strcasecmp(name,"monitor_password")) return strdup(variables.monitor_password); if (!strcasecmp(name,"monitor_replication_lag_use_percona_heartbeat")) return strdup(variables.monitor_replication_lag_use_percona_heartbeat); - if (!strcasecmp(name,"monitor_enabled")) { - return strdup((variables.monitor_enabled ? "true" : "false")); - } - if (!strcasecmp(name,"monitor_galera_healthcheck_interval")) { - sprintf(intbuf,"%d",variables.monitor_galera_healthcheck_interval); - return strdup(intbuf); - } - if (!strcasecmp(name,"monitor_galera_healthcheck_timeout")) { - sprintf(intbuf,"%d",variables.monitor_galera_healthcheck_timeout); - return strdup(intbuf); - } - if (!strcasecmp(name,"monitor_galera_healthcheck_max_timeout_count")) { - sprintf(intbuf,"%d",variables.monitor_galera_healthcheck_max_timeout_count); - return strdup(intbuf); - } - if (!strcasecmp(name,"monitor_query_interval")) { - sprintf(intbuf,"%d",variables.monitor_query_interval); - return strdup(intbuf); - } - if (!strcasecmp(name,"monitor_query_timeout")) { - sprintf(intbuf,"%d",variables.monitor_query_timeout); - return strdup(intbuf); - } - if (!strcasecmp(name,"monitor_slave_lag_when_null")) { - sprintf(intbuf,"%d",variables.monitor_slave_lag_when_null); - return strdup(intbuf); - } - if (!strcasecmp(name,"monitor_threads_min")) { - sprintf(intbuf,"%d",variables.monitor_threads_min); - return strdup(intbuf); - } - if (!strcasecmp(name,"monitor_threads_max")) { - sprintf(intbuf,"%d",variables.monitor_threads_max); - return strdup(intbuf); - } - if (!strcasecmp(name,"monitor_threads_queue_maxsize")) { - sprintf(intbuf,"%d",variables.monitor_threads_queue_maxsize); - return strdup(intbuf); - } - if (!strcasecmp(name,"monitor_writer_is_also_reader")) { - return strdup((variables.monitor_writer_is_also_reader ? "true" : "false")); - } - if (!strcasecmp(name,"monitor_wait_timeout")) { - return strdup((variables.monitor_wait_timeout ? "true" : "false")); - } } if (!strcasecmp(name, "handle_unknown_charset")) { sprintf(intbuf, "%d",variables.handle_unknown_charset); return strdup(intbuf); } - if (!strcasecmp(name,"shun_on_failures")) { - sprintf(intbuf,"%d",variables.shun_on_failures); - return strdup(intbuf); - } - if (!strcasecmp(name,"client_multi_statements")) { - return strdup((variables.client_multi_statements ? "true" : "false")); - } if (!strcasecmp(name,"connpoll_reset_queue_length")) { sprintf(intbuf,"%d",variables.connpoll_reset_queue_length); return strdup(intbuf); } - if (!strcasecmp(name,"shun_recovery_time_sec")) { - sprintf(intbuf,"%d",variables.shun_recovery_time_sec); - return strdup(intbuf); - } - if (!strcasecmp(name,"query_retries_on_failure")) { - sprintf(intbuf,"%d",variables.query_retries_on_failure); - return strdup(intbuf); - } - if (!strcasecmp(name,"connect_retries_on_failure")) { - sprintf(intbuf,"%d",variables.connect_retries_on_failure); - return strdup(intbuf); - } - if (!strcasecmp(name,"connection_delay_multiplex_ms")) { - sprintf(intbuf,"%d",variables.connection_delay_multiplex_ms); - return strdup(intbuf); - } - if (!strcasecmp(name,"connection_max_age_ms")) { - sprintf(intbuf,"%d",variables.connection_max_age_ms); - return strdup(intbuf); - } - if (!strcasecmp(name,"connect_timeout_client")) { - sprintf(intbuf,"%d",variables.connect_timeout_client); - return strdup(intbuf); - } - if (!strcasecmp(name,"connect_timeout_server")) { - sprintf(intbuf,"%d",variables.connect_timeout_server); - return strdup(intbuf); - } - if (!strcasecmp(name,"connect_timeout_server_max")) { - sprintf(intbuf,"%d",variables.connect_timeout_server_max); - return strdup(intbuf); - } - if (!strcasecmp(name,"free_connections_pct")) { - sprintf(intbuf,"%d",variables.free_connections_pct); - return strdup(intbuf); - } #ifdef IDLE_THREADS if (!strcasecmp(name,"session_idle_ms")) { sprintf(intbuf,"%d",variables.session_idle_ms); return strdup(intbuf); } #endif // IDLE_THREADS - if (!strcasecmp(name,"connect_retries_delay")) { - sprintf(intbuf,"%d",variables.connect_retries_delay); - return strdup(intbuf); - } - if (!strcasecmp(name,"eventslog_filesize")) { - sprintf(intbuf,"%d",variables.eventslog_filesize); - return strdup(intbuf); - } - if (!strcasecmp(name,"eventslog_default_log")) { - sprintf(intbuf,"%d",variables.eventslog_default_log); - return strdup(intbuf); - } if (!strcasecmp(name,"eventslog_format")) { sprintf(intbuf,"%d",variables.eventslog_format); return strdup(intbuf); } - if (!strcasecmp(name,"auditlog_filesize")) { - sprintf(intbuf,"%d",variables.auditlog_filesize); - return strdup(intbuf); - } - if (!strcasecmp(name,"tcp_keepalive_time")) { - sprintf(intbuf,"%d",variables.tcp_keepalive_time); - return strdup(intbuf); - } - if (!strcasecmp(name,"use_tcp_keepalive")) { - sprintf(intbuf,"%d",variables.use_tcp_keepalive); - return strdup(intbuf); - } - if (!strcasecmp(name,"firewall_whitelist_enabled")) { - sprintf(intbuf,"%d",variables.firewall_whitelist_enabled); - return strdup(intbuf); - } - if (!strcasecmp(name,"automatic_detect_sqli")) { - sprintf(intbuf,"%d",variables.automatic_detect_sqli); - return strdup(intbuf); - } - if (!strcasecmp(name,"enable_client_deprecate_eof")) { - return strdup((variables.enable_client_deprecate_eof ? "true" : "false")); - } - if (!strcasecmp(name,"enable_server_deprecate_eof")) { - return strdup((variables.enable_server_deprecate_eof ? "true" : "false")); - } - if (!strcasecmp(name,"log_mysql_warnings_enabled")) { - return strdup((variables.log_mysql_warnings_enabled? "true" : "false")); - } if (!strcasecmp(name,"binlog_reader_connect_retry_msec")) { sprintf(intbuf,"%d",variables.binlog_reader_connect_retry_msec); return strdup(intbuf); @@ -1837,82 +1606,6 @@ char * MySQL_Threads_Handler::get_variable(char *name) { // this is the public f sprintf(intbuf,"%d",variables.wait_timeout); return strdup(intbuf); } - if (!strcasecmp(name,"throttle_max_bytes_per_second_to_client")) { - sprintf(intbuf,"%d",variables.throttle_max_bytes_per_second_to_client); - return strdup(intbuf); - } - if (!strcasecmp(name,"throttle_ratio_server_to_client")) { - sprintf(intbuf,"%d",variables.throttle_ratio_server_to_client); - return strdup(intbuf); - } - if (!strcasecmp(name,"max_connections")) { - sprintf(intbuf,"%d",variables.max_connections); - return strdup(intbuf); - } - if (!strcasecmp(name,"max_stmts_per_connection")) { - sprintf(intbuf,"%d",variables.max_stmts_per_connection); - return strdup(intbuf); - } - if (!strcasecmp(name,"max_stmts_cache")) { - sprintf(intbuf,"%d",variables.max_stmts_cache); - return strdup(intbuf); - } - if (!strcasecmp(name,"mirror_max_concurrency")) { - sprintf(intbuf,"%d",variables.mirror_max_concurrency); - return strdup(intbuf); - } - if (!strcasecmp(name,"mirror_max_queue_length")) { - sprintf(intbuf,"%d",variables.mirror_max_queue_length); - return strdup(intbuf); - } - if (!strcasecmp(name,"default_query_delay")) { - sprintf(intbuf,"%d",variables.default_query_delay); - return strdup(intbuf); - } - if (!strcasecmp(name,"default_query_timeout")) { - sprintf(intbuf,"%d",variables.default_query_timeout); - return strdup(intbuf); - } - if (!strcasecmp(name,"query_processor_iterations")) { - sprintf(intbuf,"%d",variables.query_processor_iterations); - return strdup(intbuf); - } - if (!strcasecmp(name,"query_processor_regex")) { - sprintf(intbuf,"%d",variables.query_processor_regex); - return strdup(intbuf); - } - if (!strcasecmp(name,"set_query_lock_on_hostgroup")) { - sprintf(intbuf,"%d",variables.set_query_lock_on_hostgroup); - return strdup(intbuf); - } - if (!strcasecmp(name,"reset_connection_algorithm")) { - sprintf(intbuf,"%d",variables.reset_connection_algorithm); - return strdup(intbuf); - } - if (!strcasecmp(name,"auto_increment_delay_multiplex")) { - sprintf(intbuf,"%d",variables.auto_increment_delay_multiplex); - return strdup(intbuf); - } - if (!strcasecmp(name,"default_max_latency_ms")) { - sprintf(intbuf,"%d",variables.default_max_latency_ms); - return strdup(intbuf); - } - if (!strcasecmp(name,"long_query_time")) { - sprintf(intbuf,"%d",variables.long_query_time); - return strdup(intbuf); - } - if (!strcasecmp(name,"query_cache_size_MB")) { - sprintf(intbuf,"%d",variables.query_cache_size_MB); - return strdup(intbuf); - } - if (!strcasecmp(name,"ping_interval_server_msec")) { - sprintf(intbuf,"%d",variables.ping_interval_server_msec); - return strdup(intbuf); - } - if (!strcasecmp(name,"ping_timeout_server")) { - sprintf(intbuf,"%d",variables.ping_timeout_server); - return strdup(intbuf); - } if (!strcasecmp(name,"poll_timeout")) { sprintf(intbuf,"%d",variables.poll_timeout); return strdup(intbuf); @@ -1948,69 +1641,6 @@ char * MySQL_Threads_Handler::get_variable(char *name) { // this is the public f if (!strcasecmp(name,"have_ssl")) { return strdup((variables.have_ssl ? "true" : "false")); } - if (!strcasecmp(name,"client_found_rows")) { - return strdup((variables.client_found_rows ? "true" : "false")); - } - if (!strcasecmp(name,"multiplexing")) { - return strdup((variables.multiplexing ? "true" : "false")); - } - if (!strcasecmp(name,"log_unhealthy_connections")) { - return strdup((variables.log_unhealthy_connections ? "true" : "false")); - } - if (!strcasecmp(name,"connection_warming")) { - return strdup((variables.connection_warming ? "true" : "false")); - } - if (!strcasecmp(name,"enforce_autocommit_on_reads")) { - return strdup((variables.enforce_autocommit_on_reads ? "true" : "false")); - } - if (!strcasecmp(name,"autocommit_false_not_reusable")) { - return strdup((variables.autocommit_false_not_reusable ? "true" : "false")); - } - if (!strcasecmp(name,"autocommit_false_is_transaction")) { - return strdup((variables.autocommit_false_is_transaction ? "true" : "false")); - } - if (!strcasecmp(name,"verbose_query_error")) { - return strdup((variables.verbose_query_error ? "true" : "false")); - } - if (!strcasecmp(name,"commands_stats")) { - return strdup((variables.commands_stats ? "true" : "false")); - } - if (!strcasecmp(name,"query_digests")) { - return strdup((variables.query_digests ? "true" : "false")); - } - if (!strcasecmp(name,"query_digests_lowercase")) { - return strdup((variables.query_digests_lowercase ? "true" : "false")); - } - if (!strcasecmp(name,"query_digests_replace_null")) { - return strdup((variables.query_digests_replace_null ? "true" : "false")); - } - if (!strcasecmp(name,"query_digests_no_digits")) { - return strdup((variables.query_digests_no_digits ? "true" : "false")); - } - if (!strcasecmp(name,"query_digests_normalize_digest_text")) { - return strdup((variables.query_digests_normalize_digest_text ? "true" : "false")); - } - if (!strcasecmp(name,"query_digests_track_hostname")) { - return strdup((variables.query_digests_track_hostname ? "true" : "false")); - } - if (!strcasecmp(name,"stats_time_backend_query")) { - return strdup((variables.stats_time_backend_query ? "true" : "false")); - } - if (!strcasecmp(name,"stats_time_query_processor")) { - return strdup((variables.stats_time_query_processor ? "true" : "false")); - } - if (!strcasecmp(name,"query_cache_stores_empty_result")) { - return strdup((variables.query_cache_stores_empty_result ? "true" : "false")); - } - if (!strcasecmp(name,"kill_backend_connection_when_disconnect")) { - return strdup((variables.kill_backend_connection_when_disconnect ? "true" : "false")); - } - if (!strcasecmp(name,"client_session_track_gtid")) { - return strdup((variables.client_session_track_gtid ? "true" : "false")); - } - if (!strcasecmp(name,"sessions_sort")) { - return strdup((variables.sessions_sort ? "true" : "false")); - } #ifdef IDLE_THREADS if (!strcasecmp(name,"session_idle_show_processlist")) { return strdup((variables.session_idle_show_processlist ? "true" : "false")); @@ -2020,12 +1650,6 @@ char * MySQL_Threads_Handler::get_variable(char *name) { // this is the public f sprintf(intbuf,"%d",variables.show_processlist_extended); return strdup(intbuf); } - if (!strcasecmp(name,"servers_stats")) { - return strdup((variables.servers_stats ? "true" : "false")); - } - if (!strcasecmp(name,"default_reconnect")) { - return strdup((variables.default_reconnect ? "true" : "false")); - } return NULL; //VALGRIND_ENABLE_ERROR_REPORTING; } @@ -2049,6 +1673,7 @@ bool MySQL_Threads_Handler::set_variable(char *name, const char *value) { // thi std::string nameS = string(name); std::transform(nameS.begin(), nameS.end(), nameS.begin(), [](unsigned char c){ return std::tolower(c); }); { + // integer variable ? std::unordered_map>::const_iterator it = VariablesPointers_int.find(nameS); if (it != VariablesPointers_int.end()) { bool special_variable = std::get<3>(it->second); // if special_variable is true, min and max values are ignored, and more input validation is needed @@ -2065,6 +1690,27 @@ bool MySQL_Threads_Handler::set_variable(char *name, const char *value) { // thi } } } + { + // boolean variable ? + std::unordered_map>::const_iterator it = VariablesPointers_bool.find(nameS); + if (it != VariablesPointers_bool.end()) { + bool special_variable = std::get<1>(it->second); // if special_variable is true, more input validation is needed + if (special_variable == false) { + bool * v = std::get<0>(it->second); + if (strcasecmp(value,"true")==0 || strcasecmp(value,"1")==0) { + *v = true; + return true; + } + if (strcasecmp(value,"false")==0 || strcasecmp(value,"0")==0) { + *v = false; + return true; + } + return false; + } else { + // we need to perform input validation + } + } + } // monitor variables if (!strncasecmp(name,"monitor_",8)) { @@ -2088,512 +1734,57 @@ bool MySQL_Threads_Handler::set_variable(char *name, const char *value) { // thi variables.monitor_replication_lag_use_percona_heartbeat=strdup((value)); return true; } else { - re2::RE2::Options *opt2=new re2::RE2::Options(RE2::Quiet); - opt2->set_case_sensitive(false); - char *patt = (char *)"`?([a-z\\d_]+)`?\\.`?([a-z\\d_]+)`?"; - RE2 *re = new RE2(patt, *opt2); - bool rc=false; - rc = RE2::FullMatch(value,*re); - delete re; - delete opt2; - if(rc) { - free(variables.monitor_replication_lag_use_percona_heartbeat); - variables.monitor_replication_lag_use_percona_heartbeat=strdup(value); - return true; - } else { - proxy_error("%s is an invalid value for %s, not matching regex \"%s\"\n", value, name, patt); - } - } - return false; - } - if (!strcasecmp(name,"monitor_enabled")) { - if (strcasecmp(value,"true")==0 || strcasecmp(value,"1")==0) { - variables.monitor_enabled=true; - return true; - } - if (strcasecmp(value,"false")==0 || strcasecmp(value,"0")==0) { - variables.monitor_enabled=false; - return true; - } - return false; - } - if (!strcasecmp(name,"monitor_galera_healthcheck_interval")) { - int intv=atoi(value); - if (intv >= 50 && intv <= 7*24*3600*1000) { - variables.monitor_galera_healthcheck_interval=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"monitor_galera_healthcheck_timeout")) { - int intv=atoi(value); - if (intv >= 50 && intv <= 600*1000) { - variables.monitor_galera_healthcheck_timeout=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"monitor_galera_healthcheck_max_timeout_count")) { - int intv=atoi(value); - if (intv >= 1 && intv <= 10) { - variables.monitor_galera_healthcheck_max_timeout_count=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"monitor_query_interval")) { - int intv=atoi(value); - if (intv >= 100 && intv <= 7*24*3600*1000) { - variables.monitor_query_interval=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"monitor_query_timeout")) { - int intv=atoi(value); - if (intv >= 100 && intv <= 600*1000) { - variables.monitor_query_timeout=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"monitor_slave_lag_when_null")) { - int intv=atoi(value); - if (intv >= 0 && intv <= 604800) { - variables.monitor_slave_lag_when_null=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"monitor_threads_min")) { - int intv=atoi(value); - if (intv >= 2 && intv <= 16) { - variables.monitor_threads_min = intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"monitor_threads_max")) { - int intv=atoi(value); - if (intv >= 4 && intv <= 256) { - variables.monitor_threads_max = intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"monitor_threads_queue_maxsize")) { - int intv=atoi(value); - if (intv >= 16 && intv <= 1024) { - variables.monitor_threads_queue_maxsize = intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"monitor_wait_timeout")) { - if (strcasecmp(value,"true")==0 || strcasecmp(value,"1")==0) { - variables.monitor_wait_timeout=true; - return true; - } - if (strcasecmp(value,"false")==0 || strcasecmp(value,"0")==0) { - variables.monitor_wait_timeout=false; - return true; - } - return false; - } - if (!strcasecmp(name,"monitor_writer_is_also_reader")) { - if (strcasecmp(value,"true")==0 || strcasecmp(value,"1")==0) { - variables.monitor_writer_is_also_reader=true; - return true; - } - if (strcasecmp(value,"false")==0 || strcasecmp(value,"0")==0) { - variables.monitor_writer_is_also_reader=false; - return true; - } - return false; - } - } - if (!strcasecmp(name,"binlog_reader_connect_retry_msec")) { - int intv=atoi(value); - if (intv >= 200 && intv <= 120000) { - __sync_lock_test_and_set(&variables.binlog_reader_connect_retry_msec,intv); - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"wait_timeout")) { - int intv=atoi(value); - if (intv >= 0 && intv <= 20*24*3600*1000) { - variables.wait_timeout=intv; - if (variables.wait_timeout < 5000) { - proxy_warning("mysql-wait_timeout is set to a low value: %ums\n", variables.wait_timeout); - } - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"free_connections_pct")) { - int intv=atoi(value); - if (intv >= 0 && intv <= 100) { - variables.free_connections_pct=intv; - return true; - } else { - return false; - } - } -#ifdef IDLE_THREADS - if (!strcasecmp(name,"session_idle_ms")) { - int intv=atoi(value); - if (intv >= 1 && intv <= 3600*1000) { - variables.session_idle_ms=intv; - return true; - } else { - return false; - } - } -#endif // IDLE_THREADS - if (!strcasecmp(name,"throttle_max_bytes_per_second_to_client")) { - int intv=atoi(value); - if (intv >= 0 && intv <= 2147483647) { - variables.throttle_max_bytes_per_second_to_client=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"throttle_ratio_server_to_client")) { - int intv=atoi(value); - if (intv >= 0 && intv <= 100) { - variables.throttle_ratio_server_to_client=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"max_connections")) { - int intv=atoi(value); - if (intv >= 1 && intv <= 1000*1000) { - variables.max_connections=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"tcp_keepalive_time")) { - int intv=atoi(value); - if (intv >= 0 && intv <= 7200) { - variables.tcp_keepalive_time=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"use_tcp_keepalive")) { - if (strcasecmp(value,"true")==0 || strcasecmp(value,"1")==0) { - variables.use_tcp_keepalive=true; - return true; - } - if (strcasecmp(value,"false")==0 || strcasecmp(value,"0")==0) { - variables.use_tcp_keepalive=false; - return true; - } - return false; - } - if (!strcasecmp(name,"firewall_whitelist_enabled")) { - if (strcasecmp(value,"true")==0 || strcasecmp(value,"1")==0) { - variables.firewall_whitelist_enabled=true; - return true; - } - if (strcasecmp(value,"false")==0 || strcasecmp(value,"0")==0) { - variables.firewall_whitelist_enabled=false; - return true; - } - return false; - } - if (!strcasecmp(name,"automatic_detect_sqli")) { - if (strcasecmp(value,"true")==0 || strcasecmp(value,"1")==0) { - variables.automatic_detect_sqli=true; - return true; - } - if (strcasecmp(value,"false")==0 || strcasecmp(value,"0")==0) { - variables.automatic_detect_sqli=false; - return true; - } - return false; - } - if (!strcasecmp(name,"max_stmts_per_connection")) { - int intv=atoi(value); - if (intv >= 1 && intv <= 1024) { - variables.max_stmts_per_connection=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"max_stmts_cache")) { - int intv=atoi(value); - if (intv >= 1024 && intv <= 1024*1024) { - variables.max_stmts_cache=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"mirror_max_concurrency")) { - int intv=atoi(value); - if (intv >= 1 && intv <= 8*1024) { - variables.mirror_max_concurrency=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"mirror_max_queue_length")) { - int intv=atoi(value); - if (intv >= 0 && intv <= 1024*1024) { - variables.mirror_max_queue_length=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"default_query_delay")) { - int intv=atoi(value); - if (intv >= 0 && intv <= 3600*1000) { - variables.default_query_delay=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"default_query_timeout")) { - int intv=atoi(value); - if (intv >= 1000 && intv <= 20*24*3600*1000) { - variables.default_query_timeout=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"query_processor_iterations")) { - int intv=atoi(value); - if (intv >= 0 && intv <= 1000*1000) { - variables.query_processor_iterations=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"query_processor_regex")) { - int intv=atoi(value); - if (intv >= 1 && intv <= 2) { - variables.query_processor_regex=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"set_query_lock_on_hostgroup")) { - int intv=atoi(value); - if (intv >= 0 && intv <= 1) { - variables.set_query_lock_on_hostgroup=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"reset_connection_algorithm")) { - int intv=atoi(value); - if (intv >= 1 && intv <= 2) { - variables.reset_connection_algorithm=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"auto_increment_delay_multiplex")) { - int intv=atoi(value); - if (intv >= 0 && intv <= 1000000) { - variables.auto_increment_delay_multiplex=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"default_max_latency_ms")) { - int intv=atoi(value); - if (intv >= 0 && intv <= 20*24*3600*1000) { - variables.default_max_latency_ms=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"long_query_time")) { - int intv=atoi(value); - if (intv >= 0 && intv <= 20*24*3600*1000) { - variables.long_query_time=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"query_cache_size_MB")) { - int intv=atoi(value); - if (intv >= 0 && intv <= 1024*10240) { - variables.query_cache_size_MB=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"ping_interval_server_msec")) { - int intv=atoi(value); - if (intv >= 1000 && intv <= 7*24*3600*1000) { - variables.ping_interval_server_msec=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"ping_timeout_server")) { - int intv=atoi(value); - if (intv >= 10 && intv <= 600*1000) { - variables.ping_timeout_server=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"shun_on_failures")) { - int intv=atoi(value); - if (intv >= 0 && intv <= 10000000) { - variables.shun_on_failures=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"shun_recovery_time_sec")) { - int intv=atoi(value); - if (intv >= 0 && intv <= 3600*24*365) { - variables.shun_recovery_time_sec=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"query_retries_on_failure")) { - int intv=atoi(value); - if (intv >= 0 && intv <= 1000) { - variables.query_retries_on_failure=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"client_multi_statements")) { - if (strcasecmp(value,"true")==0 || strcasecmp(value,"1")==0) { - variables.client_multi_statements=true; - return true; - } - if (strcasecmp(value,"false")==0 || strcasecmp(value,"0")==0) { - variables.client_multi_statements=false; - return true; - } - return false; - } - if (!strcasecmp(name,"connect_retries_on_failure")) { - int intv=atoi(value); - if (intv >= 0 && intv <= 1000) { - variables.connect_retries_on_failure=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"connection_delay_multiplex_ms")) { - int intv=atoi(value); - if (intv >= 0 && intv <= 300*1000) { - variables.connection_delay_multiplex_ms=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"connection_max_age_ms")) { - int intv=atoi(value); - if (intv >= 0 && intv <= 3600*24*1000) { - variables.connection_max_age_ms=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"connect_timeout_client")) { - int intv=atoi(value); - if (intv >= 500 && intv <= 3600*1000) { - variables.connect_timeout_client=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"connect_timeout_server")) { - int intv=atoi(value); - if (intv >= 10 && intv <= 120*1000) { - variables.connect_timeout_server=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"connect_timeout_server_max")) { - int intv=atoi(value); - if (intv >= 10 && intv <= 3600*1000) { - variables.connect_timeout_server_max=intv; - return true; - } else { + re2::RE2::Options *opt2=new re2::RE2::Options(RE2::Quiet); + opt2->set_case_sensitive(false); + char *patt = (char *)"`?([a-z\\d_]+)`?\\.`?([a-z\\d_]+)`?"; + RE2 *re = new RE2(patt, *opt2); + bool rc=false; + rc = RE2::FullMatch(value,*re); + delete re; + delete opt2; + if(rc) { + free(variables.monitor_replication_lag_use_percona_heartbeat); + variables.monitor_replication_lag_use_percona_heartbeat=strdup(value); + return true; + } else { + proxy_error("%s is an invalid value for %s, not matching regex \"%s\"\n", value, name, patt); + } + } return false; } } - if (!strcasecmp(name,"connect_retries_delay")) { + if (!strcasecmp(name,"binlog_reader_connect_retry_msec")) { int intv=atoi(value); - if (intv >= 0 && intv <= 10000) { - variables.connect_retries_delay=intv; + if (intv >= 200 && intv <= 120000) { + __sync_lock_test_and_set(&variables.binlog_reader_connect_retry_msec,intv); return true; } else { return false; } } - if (!strcasecmp(name,"eventslog_filesize")) { + if (!strcasecmp(name,"wait_timeout")) { int intv=atoi(value); - if (intv >= 1024*1024 && intv <= 1*1024*1024*1024) { - variables.eventslog_filesize=intv; + if (intv >= 0 && intv <= 20*24*3600*1000) { + variables.wait_timeout=intv; + if (variables.wait_timeout < 5000) { + proxy_warning("mysql-wait_timeout is set to a low value: %ums\n", variables.wait_timeout); + } return true; } else { return false; } } - if (!strcasecmp(name,"eventslog_default_log")) { +#ifdef IDLE_THREADS + if (!strcasecmp(name,"session_idle_ms")) { int intv=atoi(value); - if (intv >= 0 && intv <= 1) { - variables.eventslog_default_log=intv; + if (intv >= 1 && intv <= 3600*1000) { + variables.session_idle_ms=intv; return true; } else { return false; } } +#endif // IDLE_THREADS if (!strcasecmp(name,"eventslog_format")) { int intv=atoi(value); if (intv >= 1 && intv <= 2) { @@ -2610,15 +1801,6 @@ bool MySQL_Threads_Handler::set_variable(char *name, const char *value) { // thi return false; } } - if (!strcasecmp(name,"auditlog_filesize")) { - int intv=atoi(value); - if (intv >= 1024*1024 && intv <= 1*1024*1024*1024) { - variables.auditlog_filesize=intv; - return true; - } else { - return false; - } - } if (!strcasecmp(name,"default_schema")) { if (vallen) { free(variables.default_schema); @@ -2722,28 +1904,6 @@ bool MySQL_Threads_Handler::set_variable(char *name, const char *value) { // thi } return false; // we couldn't set it to a valid value. It will be reset to default } - if (!strcasecmp(name,"enable_client_deprecate_eof")) { - if (strcasecmp(value,"true")==0 || strcasecmp(value,"1")==0) { - variables.enable_client_deprecate_eof=true; - return true; - } - if (strcasecmp(value,"false")==0 || strcasecmp(value,"0")==0) { - variables.enable_client_deprecate_eof=false; - return true; - } - return false; - } - if (!strcasecmp(name,"enable_server_deprecate_eof")) { - if (strcasecmp(value,"true")==0 || strcasecmp(value,"1")==0) { - variables.enable_server_deprecate_eof=true; - return true; - } - if (strcasecmp(value,"false")==0 || strcasecmp(value,"0")==0) { - variables.enable_server_deprecate_eof=false; - return true; - } - return false; - } if (!strncmp(name,"default_",8)) { for (int i=0; i Date: Tue, 11 May 2021 19:24:49 +0200 Subject: [PATCH 3/6] More code cleanup for MySQL variables --- include/MySQL_Thread.h | 3 +- include/proxysql_structs.h | 4 +- lib/MySQL_Thread.cpp | 280 ++++++------------------------------- 3 files changed, 42 insertions(+), 245 deletions(-) diff --git a/include/MySQL_Thread.h b/include/MySQL_Thread.h index 4d56c70cd..3196578e0 100644 --- a/include/MySQL_Thread.h +++ b/include/MySQL_Thread.h @@ -441,7 +441,7 @@ class MySQL_Threads_Handler char *server_version; char *keep_multiplexing_variables; //unsigned int default_charset; // removed in 2.0.13 . Obsoleted previously using MySQL_Variables instead - unsigned int handle_unknown_charset; + int handle_unknown_charset; bool servers_stats; bool commands_stats; bool query_digests; @@ -559,7 +559,6 @@ class MySQL_Threads_Handler ~MySQL_Threads_Handler(); char *get_variable_string(char *name); - unsigned int get_variable_uint(char *name); uint16_t get_variable_uint16(char *name); int get_variable_int(const char *name); void print_version(); diff --git a/include/proxysql_structs.h b/include/proxysql_structs.h index 682457058..8a1d580c5 100644 --- a/include/proxysql_structs.h +++ b/include/proxysql_structs.h @@ -758,7 +758,7 @@ __thread int mysql_thread___set_query_lock_on_hostgroup; __thread int mysql_thread___reset_connection_algorithm; __thread uint32_t mysql_thread___server_capabilities; __thread int mysql_thread___auto_increment_delay_multiplex; -__thread unsigned int mysql_thread___handle_unknown_charset; +__thread int mysql_thread___handle_unknown_charset; __thread int mysql_thread___poll_timeout; __thread int mysql_thread___poll_timeout_on_failure; __thread bool mysql_thread___connection_warming; @@ -909,7 +909,7 @@ extern __thread int mysql_thread___set_query_lock_on_hostgroup; extern __thread int mysql_thread___reset_connection_algorithm; extern __thread uint32_t mysql_thread___server_capabilities; extern __thread int mysql_thread___auto_increment_delay_multiplex; -extern __thread unsigned int mysql_thread___handle_unknown_charset; +extern __thread int mysql_thread___handle_unknown_charset; extern __thread int mysql_thread___poll_timeout; extern __thread int mysql_thread___poll_timeout_on_failure; extern __thread bool mysql_thread___connection_warming; diff --git a/lib/MySQL_Thread.cpp b/lib/MySQL_Thread.cpp index 2864d52a4..16139075f 100644 --- a/lib/MySQL_Thread.cpp +++ b/lib/MySQL_Thread.cpp @@ -1358,17 +1358,7 @@ uint16_t MySQL_Threads_Handler::get_variable_uint16(char *name) { return 0; } -unsigned int MySQL_Threads_Handler::get_variable_uint(char *name) { - if (!strcasecmp(name,"handle_unknown_charset")) return variables.handle_unknown_charset; - proxy_error("Not existing variable: %s\n", name); assert(0); - return 0; -} - int MySQL_Threads_Handler::get_variable_int(const char *name) { - - if (!strcasecmp(name,"max_transaction_idle_time")) { - PROXY_TRACE(); - } // convert name to string, and lowercase std::string nameS = string(name); std::transform(nameS.begin(), nameS.end(), nameS.begin(), [](unsigned char c){ return std::tolower(c); }); @@ -1392,58 +1382,7 @@ int MySQL_Threads_Handler::get_variable_int(const char *name) { //VALGRIND_DISABLE_ERROR_REPORTING; - char a = name[0]; - switch (a) { - case 'a': - if (!strcmp(name,"aurora_max_lag_ms_only_read_from_replicas")) return variables.aurora_max_lag_ms_only_read_from_replicas; - break; - case 'b': - if (!strcmp(name,"binlog_reader_connect_retry_msec")) return (int)variables.binlog_reader_connect_retry_msec; - break; - case 'c': - if (name[1]=='o') { - if (!strcmp(name,"connpoll_reset_queue_length")) return (int)variables.connpoll_reset_queue_length; - } - break; - case 'e': - if (!strcmp(name,"eventslog_format")) return (int)variables.eventslog_format; - break; - case 'h': - if (!strcmp(name,"have_compress")) return (int)variables.have_compress; - if (!strcmp(name,"have_ssl")) return (int)variables.have_ssl; - break; - case 'm': - if (name[3]=='_') { - if (!strcmp(name,"min_num_servers_lantency_awareness")) return (int)variables.min_num_servers_lantency_awareness; - } - break; - case 'p': - if (!strcmp(name,"poll_timeout")) return variables.poll_timeout; - if (!strcmp(name,"poll_timeout_on_failure")) return variables.poll_timeout_on_failure; - break; - case 's': - if (name[1]=='e') { -#ifdef DEBUG - if (!strcmp(name,"session_debug")) return (int)variables.session_debug; -#endif /* DEBUG */ -#ifdef IDLE_THREADS - if (!strcmp(name,"session_idle_ms")) return (int)variables.session_idle_ms; - if (!strcmp(name,"session_idle_show_processlist")) return (int)variables.session_idle_show_processlist; -#endif // IDLE_THREADS - } - if (name[1]=='h') { - if (!strcmp(name,"show_processlist_extended")) return (int)variables.show_processlist_extended; - } - if (name[1]=='t') { - if (!strcmp(name,"stacksize")) return ( stacksize ? stacksize : DEFAULT_STACK_SIZE); - } - break; - case 'w': - if (!strcmp(name,"wait_timeout")) return (int)variables.wait_timeout; - break; - default: - break; - } + if (!strcmp(name,"stacksize")) return ( stacksize ? stacksize : DEFAULT_STACK_SIZE); proxy_error("Not existing variable: %s\n", name); assert(0); return 0; //VALGRIND_ENABLE_ERROR_REPORTING; @@ -1580,48 +1519,6 @@ char * MySQL_Threads_Handler::get_variable(char *name) { // this is the public f if (!strcasecmp(name,"monitor_password")) return strdup(variables.monitor_password); if (!strcasecmp(name,"monitor_replication_lag_use_percona_heartbeat")) return strdup(variables.monitor_replication_lag_use_percona_heartbeat); } - if (!strcasecmp(name, "handle_unknown_charset")) { - sprintf(intbuf, "%d",variables.handle_unknown_charset); - return strdup(intbuf); - } - if (!strcasecmp(name,"connpoll_reset_queue_length")) { - sprintf(intbuf,"%d",variables.connpoll_reset_queue_length); - return strdup(intbuf); - } -#ifdef IDLE_THREADS - if (!strcasecmp(name,"session_idle_ms")) { - sprintf(intbuf,"%d",variables.session_idle_ms); - return strdup(intbuf); - } -#endif // IDLE_THREADS - if (!strcasecmp(name,"eventslog_format")) { - sprintf(intbuf,"%d",variables.eventslog_format); - return strdup(intbuf); - } - if (!strcasecmp(name,"binlog_reader_connect_retry_msec")) { - sprintf(intbuf,"%d",variables.binlog_reader_connect_retry_msec); - return strdup(intbuf); - } - if (!strcasecmp(name,"wait_timeout")) { - sprintf(intbuf,"%d",variables.wait_timeout); - return strdup(intbuf); - } - if (!strcasecmp(name,"poll_timeout")) { - sprintf(intbuf,"%d",variables.poll_timeout); - return strdup(intbuf); - } - if (!strcasecmp(name,"poll_timeout_on_failure")) { - sprintf(intbuf,"%d",variables.poll_timeout_on_failure); - return strdup(intbuf); - } - if (!strcasecmp(name,"min_num_servers_lantency_awareness")) { - sprintf(intbuf,"%d",variables.min_num_servers_lantency_awareness); - return strdup(intbuf); - } - if (!strcasecmp(name,"aurora_max_lag_ms_only_read_from_replicas")) { - sprintf(intbuf,"%d",variables.aurora_max_lag_ms_only_read_from_replicas); - return strdup(intbuf); - } if (!strcasecmp(name,"threads")) { sprintf(intbuf,"%d", (num_threads ? num_threads : DEFAULT_NUM_THREADS)); return strdup(intbuf); @@ -1630,26 +1527,7 @@ char * MySQL_Threads_Handler::get_variable(char *name) { // this is the public f sprintf(intbuf,"%d", (int)(stacksize ? stacksize : DEFAULT_STACK_SIZE)); return strdup(intbuf); } -#ifdef DEBUG - if (!strcasecmp(name,"session_debug")) { - return strdup((variables.session_debug ? "true" : "false")); - } -#endif /* DEBUG */ - if (!strcasecmp(name,"have_compress")) { - return strdup((variables.have_compress ? "true" : "false")); - } - if (!strcasecmp(name,"have_ssl")) { - return strdup((variables.have_ssl ? "true" : "false")); - } -#ifdef IDLE_THREADS - if (!strcasecmp(name,"session_idle_show_processlist")) { - return strdup((variables.session_idle_show_processlist ? "true" : "false")); - } -#endif // IDLE_THREADS - if (!strcasecmp(name,"show_processlist_extended")) { - sprintf(intbuf,"%d",variables.show_processlist_extended); - return strdup(intbuf); - } + return NULL; //VALGRIND_ENABLE_ERROR_REPORTING; } @@ -1774,17 +1652,6 @@ bool MySQL_Threads_Handler::set_variable(char *name, const char *value) { // thi return false; } } -#ifdef IDLE_THREADS - if (!strcasecmp(name,"session_idle_ms")) { - int intv=atoi(value); - if (intv >= 1 && intv <= 3600*1000) { - variables.session_idle_ms=intv; - return true; - } else { - return false; - } - } -#endif // IDLE_THREADS if (!strcasecmp(name,"eventslog_format")) { int intv=atoi(value); if (intv >= 1 && intv <= 2) { @@ -2025,66 +1892,6 @@ bool MySQL_Threads_Handler::set_variable(char *name, const char *value) { // thi int intv=atoi(value); if (intv > 10 && intv <= 65535) { variables.server_capabilities=intv; -// if (variables.server_capabilities & CLIENT_SSL) { - // for now disable CLIENT_SSL -// variables.server_capabilities &= ~CLIENT_SSL; -// } -// variables.server_capabilities |= CLIENT_SSL; - - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"poll_timeout")) { - int intv=atoi(value); - if (intv >= 10 && intv <= 20000) { - variables.poll_timeout=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"poll_timeout_on_failure")) { - int intv=atoi(value); - if (intv >= 10 && intv <= 20000) { - variables.poll_timeout_on_failure=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"connpoll_reset_queue_length")) { - int intv=atoi(value); - if (intv >= 0 && intv <= 1000) { - variables.connpoll_reset_queue_length=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"min_num_servers_lantency_awareness")) { - int intv=atoi(value); - if (intv >= 0 && intv <= 10000) { - variables.min_num_servers_lantency_awareness=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"aurora_max_lag_ms_only_read_from_replicas")) { - int intv=atoi(value); - if (intv >= 0 && intv <= 100) { - variables.aurora_max_lag_ms_only_read_from_replicas=intv; - return true; - } else { - return false; - } - } - if (!strcasecmp(name,"handle_unknown_charset")) { - uint8_t intv=atoi(value); - if (intv >= 0 && intv < HANDLE_UNKNOWN_CHARSET__MAX_HANDLE_VALUE) { - variables.handle_unknown_charset=intv; return true; } else { return false; @@ -2109,19 +1916,6 @@ bool MySQL_Threads_Handler::set_variable(char *name, const char *value) { // thi return false; } } -#ifdef DEBUG - if (!strcasecmp(name,"session_debug")) { - if (strcasecmp(value,"true")==0 || strcasecmp(value,"1")==0) { - variables.session_debug=true; - return true; - } - if (strcasecmp(value,"false")==0 || strcasecmp(value,"0")==0) { - variables.session_debug=false; - return true; - } - return false; - } -#endif /* DEBUG */ if (!strcasecmp(name,"have_compress")) { if (strcasecmp(value,"true")==0 || strcasecmp(value,"1")==0) { variables.have_compress=true; @@ -2155,29 +1949,6 @@ bool MySQL_Threads_Handler::set_variable(char *name, const char *value) { // thi } return false; } -#ifdef IDLE_THREADS - if (!strcasecmp(name,"session_idle_show_processlist")) { - if (strcasecmp(value,"true")==0 || strcasecmp(value,"1")==0) { - variables.session_idle_show_processlist=true; - return true; - } - if (strcasecmp(value,"false")==0 || strcasecmp(value,"0")==0) { - variables.session_idle_show_processlist=false; - return true; - } - return false; - } -#endif // IDLE_THREADS - if (!strcasecmp(name,"show_processlist_extended")) { - int intv=atoi(value); - if (intv >= 0 && intv <= 2) { - variables.show_processlist_extended=intv; - return true; - } else { - return false; - } - return false; - } return false; } @@ -2222,8 +1993,16 @@ char ** MySQL_Threads_Handler::get_variables_list() { VariablesPointers_bool["stats_time_query_processor"] = make_tuple(&variables.stats_time_query_processor, false); VariablesPointers_bool["use_tcp_keepalive"] = make_tuple(&variables.use_tcp_keepalive, false); VariablesPointers_bool["verbose_query_error"] = make_tuple(&variables.verbose_query_error, false); - - +#ifdef IDLE_THREADS + VariablesPointers_bool["session_idle_show_processlist"] = make_tuple(&variables.session_idle_show_processlist, false); +#endif // IDLE_THREADS +#ifdef DEBUG + VariablesPointers_bool["session_debug"] = make_tuple(&variables.session_debug, false); +#endif /* DEBUG */ + // variables with special variable == true + // the input validation for these variables MUST be EXPLICIT + VariablesPointers_bool["have_compress"] = make_tuple(&variables.have_compress, true); + VariablesPointers_bool["have_ssl"] = make_tuple(&variables.have_ssl, true); } @@ -2286,13 +2065,18 @@ char ** MySQL_Threads_Handler::get_variables_list() { VariablesPointers_int["throttle_max_bytes_per_second_to_client"] = make_tuple(&variables.throttle_max_bytes_per_second_to_client, 0, 2147483647, false); VariablesPointers_int["throttle_ratio_server_to_client"] = make_tuple(&variables.throttle_ratio_server_to_client, 0, 100, false); // backend management - VariablesPointers_int["default_max_latency_ms"] = make_tuple(&variables.default_max_latency_ms, 0, 20*24*3600*1000, false); - VariablesPointers_int["free_connections_pct"] = make_tuple(&variables.free_connections_pct, 0, 100, false); - VariablesPointers_int["reset_connection_algorithm"] = make_tuple(&variables.reset_connection_algorithm, 1, 2, false); - VariablesPointers_int["shun_on_failures"] = make_tuple(&variables.shun_on_failures, 0, 10000000, false); - VariablesPointers_int["shun_recovery_time_sec"] = make_tuple(&variables.shun_recovery_time_sec, 0, 3600*24*365, false); - VariablesPointers_int["hostgroup_manager_verbose"] = make_tuple(&variables.hostgroup_manager_verbose, 1, 2, false); - VariablesPointers_int["tcp_keepalive_time"] = make_tuple(&variables.tcp_keepalive_time, 0, 7200, false); + VariablesPointers_int["connpoll_reset_queue_length"] = make_tuple(&variables.connpoll_reset_queue_length, 0, 10000, false); + VariablesPointers_int["default_max_latency_ms"] = make_tuple(&variables.default_max_latency_ms, 0, 20*24*3600*1000, false); + VariablesPointers_int["free_connections_pct"] = make_tuple(&variables.free_connections_pct, 0, 100, false); + VariablesPointers_int["poll_timeout"] = make_tuple(&variables.poll_timeout, 10, 20000, false); + VariablesPointers_int["poll_timeout_on_failure"] = make_tuple(&variables.poll_timeout_on_failure, 10, 20000, false); + VariablesPointers_int["reset_connection_algorithm"] = make_tuple(&variables.reset_connection_algorithm, 1, 2, false); + VariablesPointers_int["shun_on_failures"] = make_tuple(&variables.shun_on_failures, 0, 10000000, false); + VariablesPointers_int["shun_recovery_time_sec"] = make_tuple(&variables.shun_recovery_time_sec, 0, 3600*24*365, false); + VariablesPointers_int["hostgroup_manager_verbose"] = make_tuple(&variables.hostgroup_manager_verbose, 1, 2, false); + VariablesPointers_int["tcp_keepalive_time"] = make_tuple(&variables.tcp_keepalive_time, 0, 7200, false); + VariablesPointers_int["min_num_servers_lantency_awareness"] = make_tuple(&variables.min_num_servers_lantency_awareness, 0, 10000, false); + VariablesPointers_int["aurora_max_lag_ms_only_read_from_replicas"] = make_tuple(&variables.aurora_max_lag_ms_only_read_from_replicas, 0, 100, false); // connection management VariablesPointers_int["connect_retries_on_failure"] = make_tuple(&variables.connect_retries_on_failure, 0, 1000, false); VariablesPointers_int["connect_retries_delay"] = make_tuple(&variables.connect_retries_delay, 0, 10000, false); @@ -2301,6 +2085,7 @@ char ** MySQL_Threads_Handler::get_variables_list() { VariablesPointers_int["connect_timeout_server_max"] = make_tuple(&variables.connect_timeout_server_max, 10, 3600*1000, false); VariablesPointers_int["connection_delay_multiplex_ms"] = make_tuple(&variables.connection_delay_multiplex_ms, 0, 300*1000, false); VariablesPointers_int["connection_max_age_ms"] = make_tuple(&variables.connection_max_age_ms, 0, 3600*24*1000, false); + VariablesPointers_int["handle_unknown_charset"] = make_tuple(&variables.handle_unknown_charset, 0, HANDLE_UNKNOWN_CHARSET__MAX_HANDLE_VALUE, false); VariablesPointers_int["ping_interval_server_msec"] = make_tuple(&variables.ping_interval_server_msec, 1000, 7*24*3600*1000, false); VariablesPointers_int["ping_timeout_server"] = make_tuple(&variables.ping_timeout_server, 10, 600*1000, false); // logs @@ -2316,10 +2101,23 @@ char ** MySQL_Threads_Handler::get_variables_list() { VariablesPointers_int["max_transaction_idle_time"] = make_tuple(&variables.max_transaction_idle_time, 1000, 20*24*3600*1000, false); VariablesPointers_int["max_transaction_time"] = make_tuple(&variables.max_transaction_time, 1000, 20*24*3600*1000, false); VariablesPointers_int["query_cache_size_MB"] = make_tuple(&variables.query_cache_size_MB, 0, 1024*10240, false); +#ifdef IDLE_THREADS + VariablesPointers_int["session_idle_ms"] = make_tuple(&variables.session_idle_ms, 1, 3600*1000, false); +#endif // IDLE_THREADS + VariablesPointers_int["show_processlist_extended"] = make_tuple(&variables.show_processlist_extended, 0, 2, false); VariablesPointers_int["threshold_query_length"] = make_tuple(&variables.threshold_query_length, 1024, 1*1024*1024*1024, false); VariablesPointers_int["threshold_resultset_size"] = make_tuple(&variables.threshold_resultset_size, 1024, 1*1024*1024*1024, false); + + // variables with special variable == true + // the input validation for these variables MUST be EXPLICIT + VariablesPointers_int["binlog_reader_connect_retry_msec"] = make_tuple(&variables.binlog_reader_connect_retry_msec, 0, 0, true); + VariablesPointers_int["eventslog_format"] = make_tuple(&variables.eventslog_format, 0, 0, true); + VariablesPointers_int["wait_timeout"] = make_tuple(&variables.wait_timeout, 0, 0, true); + + } + const size_t l=sizeof(mysql_thread_variables_names)/sizeof(char *); unsigned int i; size_t ltv = 0; @@ -3774,7 +3572,7 @@ void MySQL_Thread::refresh_variables() { if (mysql_thread___keep_multiplexing_variables) free(mysql_thread___keep_multiplexing_variables); mysql_thread___keep_multiplexing_variables=GloMTH->get_variable_string((char *)"keep_multiplexing_variables"); mysql_thread___server_capabilities=GloMTH->get_variable_uint16((char *)"server_capabilities"); - mysql_thread___handle_unknown_charset=GloMTH->get_variable_uint((char *)"handle_unknown_charset"); + mysql_thread___handle_unknown_charset=GloMTH->get_variable_int((char *)"handle_unknown_charset"); mysql_thread___poll_timeout=GloMTH->get_variable_int((char *)"poll_timeout"); mysql_thread___poll_timeout_on_failure=GloMTH->get_variable_int((char *)"poll_timeout_on_failure"); mysql_thread___have_compress=(bool)GloMTH->get_variable_int((char *)"have_compress"); From b446dc07184b0112645061220b2a9d03a053fd7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Sun, 16 May 2021 20:29:18 +0200 Subject: [PATCH 4/6] Changing query_cache_size_MB to lowercase --- lib/MySQL_Thread.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/MySQL_Thread.cpp b/lib/MySQL_Thread.cpp index 16139075f..d7da2d367 100644 --- a/lib/MySQL_Thread.cpp +++ b/lib/MySQL_Thread.cpp @@ -2100,7 +2100,7 @@ char ** MySQL_Threads_Handler::get_variables_list() { VariablesPointers_int["max_stmts_cache"] = make_tuple(&variables.max_stmts_cache, 1024, 1024*1024, false); VariablesPointers_int["max_transaction_idle_time"] = make_tuple(&variables.max_transaction_idle_time, 1000, 20*24*3600*1000, false); VariablesPointers_int["max_transaction_time"] = make_tuple(&variables.max_transaction_time, 1000, 20*24*3600*1000, false); - VariablesPointers_int["query_cache_size_MB"] = make_tuple(&variables.query_cache_size_MB, 0, 1024*10240, false); + VariablesPointers_int["query_cache_size_mb"] = make_tuple(&variables.query_cache_size_MB, 0, 1024*10240, false); #ifdef IDLE_THREADS VariablesPointers_int["session_idle_ms"] = make_tuple(&variables.session_idle_ms, 1, 3600*1000, false); #endif // IDLE_THREADS From d494f6f7b291ed17fb9e78a207a87c4619eddec1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Mon, 17 May 2021 12:12:50 +0200 Subject: [PATCH 5/6] Configure use_tcp_keepalive as bool in TAP test test_cluster_sync-t.cpp had incorrectly set use_tcp_keepalive as number instead of bool --- test/tap/tests/test_cluster_sync-t.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/tap/tests/test_cluster_sync-t.cpp b/test/tap/tests/test_cluster_sync-t.cpp index a42c5ce2a..d7a9ee9a3 100644 --- a/test/tap/tests/test_cluster_sync-t.cpp +++ b/test/tap/tests/test_cluster_sync-t.cpp @@ -975,7 +975,7 @@ int main(int, char**) { std::make_tuple("mysql-monitor_writer_is_also_reader" , "true" ), std::make_tuple("mysql-max_allowed_packet" , "67108864" ), std::make_tuple("mysql-tcp_keepalive_time" , "0" ), - std::make_tuple("mysql-use_tcp_keepalive" , "0" ), + std::make_tuple("mysql-use_tcp_keepalive" , "false" ), std::make_tuple("mysql-automatic_detect_sqli" , "0" ), std::make_tuple("mysql-firewall_whitelist_enabled" , "0" ), std::make_tuple("mysql-firewall_whitelist_errormsg" , "Firewall blocked this query"), From 218bfa873903cda345d885943f2b78d84b1fcbed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Mon, 17 May 2021 13:02:35 +0200 Subject: [PATCH 6/6] Setting some vars as bool in test_cluster_sync-t Some variables were incorrectly configured as integer and not boolean --- test/tap/tests/test_cluster_sync-t.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/tap/tests/test_cluster_sync-t.cpp b/test/tap/tests/test_cluster_sync-t.cpp index d7a9ee9a3..cf1f7bcd2 100644 --- a/test/tap/tests/test_cluster_sync-t.cpp +++ b/test/tap/tests/test_cluster_sync-t.cpp @@ -976,8 +976,8 @@ int main(int, char**) { std::make_tuple("mysql-max_allowed_packet" , "67108864" ), std::make_tuple("mysql-tcp_keepalive_time" , "0" ), std::make_tuple("mysql-use_tcp_keepalive" , "false" ), - std::make_tuple("mysql-automatic_detect_sqli" , "0" ), - std::make_tuple("mysql-firewall_whitelist_enabled" , "0" ), + std::make_tuple("mysql-automatic_detect_sqli" , "false" ), + std::make_tuple("mysql-firewall_whitelist_enabled" , "false" ), std::make_tuple("mysql-firewall_whitelist_errormsg" , "Firewall blocked this query"), std::make_tuple("mysql-throttle_connections_per_sec_to_hostgroup" , "1000001" ), std::make_tuple("mysql-max_transaction_time" , "14400001" ),