From 06d45796546d64e239891cfe65987c2abe21928b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Mon, 11 Sep 2023 16:49:43 +0000 Subject: [PATCH] More fixed on Set Parser 2 --- include/set_parser.h | 1 + lib/set_parser.cpp | 29 +++++++++++++++---- .../tests/test_filtered_set_statements-t.cpp | 2 +- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/include/set_parser.h b/include/set_parser.h index 36391d15a..542186834 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 bfd4cad02..fe61f91c0 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 fee2dee09..726050ac6 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" },