Skip to content

Commit

Permalink
Add variable client_multi_statements to address sysown#1074
Browse files Browse the repository at this point in the history
See comments in Github issue. Once applied, this change
allows the user to toggle the 'client_multi_statements'
flag as a global variable.
  • Loading branch information
stantona authored and pondix committed May 7, 2018
1 parent 689ab0c commit e370e17
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/MySQL_Thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ class MySQL_Threads_Handler
int shun_on_failures;
int shun_recovery_time_sec;
int query_retries_on_failure;
bool client_multi_statements;
int connect_retries_on_failure;
int connect_retries_delay;
int connection_delay_multiplex_ms;
Expand Down
2 changes: 2 additions & 0 deletions include/proxysql_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,7 @@ __thread int mysql_thread___ping_timeout_server;
__thread int mysql_thread___shun_on_failures;
__thread int mysql_thread___shun_recovery_time_sec;
__thread int mysql_thread___query_retries_on_failure;
__thread bool mysql_thread___client_multi_statements;
__thread int mysql_thread___connect_retries_on_failure;
__thread int mysql_thread___connect_retries_delay;
__thread int mysql_thread___connection_delay_multiplex_ms;
Expand Down Expand Up @@ -724,6 +725,7 @@ extern __thread int mysql_thread___ping_timeout_server;
extern __thread int mysql_thread___shun_on_failures;
extern __thread int mysql_thread___shun_recovery_time_sec;
extern __thread int mysql_thread___query_retries_on_failure;
extern __thread bool mysql_thread___client_multi_statements;
extern __thread int mysql_thread___connect_retries_on_failure;
extern __thread int mysql_thread___connect_retries_delay;
extern __thread int mysql_thread___connection_delay_multiplex_ms;
Expand Down
18 changes: 18 additions & 0 deletions lib/MySQL_Thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ static char * mysql_thread_variables_names[]= {
(char *)"shun_on_failures",
(char *)"shun_recovery_time_sec",
(char *)"query_retries_on_failure",
(char *)"client_multi_statements",
(char *)"connect_retries_on_failure",
(char *)"connect_retries_delay",
(char *)"connection_delay_multiplex_ms",
Expand Down Expand Up @@ -342,6 +343,7 @@ MySQL_Threads_Handler::MySQL_Threads_Handler() {
variables.shun_on_failures=5;
variables.shun_recovery_time_sec=10;
variables.query_retries_on_failure=1;
variables.client_multi_statements=true;
variables.connect_retries_on_failure=10;
variables.connection_delay_multiplex_ms=0;
variables.connection_max_age_ms=0;
Expand Down Expand Up @@ -694,6 +696,7 @@ int MySQL_Threads_Handler::get_variable_int(char *name) {
if (!strcasecmp(name,"poll_timeout")) return variables.poll_timeout;
if (!strcasecmp(name,"poll_timeout_on_failure")) return variables.poll_timeout_on_failure;
if (!strcasecmp(name,"stacksize")) return ( stacksize ? stacksize : DEFAULT_STACK_SIZE);
if (!strcasecmp(name,"client_multi_statements")) return (int)variables.client_multi_statements;
proxy_error("Not existing variable: %s\n", name); assert(0);
return 0;
}
Expand Down Expand Up @@ -859,6 +862,9 @@ char * MySQL_Threads_Handler::get_variable(char *name) { // this is the public f
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);
Expand Down Expand Up @@ -1637,6 +1643,17 @@ bool MySQL_Threads_Handler::set_variable(char *name, char *value) { // this is t
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) {
Expand Down Expand Up @@ -3381,6 +3398,7 @@ void MySQL_Thread::refresh_variables() {
mysql_thread___shun_recovery_time_sec=GloMTH->get_variable_int((char *)"shun_recovery_time_sec");
mysql_thread___query_retries_on_failure=GloMTH->get_variable_int((char *)"query_retries_on_failure");
mysql_thread___connect_retries_on_failure=GloMTH->get_variable_int((char *)"connect_retries_on_failure");
mysql_thread___client_multi_statements=(bool)GloMTH->get_variable_int((char *)"client_multi_statements");
mysql_thread___connection_delay_multiplex_ms=GloMTH->get_variable_int((char *)"connection_delay_multiplex_ms");
mysql_thread___connection_max_age_ms=GloMTH->get_variable_int((char *)"connection_max_age_ms");
mysql_thread___connect_timeout_server=GloMTH->get_variable_int((char *)"connect_timeout_server");
Expand Down
3 changes: 2 additions & 1 deletion lib/mysql_connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,8 @@ void MySQL_Connection::connect_start() {
client_flags += CLIENT_FOUND_ROWS;
if (parent->compression)
client_flags += CLIENT_COMPRESS;
client_flags += CLIENT_MULTI_STATEMENTS; // FIXME: add global variable
if (mysql_thread___client_multi_statements)
client_flags += CLIENT_MULTI_STATEMENTS;
char *auth_password=NULL;
if (userinfo->password) {
if (userinfo->password[0]=='*') { // we don't have the real password, let's pass sha1
Expand Down

0 comments on commit e370e17

Please sign in to comment.