diff --git a/include/proxysql_utils.h b/include/proxysql_utils.h index 77c21d3f1..ffe3fe1bb 100644 --- a/include/proxysql_utils.h +++ b/include/proxysql_utils.h @@ -211,33 +211,6 @@ std::string generate_multi_rows_query(int rows, int params); void close_all_non_term_fd(std::vector excludeFDs); -/** - * @brief Suggested implementation of 'mismatch_' from ['cppreference'](https://en.cppreference.com/w/cpp/algorithm/mismatch). - * - * @param first1 begin of the first range of the elements. - * @param last1 end of the first range of the elements. - * @param first2 begin of the second range of the elements. - * @param last2 end of the second range of the elements. - * @param p binary predicate which returns `true` if the elements should be treated as equal. - * - * @return std::pair with iterators to the first two non-equal elements. - */ -template -std::pair mismatch_( - InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, BinaryPredicate p -) { - while (first1 != last1 && first2 != last2 && p(*first1, *first2)) { - ++first1, ++first2; - } - return std::make_pair(first1, first2); -} - -/** - * @brief Returns a sorted copy in ascending order of the supplied version numbers. - * @details Expected version numbers formats are: ['N', 'N.N', 'N.N.N', ...] - */ -std::vector sort_versions(std::vector versions); - /** * @brief Returns the expected error for query 'SELECT $$'. * @param version The 'server_version' for which the error should match. diff --git a/lib/proxysql_utils.cpp b/lib/proxysql_utils.cpp index a4c3e25c3..34ae6e5e3 100644 --- a/lib/proxysql_utils.cpp +++ b/lib/proxysql_utils.cpp @@ -433,29 +433,6 @@ void close_all_non_term_fd(std::vector excludeFDs) { } } -vector sort_versions(vector versions) { - std::sort( - versions.begin(), versions.end(), - [](const string& v1, const string& v2) { - const auto result = - mismatch_( - v1.cbegin(), v1.cend(), v2.cbegin(), v2.cend(), - [](const unsigned char lhs, const unsigned char rhs) { - return tolower(lhs) == tolower(rhs); - } - ); - - const bool not_equal = result.second != v2.cend(); - const bool fst_shorter = result.first == v1.cend(); - const bool fst_lesser = std::tolower(*result.first) < std::tolower(*result.second); - - return not_equal && (fst_shorter || fst_lesser); - } - ); - - return versions; -} - std::pair get_dollar_quote_error(const char* version) { const char* ER_PARSE_MSG { "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server" @@ -465,9 +442,7 @@ std::pair get_dollar_quote_error(const char* version) { if (strcasecmp(version,"8.1.0") == 0) { return { ER_PARSE_ERROR, ER_PARSE_MSG }; } else { - const vector sorted { sort_versions({"8.1.0", version}) }; - - if (sorted[0] == "8.1.0") { + if (strncasecmp(version, "8.1", 3) == 0) { // SQLSTATE: 42000 return { ER_PARSE_ERROR, ER_PARSE_MSG }; } else { diff --git a/test/tap/tests/reg_test_4300-dollar_quote_check-t.cpp b/test/tap/tests/reg_test_4300-dollar_quote_check-t.cpp index 2b2c95826..72ecc5b70 100644 --- a/test/tap/tests/reg_test_4300-dollar_quote_check-t.cpp +++ b/test/tap/tests/reg_test_4300-dollar_quote_check-t.cpp @@ -25,7 +25,7 @@ using std::vector; using std::string; -const vector versions { "5.6", "5.7", "8.0", "8.1.0", "8.1", "8.2" }; +const vector versions { "5.6", "5.7", "8.0", "8.1.0", "8.1", "8.1.4" }; int test_supports_dollar_quote(MYSQL* conn, int v_idx, int v8_1_0_idx) { int rc = mysql_query_t(conn, "SELECT $$");