diff --git a/include/MySQL_Thread.h b/include/MySQL_Thread.h index 2ff679cd1..6b03e243f 100644 --- a/include/MySQL_Thread.h +++ b/include/MySQL_Thread.h @@ -283,6 +283,7 @@ class MySQL_Threads_Handler bool have_compress; bool client_found_rows; bool multiplexing; + bool enforce_autocommit_on_reads; int max_transaction_time; int threshold_query_length; int threshold_resultset_size; diff --git a/include/proxysql_structs.h b/include/proxysql_structs.h index a8f916b4a..448fc6591 100644 --- a/include/proxysql_structs.h +++ b/include/proxysql_structs.h @@ -712,6 +712,7 @@ __thread int mysql_thread___poll_timeout_on_failure; __thread bool mysql_thread___have_compress; __thread bool mysql_thread___client_found_rows; __thread bool mysql_thread___multiplexing; +__thread bool mysql_thread___enforce_autocommit_on_reads; __thread bool mysql_thread___servers_stats; __thread bool mysql_thread___commands_stats; __thread bool mysql_thread___query_digests; @@ -776,6 +777,7 @@ extern __thread int mysql_thread___poll_timeout_on_failure; extern __thread bool mysql_thread___have_compress; extern __thread bool mysql_thread___client_found_rows; extern __thread bool mysql_thread___multiplexing; +extern __thread bool mysql_thread___enforce_autocommit_on_reads; extern __thread bool mysql_thread___servers_stats; extern __thread bool mysql_thread___commands_stats; extern __thread bool mysql_thread___query_digests; diff --git a/lib/MySQL_Thread.cpp b/lib/MySQL_Thread.cpp index ddb222da3..29f5e7713 100644 --- a/lib/MySQL_Thread.cpp +++ b/lib/MySQL_Thread.cpp @@ -167,6 +167,7 @@ static char * mysql_thread_variables_names[]= { (char *)"monitor_writer_is_also_reader", (char *)"max_transaction_time", (char *)"multiplexing", + (char *)"enforce_autocommit_on_reads", (char *)"threshold_query_length", (char *)"threshold_resultset_size", (char *)"wait_timeout", @@ -256,6 +257,7 @@ MySQL_Threads_Handler::MySQL_Threads_Handler() { variables.client_found_rows=true; variables.commands_stats=true; variables.multiplexing=true; + variables.enforce_autocommit_on_reads=false; variables.query_digests=true; variables.sessions_sort=true; variables.servers_stats=true; @@ -403,6 +405,7 @@ int MySQL_Threads_Handler::get_variable_int(char *name) { if (!strcasecmp(name,"have_compress")) return (int)variables.have_compress; if (!strcasecmp(name,"client_found_rows")) return (int)variables.client_found_rows; if (!strcasecmp(name,"multiplexing")) return (int)variables.multiplexing; + if (!strcasecmp(name,"enforce_autocommit_on_reads")) return (int)variables.enforce_autocommit_on_reads; if (!strcasecmp(name,"commands_stats")) return (int)variables.commands_stats; if (!strcasecmp(name,"query_digests")) return (int)variables.query_digests; if (!strcasecmp(name,"sessions_sort")) return (int)variables.sessions_sort; @@ -594,6 +597,9 @@ char * MySQL_Threads_Handler::get_variable(char *name) { // this is the public f if (!strcasecmp(name,"multiplexing")) { return strdup((variables.multiplexing ? "true" : "false")); } + if (!strcasecmp(name,"enforce_autocommit_on_reads")) { + return strdup((variables.enforce_autocommit_on_reads ? "true" : "false")); + } if (!strcasecmp(name,"commands_stats")) { return strdup((variables.commands_stats ? "true" : "false")); } @@ -1088,6 +1094,17 @@ bool MySQL_Threads_Handler::set_variable(char *name, char *value) { // this is t } return false; } + if (!strcasecmp(name,"enforce_autocommit_on_reads")) { + if (strcasecmp(value,"true")==0 || strcasecmp(value,"1")==0) { + variables.enforce_autocommit_on_reads=true; + return true; + } + if (strcasecmp(value,"false")==0 || strcasecmp(value,"0")==0) { + variables.enforce_autocommit_on_reads=false; + return true; + } + return false; + } if (!strcasecmp(name,"commands_stats")) { if (strcasecmp(value,"true")==0 || strcasecmp(value,"1")==0) { variables.commands_stats=true; @@ -1801,6 +1818,7 @@ void MySQL_Thread::refresh_variables() { mysql_thread___have_compress=(bool)GloMTH->get_variable_int((char *)"have_compress"); mysql_thread___client_found_rows=(bool)GloMTH->get_variable_int((char *)"client_found_rows"); mysql_thread___multiplexing=(bool)GloMTH->get_variable_int((char *)"multiplexing"); + mysql_thread___enforce_autocommit_on_reads=(bool)GloMTH->get_variable_int((char *)"enforce_autocommit_on_reads"); mysql_thread___commands_stats=(bool)GloMTH->get_variable_int((char *)"commands_stats"); mysql_thread___query_digests=(bool)GloMTH->get_variable_int((char *)"query_digests"); mysql_thread___sessions_sort=(bool)GloMTH->get_variable_int((char *)"sessions_sort");