Adding some comments and a quick exit on handler_special_queries for locked_on_hostgroup

pull/3451/head
René Cannaò 5 years ago committed by Javier Jaramago Fernández
parent 8be7e52e61
commit dc10bee4d5

@ -1179,7 +1179,15 @@ bool MySQL_Session::handler_special_queries(PtrSize_t *pkt) {
l_free(pkt->size,pkt->ptr);
return true;
}
if ((locked_on_hostgroup == -1) && (pkt->size < 60) && (pkt->size > 38) && (strncasecmp((char *)"SET SESSION character_set_server",(char *)pkt->ptr+5,32)==0) ) { // issue #601
if (locked_on_hostgroup >= 0 && (strncasecmp((char *)"SET ",(char *)pkt->ptr+5,33)==4)) {
// this is a circuit breaker, we will send everything to the backend
//
// also note that in the current implementation we stop tracking variables:
// this becomes a problem if mysql-set_query_lock_on_hostgroup is
// disabled while a session is already locked
return false;
}
if ((pkt->size < 60) && (pkt->size > 38) && (strncasecmp((char *)"SET SESSION character_set_server",(char *)pkt->ptr+5,32)==0) ) { // issue #601
char *idx=NULL;
char *p=(char *)pkt->ptr+37;
idx=(char *)memchr(p,'=',pkt->size-37);
@ -1199,7 +1207,7 @@ bool MySQL_Session::handler_special_queries(PtrSize_t *pkt) {
pkt->ptr=pkt_2.ptr;
}
}
if ((locked_on_hostgroup == -1) && (pkt->size < 60) && (pkt->size > 39) && (strncasecmp((char *)"SET SESSION character_set_results",(char *)pkt->ptr+5,33)==0) ) { // like the above
if ((pkt->size < 60) && (pkt->size > 39) && (strncasecmp((char *)"SET SESSION character_set_results",(char *)pkt->ptr+5,33)==0) ) { // like the above
char *idx=NULL;
char *p=(char *)pkt->ptr+38;
idx=(char *)memchr(p,'=',pkt->size-38);
@ -1220,7 +1228,7 @@ bool MySQL_Session::handler_special_queries(PtrSize_t *pkt) {
}
}
if (
(locked_on_hostgroup == -1) && (pkt->size < 100) && (pkt->size > 15) && (strncasecmp((char *)"SET NAMES ",(char *)pkt->ptr+5,10)==0)
(pkt->size < 100) && (pkt->size > 15) && (strncasecmp((char *)"SET NAMES ",(char *)pkt->ptr+5,10)==0)
&&
(memchr((const void *)((char *)pkt->ptr+5),',',pkt->size-15)==NULL) // there is no comma
) {
@ -2310,7 +2318,7 @@ bool MySQL_Session::handler_again___status_SETTING_GENERIC_VARIABLE(int *_rc, co
q=(char *)"SET %s=%s";
if (strncasecmp(var_value,(char *)"REPLACE",7)==0)
q=(char *)"SET %s=%s";
if (var_value[0] && var_value[0]=='(') {
if (var_value[0] && var_value[0]=='(') { // the value is a subquery
q=(char *)"SET %s=%s";
}
}

@ -3,6 +3,8 @@
* @brief This test verifies that after locking on a hostgroup, ProxySQL forwards
* several simple special queries in a proper way, forwarding them to the backend
* connection.
* Note: queries have hostgroup=0 to avoid getting lock on hostgroup 0 and
* attempting to run queries on hostgroup 1
*/
#include <cstring>

@ -3,6 +3,7 @@
* @brief Test file for unit testing 'SetParser' type, responsible of parsing
* non-trivial 'SET' statements. This test is executed via the wrapper tap test
* 'setparser_test-t'.
* This file is an extension of ../../set_parser_test/setparsertest.cpp
*/
#include "re2/re2.h"

Loading…
Cancel
Save