Skip to content

Commit

Permalink
add more debug mode ifdefs
Browse files Browse the repository at this point in the history
  • Loading branch information
mirostauder committed Oct 20, 2023
1 parent 69700d0 commit 076ca2e
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions lib/set_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ void SetParser::set_query(const std::string& nq) {
#define VAR_VALUE_P1 "(" VAR_VALUE_P1_1 VAR_VALUE_P1_2 VAR_VALUE_P1_3 VAR_VALUE_P1_4 VAR_VALUE_P1_5 VAR_VALUE_P1_6 ")"

std::map<std::string,std::vector<std::string>> SetParser::parse1() {

#ifdef DEBUG
proxy_debug(PROXY_DEBUG_MYSQL_QUERY_PROCESSOR, 4, "Parsing query %s\n", query.c_str());
#endif // DEBUG
re2::RE2::Options *opt2=new re2::RE2::Options(RE2::Quiet);
opt2->set_case_sensitive(false);
opt2->set_longest_match(false);
Expand All @@ -83,9 +84,13 @@ std::map<std::string,std::vector<std::string>> SetParser::parse1() {
std::map<std::string,std::vector<std::string>> result;

const std::string pattern="(?:" NAMES SPACES QUOTES NAME_VALUE QUOTES "(?: +COLLATE +" QUOTES NAME_VALUE QUOTES "|)" "|" SESSION_P1 VAR_P1 SPACES "(?:|:)=" SPACES QUOTES VAR_VALUE_P1 QUOTES ") *,? *";
#ifdef DEBUG
VALGRIND_DISABLE_ERROR_REPORTING;
#endif // DEBUG
re2::RE2 re(pattern, *opt2);
#ifdef DEBUG
VALGRIND_ENABLE_ERROR_REPORTING;
#endif // DEBUG
std::string var;
std::string value1, value2, value3, value4, value5;
re2::StringPiece input(query);
Expand Down Expand Up @@ -267,9 +272,10 @@ void SetParser::generateRE_parse1v2() {
var_value += s;
}
var_value += ")";


#ifdef DEBUG
proxy_debug(PROXY_DEBUG_MYSQL_QUERY_PROCESSOR, 4, "Parsing query %s\n", query.c_str());
#endif // DEBUG
parse1v2_opt2 = new re2::RE2::Options(RE2::Quiet);
parse1v2_opt2->set_case_sensitive(false);
parse1v2_opt2->set_longest_match(false);
Expand Down Expand Up @@ -317,7 +323,9 @@ void SetParser::generateRE_parse1v2() {
//const std::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 std::string pattern="(?:" NAMES SPACES + name_value + "(?: +COLLATE +" + name_value + "|)" "|" + var_1 + SPACES "(?:|:)=" SPACES + var_value + ") *,? *";
//const std::string pattern=var_1 + SPACES "(?:|:)=" SPACES + var_value;
#ifdef DEBUG
VALGRIND_DISABLE_ERROR_REPORTING;
#endif // DEBUG
#ifdef PARSERDEBUG
if (verbosity > 0) {
cout << pattern << endl;
Expand All @@ -339,7 +347,9 @@ std::map<std::string,std::vector<std::string>> SetParser::parse1v2() {

re2::RE2 re0("^\\s*SET\\s+", *parse1v2_opt2);
re2::RE2::Replace(&query, re0, "");
#ifdef DEBUG
VALGRIND_ENABLE_ERROR_REPORTING;
#endif // DEBUG
std::string var;
std::string value1, value2, value3, value4, value5;
re2::StringPiece input(query);
Expand Down Expand Up @@ -393,8 +403,9 @@ VALGRIND_ENABLE_ERROR_REPORTING;


std::map<std::string,std::vector<std::string>> SetParser::parse2() {

#ifdef DEBUG
proxy_debug(PROXY_DEBUG_MYSQL_QUERY_PROCESSOR, 4, "Parsing query %s\n", query.c_str());
#endif // DEBUG
re2::RE2::Options *opt2=new re2::RE2::Options(RE2::Quiet);
opt2->set_case_sensitive(false);
opt2->set_longest_match(false);
Expand Down Expand Up @@ -445,7 +456,9 @@ std::map<std::string,std::vector<std::string>> SetParser::parse2() {
}

std::string SetParser::parse_character_set() {
#ifdef DEBUG
proxy_debug(PROXY_DEBUG_MYSQL_QUERY_PROCESSOR, 4, "Parsing query %s\n", query.c_str());
#endif // DEBUG
re2::RE2::Options *opt2=new re2::RE2::Options(RE2::Quiet);
opt2->set_case_sensitive(false);
opt2->set_longest_match(false);
Expand Down

0 comments on commit 076ca2e

Please sign in to comment.