Attempt to fix some valgrind errors

pull/2895/head
René Cannaò 6 years ago
parent ec1f234094
commit 7ffe8209e6

@ -24,11 +24,11 @@ SetParser::SetParser(std::string nq) {
std::map<std::string,std::vector<string>> SetParser::parse1() {
proxy_debug(PROXY_DEBUG_MYSQL_QUERY_PROCESSOR, 4, "Parsing query %s\n", query.c_str());
re2::RE2::Options *opt2=new re2::RE2::Options(RE2::Quiet);
opt2->set_case_sensitive(false);
opt2->set_longest_match(false);
re2::RE2::Options opt2 = re2::RE2::Options(RE2::Quiet);
opt2.set_case_sensitive(false);
opt2.set_longest_match(false);
re2::RE2 re0("^\\s*SET\\s+", *opt2);
re2::RE2 re0("^\\s*SET\\s+", opt2);
re2::RE2::Replace(&query, re0, "");
std::map<std::string,std::vector<string>> result;
@ -40,7 +40,7 @@ std::map<std::string,std::vector<string>> SetParser::parse1() {
#define VAR_VALUE_P1 "(((?:CONCAT\\()*(?:((?: )*REPLACE|IFNULL|CONCAT)\\()+(?: )*(?:NULL|@OLD_SQL_MODE|@@sql_mode),(?:(?:'|\\w|,| |\"|\\))+(?:\\))*)|(?:[@\\w/\\d:\\+\\-]|,)+|(?:)))"
const string pattern="(?:" NAMES SPACES QUOTES NAME_VALUE QUOTES "(?: +COLLATE +" QUOTES NAME_VALUE QUOTES "|)" "|" SESSION_P1 VAR_P1 SPACES "(?:|:)=" SPACES QUOTES VAR_VALUE_P1 QUOTES ") *,? *";
re2::RE2 re(pattern, *opt2);
re2::RE2 re(pattern, opt2);
string var;
string value1, value2, value3, value4, value5;
re2::StringPiece input(query);
@ -67,7 +67,6 @@ std::map<std::string,std::vector<string>> SetParser::parse1() {
std::transform(key.begin(), key.end(), key.begin(), ::tolower);
result[key] = op;
}
delete opt2;
return result;
}
@ -75,11 +74,11 @@ std::map<std::string,std::vector<string>> SetParser::parse1() {
std::map<std::string,std::vector<string>> SetParser::parse2() {
proxy_debug(PROXY_DEBUG_MYSQL_QUERY_PROCESSOR, 4, "Parsing query %s\n", query.c_str());
re2::RE2::Options *opt2=new re2::RE2::Options(RE2::Quiet);
opt2->set_case_sensitive(false);
opt2->set_longest_match(false);
re2::RE2::Options opt2 = re2::RE2::Options(RE2::Quiet);
opt2.set_case_sensitive(false);
opt2.set_longest_match(false);
re2::RE2 re0("^\\s*SET\\s+", *opt2);
re2::RE2 re0("^\\s*SET\\s+", opt2);
re2::RE2::Replace(&query, re0, "");
std::map<std::string,std::vector<string>> result;
@ -95,7 +94,7 @@ std::map<std::string,std::vector<string>> SetParser::parse2() {
*/
//const string pattern="(?:" NAMES SPACES QUOTES NAME_VALUE QUOTES "(?: +COLLATE +" QUOTES NAME_VALUE QUOTES "|)" "|" SESSION_P1 VAR_P1 SPACES "(?:|:)=" SPACES QUOTES VAR_VALUE_P1 QUOTES ") *,? *";
const string pattern="(|SESSION) *TRANSACTION(?: +)(?:(?:(ISOLATION(?: +)LEVEL)(?: +)(REPEATABLE(?: +)READ|READ(?: +)COMMITTED|READ(?: +)UNCOMMITTED|SERIALIZABLE))|(?:(READ)(?: +)(WRITE|ONLY)))";
re2::RE2 re(pattern, *opt2);
re2::RE2 re(pattern, opt2);
string var;
string value1, value2, value3, value4, value5;
re2::StringPiece input(query);
@ -120,29 +119,27 @@ std::map<std::string,std::vector<string>> SetParser::parse2() {
result[key] = op;
}
delete opt2;
return result;
}
std::string SetParser::parse_character_set() {
proxy_debug(PROXY_DEBUG_MYSQL_QUERY_PROCESSOR, 4, "Parsing query %s\n", query.c_str());
re2::RE2::Options *opt2=new re2::RE2::Options(RE2::Quiet);
opt2->set_case_sensitive(false);
opt2->set_longest_match(false);
re2::RE2::Options opt2 = re2::RE2::Options(RE2::Quiet);
opt2.set_case_sensitive(false);
opt2.set_longest_match(false);
re2::RE2 re0("^\\s*SET\\s+", *opt2);
re2::RE2 re0("^\\s*SET\\s+", opt2);
re2::RE2::Replace(&query, re0, "");
std::map<std::string,std::vector<string>> result;
const string pattern="((charset)|(character +set))(?: )(\\S+)";
re2::RE2 re(pattern, *opt2);
re2::RE2 re(pattern, opt2);
string var;
string value1, value2, value3, value4;
re2::StringPiece input(query);
re2::RE2::Consume(&input, re, &value1, &value2, &value3, &value4);
delete opt2;
return value4;
}

Loading…
Cancel
Save