diff --git a/include/MySQL_Thread.h b/include/MySQL_Thread.h index 7b5ab51be..415ec4c24 100644 --- a/include/MySQL_Thread.h +++ b/include/MySQL_Thread.h @@ -328,6 +328,7 @@ class MySQL_Threads_Handler bool client_found_rows; bool multiplexing; // bool stmt_multiplexing; + bool forward_autocommit; bool enforce_autocommit_on_reads; int max_allowed_packet; int max_transaction_time; diff --git a/include/proxysql_structs.h b/include/proxysql_structs.h index bd9dd2e9c..8a3b52af7 100644 --- a/include/proxysql_structs.h +++ b/include/proxysql_structs.h @@ -814,6 +814,7 @@ __thread bool mysql_thread___have_compress; __thread bool mysql_thread___client_found_rows; __thread bool mysql_thread___multiplexing; // __thread bool mysql_thread___stmt_multiplexing; +__thread bool mysql_thread___forward_autocommit; __thread bool mysql_thread___enforce_autocommit_on_reads; __thread bool mysql_thread___servers_stats; __thread bool mysql_thread___commands_stats; @@ -904,6 +905,7 @@ 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___stmt_multiplexing; +extern __thread bool mysql_thread___forward_autocommit; extern __thread bool mysql_thread___enforce_autocommit_on_reads; extern __thread bool mysql_thread___servers_stats; extern __thread bool mysql_thread___commands_stats; diff --git a/lib/MySQL_Session.cpp b/lib/MySQL_Session.cpp index 3ab7807ca..4b2942c7c 100644 --- a/lib/MySQL_Session.cpp +++ b/lib/MySQL_Session.cpp @@ -525,13 +525,14 @@ __ret_autocommit_OK: bool MySQL_Session::handler_special_queries(PtrSize_t *pkt) { - if (handler_SetAutocommit(pkt) == true) { - return true; - } - if (handler_CommitRollback(pkt) == true) { - return true; + if (mysql_thread___forward_autocommit == false) { + if (handler_SetAutocommit(pkt) == true) { + return true; + } + if (handler_CommitRollback(pkt) == true) { + return true; + } } - if (pkt->size>(5+4) && strncmp((char *)"USE ",(char *)pkt->ptr+5,4)==0) { handler___status_WAITING_CLIENT_DATA___STATE_SLEEP___MYSQL_COM_QUERY_USE_DB(pkt); return true; diff --git a/lib/MySQL_Thread.cpp b/lib/MySQL_Thread.cpp index 5c5c64fc3..3543d8229 100644 --- a/lib/MySQL_Thread.cpp +++ b/lib/MySQL_Thread.cpp @@ -237,6 +237,7 @@ static char * mysql_thread_variables_names[]= { (char *)"max_transaction_time", (char *)"multiplexing", // (char *)"stmt_multiplexing", + (char *)"forward_autocommit", (char *)"enforce_autocommit_on_reads", (char *)"threshold_query_length", (char *)"threshold_resultset_size", @@ -358,6 +359,7 @@ MySQL_Threads_Handler::MySQL_Threads_Handler() { variables.commands_stats=true; variables.multiplexing=true; // variables.stmt_multiplexing=false; + variables.forward_autocommit=false; variables.enforce_autocommit_on_reads=false; variables.query_digests=true; variables.query_digests_lowercase=false; @@ -580,6 +582,7 @@ int MySQL_Threads_Handler::get_variable_int(char *name) { if (!strcasecmp(name,"client_found_rows")) return (int)variables.client_found_rows; if (!strcasecmp(name,"multiplexing")) return (int)variables.multiplexing; // if (!strcasecmp(name,"stmt_multiplexing")) return (int)variables.stmt_multiplexing; + if (!strcasecmp(name,"forward_autocommit")) return (int)variables.forward_autocommit; 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; @@ -861,6 +864,9 @@ char * MySQL_Threads_Handler::get_variable(char *name) { // this is the public f // if (!strcasecmp(name,"stmt_multiplexing")) { // return strdup((variables.stmt_multiplexing ? "true" : "false")); // } + if (!strcasecmp(name,"forward_autocommit")) { + return strdup((variables.forward_autocommit ? "true" : "false")); + } if (!strcasecmp(name,"enforce_autocommit_on_reads")) { return strdup((variables.enforce_autocommit_on_reads ? "true" : "false")); } @@ -1526,6 +1532,17 @@ bool MySQL_Threads_Handler::set_variable(char *name, char *value) { // this is t // } // return false; // } + if (!strcasecmp(name,"forward_autocommit")) { + if (strcasecmp(value,"true")==0 || strcasecmp(value,"1")==0) { + variables.forward_autocommit=true; + return true; + } + if (strcasecmp(value,"false")==0 || strcasecmp(value,"0")==0) { + variables.forward_autocommit=false; + return true; + } + return false; + } if (!strcasecmp(name,"enforce_autocommit_on_reads")) { if (strcasecmp(value,"true")==0 || strcasecmp(value,"1")==0) { variables.enforce_autocommit_on_reads=true; @@ -2810,6 +2827,7 @@ void MySQL_Thread::refresh_variables() { 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___stmt_multiplexing=(bool)GloMTH->get_variable_int((char *)"stmt_multiplexing"); + mysql_thread___forward_autocommit=(bool)GloMTH->get_variable_int((char *)"forward_autocommit"); 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");