From 83759f0df10147d61614007b7fca4cdde13ddf12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Mon, 12 Jun 2023 09:23:25 +0000 Subject: [PATCH] Fix compiling of fwd_eof_ok_query Also added several debugging information --- .../deprecate_eof_support/Makefile | 2 +- .../deprecate_eof_cache-t.cpp | 19 +++++++++++++++---- .../deprecate_eof_support/fwd_eof_query.cpp | 8 +++++--- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/test/tap/tests_with_deps/deprecate_eof_support/Makefile b/test/tap/tests_with_deps/deprecate_eof_support/Makefile index d03e7823a..6c94014fc 100644 --- a/test/tap/tests_with_deps/deprecate_eof_support/Makefile +++ b/test/tap/tests_with_deps/deprecate_eof_support/Makefile @@ -67,7 +67,7 @@ fwd_eof_query: fwd_eof_query.cpp $(TESTS_DEPS) # NOTE: Compilation with 'libmysql' instead of 'libmariadb' client to confirm packet sequence id isn't check by 'libmariadb' fwd_eof_ok_query: fwd_eof_query.cpp $(TAP_LIBDIR)/libtap.a - $(CXX) -DDEBUG fwd_eof_query.cpp $(OPT) -std=c++11 -I$(JSON_IDIR) -I$(TAP_LIBDIR) -I$(INCLUDEDIRS) -L$(TAP_LIBDIR) -L$(TAP_DEPS_LIBS) -L/usr/lib/x86_64-linux-gnu/ -lmysqlclient -ltap -ldl -o fwd_eof_ok_query -DGITVERSION=\"$(GIT_VERSION)\" + $(CXX) -DDEBUG fwd_eof_query.cpp $(OPT) -std=c++11 -I$(JSON_IDIR) -I$(TAP_LIBDIR) -I /usr/include/mysql/ -I$(IDIR) -L$(TAP_LIBDIR) -L$(TAP_DEPS_LIBS) -L/usr/lib/x86_64-linux-gnu/ -lmysqlclient -ltap -ldl -o fwd_eof_ok_query -DGITVERSION=\"$(GIT_VERSION)\" deprecate_eof_cache-t: deprecate_eof_cache-t.cpp $(TESTS_DEPS) $(CXX) -DDEBUG deprecate_eof_cache-t.cpp $(OPT) -std=c++11 -I$(JSON_IDIR) -I$(TAP_LIBDIR) -I$(INCLUDEDIRS) -L$(TAP_LIBDIR) -L$(TAP_DEPS_LIBS) -L$(MARIADB_TEST_DEP)/libmariadb -L$(SSL_LDIR) -L$(PROXYLDIR) -ltap $(MYLIBS) -lproxysql -ldl -o deprecate_eof_cache-t -DGITVERSION=\"$(GIT_VERSION)\" diff --git a/test/tap/tests_with_deps/deprecate_eof_support/deprecate_eof_cache-t.cpp b/test/tap/tests_with_deps/deprecate_eof_support/deprecate_eof_cache-t.cpp index 7e9a1a9b4..66c4e8b8c 100644 --- a/test/tap/tests_with_deps/deprecate_eof_support/deprecate_eof_cache-t.cpp +++ b/test/tap/tests_with_deps/deprecate_eof_support/deprecate_eof_cache-t.cpp @@ -54,6 +54,14 @@ std::vector queries { int main(int argc, char** argv) { CommandLine cl; + uint32_t c_operations = 50; + to_opts_t opts { 10000*1000, 100*1000, 500*1000, 2000*1000 }; + + unsigned int p = 1; // create table + p += c_operations; // inserts + p += c_operations*12; // 12 tests each time + plan(p); + if (cl.getEnv()) { diag("Failed to get the required environmental variables."); return -1; @@ -90,7 +98,6 @@ int main(int argc, char** argv) { return exit_status(); } - uint32_t c_operations = 50; vector> stored_pairs {}; // INSERT the required data for exercising the cache @@ -142,12 +149,14 @@ int main(int argc, char** argv) { std::string select_query {}; string_format(t_select_query, select_query, id); - to_opts_t opts { 10000*1000, 100*1000, 500*1000, 2000*1000 }; + std::string binary = ""; // Query *without* support for EOF deprecation + binary = "fwd_eof_query"; + diag("Calling %s%s with query: %s", cl.workdir, binary.c_str(), select_query.c_str()); auto eof_query = [&] (std::string& query_res, std::string& eof_query_err) -> int { int exec_res = wexecvp( - std::string(cl.workdir) + "fwd_eof_query", + std::string(cl.workdir) + binary, { select_query.c_str() }, opts, query_res, @@ -158,9 +167,11 @@ int main(int argc, char** argv) { }; // Query *with* support for EOF deprecation + binary = "fwd_eof_ok_query"; + diag("Calling %s%s with query: %s", cl.workdir, binary.c_str(), select_query.c_str()); auto ok_query = [&] (std::string& query_res, std::string& ok_query_err) -> int { int exec_res = wexecvp( - std::string(cl.workdir) + "fwd_eof_ok_query", + std::string(cl.workdir) + binary, { select_query.c_str() }, opts, query_res, diff --git a/test/tap/tests_with_deps/deprecate_eof_support/fwd_eof_query.cpp b/test/tap/tests_with_deps/deprecate_eof_support/fwd_eof_query.cpp index 1c8b61613..faf18c859 100644 --- a/test/tap/tests_with_deps/deprecate_eof_support/fwd_eof_query.cpp +++ b/test/tap/tests_with_deps/deprecate_eof_support/fwd_eof_query.cpp @@ -112,14 +112,14 @@ int main(int argc, char** argv) { */ if (!mysql_real_connect(proxy, cl.host, cl.username, cl.password, NULL, cl.port, NULL, 0)) { - std::string err_msg { "MySQL Error:" + std::string { mysql_error(proxy) }+ "" }; + std::string err_msg { "MySQL Error:" + std::string { mysql_error(proxy) } + " at line " + std::to_string(__LINE__) }; std::cerr << "{ \"Code\": \"Err\", \"Result\": \"" << err_msg << "\" }"; return -1; } int query_res = mysql_query(proxy, query.c_str()); if (query_res != 0) { - std::string err_msg { "MySQL Error:" + std::string { mysql_error(proxy) }+ "" }; + std::string err_msg { "MySQL Error:" + std::string { mysql_error(proxy) } + " at line " + std::to_string(__LINE__) }; std::cerr << "{ \"Code\": \"Err\", \"Result\": \"" << err_msg << "\" }"; return -1; } @@ -132,7 +132,9 @@ int main(int argc, char** argv) { MySQL_result_to_JSON(select_res, j_res); std::cout << "{ \"Code\": \"OK\", \"Result\": " << j_res.dump() << ", \"Status\": " << proxy->server_status - << ", \"Warnings\": " << mysql_warning_count(proxy) << " }"; + << ", \"Warnings\": " << mysql_warning_count(proxy) + << ", \"Line\": " << __LINE__ + << " }"; } else { std::string err_msg { "MySQL Error: " + std::string { mysql_error(proxy) }+ ""