Add variable client_multi_statements to address #1074

See comments in Github issue. Once applied, this change
allows the user to toggle the 'client_multi_statements'
flag as a global variable.
pull/1495/head
Adam Stanton 8 years ago committed by Nikolaos Vyzas
parent 689ab0c294
commit e370e1781d

@ -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;

@ -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;
@ -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;

@ -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",
@ -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;
@ -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;
}
@ -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);
@ -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) {
@ -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");

@ -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

Loading…
Cancel
Save