diff --git a/include/set_parser.h b/include/set_parser.h index 36391d15ae..5421868342 100644 --- a/include/set_parser.h +++ b/include/set_parser.h @@ -7,6 +7,7 @@ #include "re2/re2.h" #include "re2/regexp.h" +//#define PARSERDEBUG class SetParser { private: diff --git a/lib/set_parser.cpp b/lib/set_parser.cpp index bfd4cad027..fe61f91c0e 100644 --- a/lib/set_parser.cpp +++ b/lib/set_parser.cpp @@ -178,14 +178,30 @@ void SetParser::generateRE_parse1v2() { var_patterns.push_back(vp); //vp = "\\w+"; // single word //var_patterns.push_back(vp); - //vp = "(?:\\w|\\d)+"; // single word with letters and digits , for example utf8mb4 and latin1 + { + string vp0 = "(?:\\w|\\d)+"; // single word with letters and digits , for example utf8mb4 and latin1 //var_patterns.push_back(vp); - vp = "(?:\\w|\\d)+(?:-|\\w|\\d+)*"; // multiple words (letters and digits) separated by dash, WITHOUT any spaces between words . Used ialso for transaction isolation - var_patterns.push_back(vp); - for (auto it = quote_symbol.begin(); it != quote_symbol.end(); it++) { - string s = *it + vp + *it; - var_patterns.push_back(s); // add with quote +/* + string vp1 = "(?:" + vp0 + "(?:," + vp0 + ")*)"; // multiple words (letters and digits) separated by commas WITHOUT any spaces between words . Used also for sql_mode , example: ONLY_FULL_GROUP_BY,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO + //var_patterns.push_back(vp1); // do NOT add without quote + for (auto it = quote_symbol.begin(); it != quote_symbol.end(); it++) { + string s = *it + vp1 + *it; + var_patterns.push_back(s); // add with quote + } +*/ + string vp2 = "(?:" + vp0 + "(?:-" + vp0 + ")*)"; // multiple words (letters and digits) separated by dash, WITHOUT any spaces between words . Used also for transaction isolation + var_patterns.push_back(vp2); + for (auto it = quote_symbol.begin(); it != quote_symbol.end(); it++) { + string s = *it + vp2 + *it; + var_patterns.push_back(s); // add with quote + } } + //vp = "(?:\\w|\\d)+(?:-|\\w|\\d+)*"; // multiple words (letters and digits) separated by dash, WITHOUT any spaces between words . Used ialso for transaction isolation + //var_patterns.push_back(vp); +// for (auto it = quote_symbol.begin(); it != quote_symbol.end(); it++) { +// string s = *it + vp + *it; +// var_patterns.push_back(s); // add with quote +// } vp = "\\w+(?:,\\w+)+"; // multiple words separated by commas, WITHOUT any spaces between words // NOTE: we do not use multiple words without quotes @@ -365,6 +381,7 @@ VALGRIND_ENABLE_ERROR_REPORTING; } } else if (value4 != "") { // VARIABLE + remove_quotes(value4); if (strcasecmp("transaction_isolation", value4.c_str()) == 0) { value4 = "tx_isolation"; } else if (strcasecmp("transaction_read_only", value4.c_str()) == 0) { diff --git a/test/tap/tests/test_filtered_set_statements-t.cpp b/test/tap/tests/test_filtered_set_statements-t.cpp index fee2dee096..726050ac62 100644 --- a/test/tap/tests/test_filtered_set_statements-t.cpp +++ b/test/tap/tests/test_filtered_set_statements-t.cpp @@ -28,7 +28,7 @@ * TODO: Fill with all the statements that should be properly handled by ProxySQL. */ std::vector> filtered_set_queries { - { "sql_mode", "ONLY_FULL_GROUP_BY,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO" }, + { "sql_mode", "'ONLY_FULL_GROUP_BY,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO'" }, { "wait_timeout", "28801" }, { "character_set_results", "latin1" }, { "character_set_connection", "latin1" },