diff --git a/lib/MySQL_Logger.cpp b/lib/MySQL_Logger.cpp index 56261a137..b3f05e7a2 100644 --- a/lib/MySQL_Logger.cpp +++ b/lib/MySQL_Logger.cpp @@ -1367,14 +1367,14 @@ int MySQL_Logger::processEvents(SQLite3DB * statsdb , SQLite3DB * statsdb_disk) delete event; } size_t ret = events.size(); -#if 1 // FIXME: TEMPORARY , TO REMOVE +#if 0 std::cerr << "Circular:" << endl; std::cerr << " EventsAddedCount: " << MyLogCB->getEventsAddedCount() << endl; std::cerr << " EventsDroppedCount: " << MyLogCB->getEventsDroppedCount() << endl; std::cerr << " Size: " << MyLogCB->size() << endl; std::cerr << "memoryCopy: Count: " << metrics.memoryCopyCount << " , TimeUs: " << metrics.totalMemoryCopyTimeMicros << endl; std::cerr << "diskCopy: Count: " << metrics.diskCopyCount << " , TimeUs: " << metrics.totalDiskCopyTimeMicros << endl; -#endif // 1 , FIXME: TEMPORARY , TO REMOVE +#endif // 0 return ret; } diff --git a/lib/ProxySQL_Admin.cpp b/lib/ProxySQL_Admin.cpp index 9b1e59bf9..ce9d09d53 100644 --- a/lib/ProxySQL_Admin.cpp +++ b/lib/ProxySQL_Admin.cpp @@ -9932,6 +9932,17 @@ void ProxySQL_Admin::stats___mysql_global() { statsdb->execute(query); free(query); } + if (GloMyLogger != nullptr) { + const string prefix = "MySQL_Logger-"; + std::unordered_map metrics = GloMyLogger->getAllMetrics(); + for (std::unordered_map::iterator it = metrics.begin(); it != metrics.end(); it++) { + unsigned int l = strlen(a) + prefix.length() + it->first.length() + 32; + char *query = (char *)malloc(l); + sprintf(query, a, string(prefix + it->first).c_str(),std::to_string(it->second).c_str()); + statsdb->execute(query); + free(query); + } + } statsdb->execute("COMMIT"); } diff --git a/test/tap/tests/test_empty_schemaname-t.cpp b/test/tap/tests/test_empty_schemaname-t.cpp new file mode 100644 index 000000000..72c814738 --- /dev/null +++ b/test/tap/tests/test_empty_schemaname-t.cpp @@ -0,0 +1,73 @@ +/** + * @file test_empty_schemaname-t.cpp + * @brief Simple test checking that empty schemaname are properly handled by ProxySQL. + */ + +#include "mysql.h" +#include "tap.h" +#include "command_line.h" +#include "utils.h" + +uint32_t EXECUTIONS = 1000; + +int main(int argc, char** argv) { + plan(1); + + CommandLine cl; + + if (cl.getEnv()) { + diag("Failed to get the required environmental variables."); + return EXIT_FAILURE; + } + + for (uint32_t i = 0; i < EXECUTIONS; i++) { + { + MYSQL* proxy = mysql_init(NULL); + + if (!mysql_real_connect(proxy, cl.host, "sbtest", "sbtest", "sbtest", cl.port, NULL, 0)) { + fprintf(stderr, "File %s, line %d, Error: %s\n", __FILE__, __LINE__, mysql_error(proxy)); + return EXIT_FAILURE; + } + mysql_query(proxy, "DO 1"); + mysql_query(proxy, "USE ``"); + mysql_query(proxy, "USE `` "); + mysql_query(proxy, "USE `` "); + mysql_query(proxy, "DO 1"); +/* + mysql_close(proxy); + } + + { + MYSQL* proxy = mysql_init(NULL); + + if (!mysql_real_connect(proxy, cl.host, "sbtest", "sbtest", "` `", cl.port, NULL, 0)) { + fprintf(stderr, "File %s, line %d, Error: %s\n", __FILE__, __LINE__, mysql_error(proxy)); + return EXIT_FAILURE; + } + mysql_query(proxy, "DO 1"); +*/ + mysql_close(proxy); + } + } +/* + int exp_myerr = 1065; + int act_myerr = 0; + + for (uint32_t i = 0; i < EXECUTIONS; i++) { + mysql_query(proxy, ""); + act_myerr = mysql_errno(proxy); + + if (exp_myerr != act_myerr) { + break; + } + } + + ok( + exp_myerr == act_myerr, "MySQL error equals expected - exp_err: '%d', act_err: '%d' error: `%s`", + exp_myerr, act_myerr, mysql_error(proxy) + ); +*/ + //mysql_close(proxy); + + return exit_status(); +}