Skip to content

Commit

Permalink
Further improvement on SET parser #1528
Browse files Browse the repository at this point in the history
Support for SET NAMES + other variables
  • Loading branch information
renecannao committed Sep 28, 2018
1 parent 7249f00 commit 2e2b436
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/MySQL_Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,11 @@ bool MySQL_Session::handler_special_queries(PtrSize_t *pkt) {
pkt->ptr=pkt_2.ptr;
}
}
if ( (pkt->size < 100) && (pkt->size > 15) && (strncasecmp((char *)"SET NAMES ",(char *)pkt->ptr+5,10)==0) ) {
if (
(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
) {
char *unstripped=strndup((char *)pkt->ptr+15,pkt->size-15);
char *csname=trim_spaces_and_quotes_in_place(unstripped);
bool collation_specified = false;
Expand Down Expand Up @@ -3910,7 +3914,12 @@ bool MySQL_Session::handler___status_WAITING_CLIENT_DATA___STATE_SLEEP___MYSQL_C
}
}
}
if (match_regexes && (match_regexes[1]->match(dig) || match_regexes[2]->match(dig))) {
if (
(
match_regexes && (match_regexes[1]->match(dig) || match_regexes[2]->match(dig))
) ||
( strncasecmp(dig,(char *)"SET NAMES", strlen((char *)"SET NAMES")) == 0)
) {
proxy_debug(PROXY_DEBUG_MYSQL_COM, 5, "Parsing SET command %s\n", nq.c_str());
SetParser parser(nq);
std::map<std::string, std::vector<std::string>> set = parser.parse();
Expand Down

0 comments on commit 2e2b436

Please sign in to comment.