From 5885e5f5c2c72d4998f44e9ae9f4e48553db454f Mon Sep 17 00:00:00 2001 From: ethanblackburn Date: Wed, 24 Feb 2016 08:49:49 -0800 Subject: [PATCH] Add checksum mysql replication hostgroups command --- include/sqlite3db.h | 4 ++-- lib/ProxySQL_Admin.cpp | 22 +++++++++++++++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/include/sqlite3db.h b/include/sqlite3db.h index 8d8c3aab6..67a9f584b 100644 --- a/include/sqlite3db.h +++ b/include/sqlite3db.h @@ -3,6 +3,8 @@ #include "proxysql.h" #include "cpp.h" + + //struct _sqlite3row_t { //}; @@ -91,7 +93,6 @@ class SQLite3_result { SQLite3_result() { columns=0; }; - void add_column_definition(int a, const char *b) { SQLite3_column *cf=new SQLite3_column(a,b); column_definition.push_back(cf); @@ -113,7 +114,6 @@ class SQLite3_result { rows_count++; return SQLITE_ROW; }; - SQLite3_result(sqlite3_stmt *stmt) { rows_count=0; columns=sqlite3_column_count(stmt); diff --git a/lib/ProxySQL_Admin.cpp b/lib/ProxySQL_Admin.cpp index a5f32e208..368aa9f2c 100644 --- a/lib/ProxySQL_Admin.cpp +++ b/lib/ProxySQL_Admin.cpp @@ -1116,7 +1116,6 @@ SQLite3_result * ProxySQL_Admin::generate_show_table_status(const char *tablenam *err=strdup(error); free(error); if (resultset) delete resultset; - free(tn); return NULL; } @@ -1366,12 +1365,19 @@ void admin_session_handler(MySQL_Session *sess, ProxySQL_Admin *pa, PtrSize_t *p } if (strlen(query_no_space)==strlen("CHECKSUM DISK MYSQL VARIABLES") && !strncasecmp("CHECKSUM DISK MYSQL VARIABLES", query_no_space, strlen(query_no_space))){ - char *q=(char *)"SELECT * FROM global_variables ORDER BY variable_name"; + char *q=(char *)"SELECT * FROM global_variables WHERE variable_name LIKE 'mysql-%' ORDER BY variable_name"; tablename=(char *)"MYSQL VARIABLES"; SPA->configdb->execute_statement(q, &error, &cols, &affected_rows, &resultset); } + if (strlen(query_no_space)==strlen("CHECKSUM DISK MYSQL REPLICATION HOSTGROUPS") && !strncasecmp("CHECKSUM DISK MYSQL REPLICATION HOSTGROUPS", query_no_space, strlen(query_no_space))){ + char *q=(char *)"SELECT * FROM mysql_replication_hostgroups ORDER BY writer_hostgroup"; + tablename=(char *)"MYSQL REPLICATION HOSTGROUPS"; + SPA->configdb->execute_statement(q, &error, &cols, &affected_rows, &resultset); + + } + if ((strlen(query_no_space)==strlen("CHECKSUM MEMORY MYSQL SERVERS") && !strncasecmp("CHECKSUM MEMORY MYSQL SERVERS", query_no_space, strlen(query_no_space))) || (strlen(query_no_space)==strlen("CHECKSUM MEM MYSQL SERVERS") && !strncasecmp("CHECKSUM MEM MYSQL SERVERS", query_no_space, strlen(query_no_space))) @@ -1407,11 +1413,21 @@ void admin_session_handler(MySQL_Session *sess, ProxySQL_Admin *pa, PtrSize_t *p (strlen(query_no_space)==strlen("CHECKSUM MEM MYSQL VARIABLES") && !strncasecmp("CHECKSUM MEM MYSQL VARIABLES", query_no_space, strlen(query_no_space))) || (strlen(query_no_space)==strlen("CHECKSUM MYSQL VARIABLES") && !strncasecmp("CHECKSUM MYSQL VARIABLES", query_no_space, strlen(query_no_space)))){ - char *q=(char *)"SELECT * FROM global_variables ORDER BY variable_name"; + char *q=(char *)"SELECT * FROM global_variables WHERE variable_name LIKE 'mysql-%' ORDER BY variable_name"; tablename=(char *)"MYSQL VARIABLES"; SPA->admindb->execute_statement(q, &error, &cols, &affected_rows, &resultset); } + if ((strlen(query_no_space)==strlen("CHECKSUM MEMORY MYSQL REPLICATION HOSTGROUPS") && !strncasecmp("CHECKSUM MEMORY MYSQL REPLICATION HOSTGROUPS", query_no_space, strlen(query_no_space))) + || + (strlen(query_no_space)==strlen("CHECKSUM MEM MYSQL REPLICATION HOSTGROUPS") && !strncasecmp("CHECKSUM MEM MYSQL REPLICATION HOSTGROUPS", query_no_space, strlen(query_no_space))) + || + (strlen(query_no_space)==strlen("CHECKSUM MYSQL REPLICATION HOSTGROUPS") && !strncasecmp("CHECKSUM MYSQL REPLICATION HOSTGROUPS", query_no_space, strlen(query_no_space)))){ + char *q=(char *)"SELECT * FROM mysql_replication_hostgroups ORDER BY writer_hostgroup"; + tablename=(char *)"MYSQL REPLICATION HOSTGROUPS"; + SPA->admindb->execute_statement(q, &error, &cols, &affected_rows, &resultset); + } + if (error) { proxy_error("Error: %s\n", error); char buf[1024];