From 26235f9c5636cb85a88caf9365e58c624559b532 Mon Sep 17 00:00:00 2001 From: ethanblackburn Date: Mon, 15 Feb 2016 19:54:36 -0800 Subject: [PATCH 1/7] Add CHECKSUM command --- include/proxysql_admin.h | 5 +- lib/ProxySQL_Admin.cpp | 106 +++++++++++++++++++++++++++++++++++++++ lib/sqlite3db.cpp | 1 + 3 files changed, 110 insertions(+), 2 deletions(-) diff --git a/include/proxysql_admin.h b/include/proxysql_admin.h index c9b04fa6b..0ff17bc10 100644 --- a/include/proxysql_admin.h +++ b/include/proxysql_admin.h @@ -65,7 +65,6 @@ class ProxySQL_Admin { void flush_mysql_variables___runtime_to_database(SQLite3DB *db, bool replace, bool del, bool onlyifempty); void flush_mysql_variables___database_to_runtime(SQLite3DB *db, bool replace); - char **get_variables_list(); char *get_variable(char *name); bool set_variable(char *name, char *value); @@ -120,7 +119,9 @@ class ProxySQL_Admin { void load_mysql_variables_to_runtime() { flush_mysql_variables___database_to_runtime(admindb, true); } void save_mysql_variables_from_runtime() { flush_mysql_variables___runtime_to_database(admindb, true, true, false); } - + + char *table_checksum(char *tablename, char *source, char **err); + void stats___mysql_query_rules(); void stats___mysql_query_digests(); void stats___mysql_query_digests_reset(); diff --git a/lib/ProxySQL_Admin.cpp b/lib/ProxySQL_Admin.cpp index 0e6f89599..57b6870d2 100644 --- a/lib/ProxySQL_Admin.cpp +++ b/lib/ProxySQL_Admin.cpp @@ -1173,6 +1173,23 @@ SQLite3_result * ProxySQL_Admin::generate_show_table_status(const char *tablenam return result; } +char *parse_destination(char *query){ + char *method=(char *)"TO"; + char *pch=strstr(query, method); + if (pch){ + return pch+3; + } + return NULL; +} + +char *parse_source(char *query){ + char *method=(char *)"FROM"; + char *pch=strstr(query, method); + if (pch){ + return pch+5; + } + return NULL; +} void admin_session_handler(MySQL_Session *sess, ProxySQL_Admin *pa, PtrSize_t *pkt) { @@ -1339,6 +1356,29 @@ void admin_session_handler(MySQL_Session *sess, ProxySQL_Admin *pa, PtrSize_t *p } } + if(!strncasecmp("CHECKSUM TABLE ", query_no_space, 15)){ + proxy_debug(PROXYSQL_DEBUG_ADMIN, 4, "Received CHECKSUM command\n"); + char *source=parse_source(query_no_space); + char *tablename; + if (source){ + int tablename_length=query_no_space_length-strlen(source)-20; + tablename=(char *)malloc(tablename_length); + strncpy(tablename, query_no_space+15, tablename_length); + } else { + tablename=query_no_space+15; + } + char *error=NULL; + char *checksum_result=SPA->table_checksum(tablename, source, &error); + if (error) { + SPA->send_MySQL_ERR(&sess->client_myds->myprot, error); + } else { + char *q=(char *)"SELECT '%s' AS 'table', '%s' AS 'checksum'"; + query=(char *)malloc(strlen(q)+strlen(tablename)+strlen(checksum_result)+20); + sprintf(query,q,tablename,checksum_result); + goto __run_query; + } + } + if (strncasecmp("SHOW ", query_no_space, 5)) { goto __end_show_commands; // in the next block there are only SHOW commands } @@ -1547,6 +1587,7 @@ __run_query: SPA->statsdb->execute_statement(query, &error , &cols , &affected_rows , &resultset); SPA->statsdb->execute("PRAGMA query_only = OFF"); } + proxy_info("%s", query); sess->SQLite3_to_MySQL(resultset, error, affected_rows, &sess->client_myds->myprot); delete resultset; } @@ -2072,6 +2113,9 @@ bool ProxySQL_Admin::is_command(std::string s) { }; + + + void ProxySQL_Admin::dump_mysql_collations() { const CHARSET_INFO * c = compiled_charsets; char buf[1024]; @@ -2260,6 +2304,68 @@ void ProxySQL_Admin::flush_mysql_variables___runtime_to_database(SQLite3DB *db, free(varnames); } +char *ProxySQL_Admin::table_checksum(char *tablename, char *source, char **err){ + char *error=NULL; + int cols=0; + int affected_rows=0; + char *q1=(char *)"SELECT * FROM %s ORDER BY rowid"; + char *q2=(char *)malloc(strlen(q1)+strlen(tablename)); + SQLite3_result *resultset=NULL; + sprintf(q2, q1, tablename); + if (source && !strncasecmp(source,"DISK", 4)){ + configdb->execute_statement(q2, &error, &cols, &affected_rows, &resultset); + } else{ + admindb->execute_statement(q2, &error, &cols, &affected_rows, &resultset); + } + if (error) { + *err=strdup(error); + proxy_error("Error on %s: %s\n", q2, error); + free(error); + return (char *)"NULL"; + } else if (resultset->rows_count>0) { + int tot_l=0; + int tot_s=0; + char *large_buff[resultset->rows_count]; + int column_length=resultset->columns; + for (std::vector::iterator it = resultset->rows.begin() ; it != resultset->rows.end(); ++it) { + SQLite3_row *r=*it; + char *buffs[column_length]; + int local_s=0; + for (int i=0; ifields[i]){ + int l=strlen(r->fields[i]); + local_s+=l; + buffs[i]=(char *)malloc(strlen(r->fields[i])+1); + strncpy(buffs[i], r->fields[i], strlen(r->fields[i])); + } else { + buffs[i]=(char *)""; + local_s+=1; + } + } + large_buff[tot_l]=(char *)malloc(local_s+1); + for (int i=0; i Date: Mon, 15 Feb 2016 20:00:44 -0800 Subject: [PATCH 2/7] Remove old code --- include/proxysql_admin.h | 2 +- lib/ProxySQL_Admin.cpp | 5 ----- lib/sqlite3db.cpp | 1 - 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/include/proxysql_admin.h b/include/proxysql_admin.h index 0ff17bc10..c9552ebaf 100644 --- a/include/proxysql_admin.h +++ b/include/proxysql_admin.h @@ -65,6 +65,7 @@ class ProxySQL_Admin { void flush_mysql_variables___runtime_to_database(SQLite3DB *db, bool replace, bool del, bool onlyifempty); void flush_mysql_variables___database_to_runtime(SQLite3DB *db, bool replace); + char **get_variables_list(); char *get_variable(char *name); bool set_variable(char *name, char *value); @@ -118,7 +119,6 @@ class ProxySQL_Admin { void load_mysql_variables_to_runtime() { flush_mysql_variables___database_to_runtime(admindb, true); } void save_mysql_variables_from_runtime() { flush_mysql_variables___runtime_to_database(admindb, true, true, false); } - char *table_checksum(char *tablename, char *source, char **err); diff --git a/lib/ProxySQL_Admin.cpp b/lib/ProxySQL_Admin.cpp index 57b6870d2..f9f3778ff 100644 --- a/lib/ProxySQL_Admin.cpp +++ b/lib/ProxySQL_Admin.cpp @@ -1587,7 +1587,6 @@ __run_query: SPA->statsdb->execute_statement(query, &error , &cols , &affected_rows , &resultset); SPA->statsdb->execute("PRAGMA query_only = OFF"); } - proxy_info("%s", query); sess->SQLite3_to_MySQL(resultset, error, affected_rows, &sess->client_myds->myprot); delete resultset; } @@ -2112,10 +2111,6 @@ bool ProxySQL_Admin::is_command(std::string s) { return true; }; - - - - void ProxySQL_Admin::dump_mysql_collations() { const CHARSET_INFO * c = compiled_charsets; char buf[1024]; diff --git a/lib/sqlite3db.cpp b/lib/sqlite3db.cpp index 4b11db180..630c75d48 100644 --- a/lib/sqlite3db.cpp +++ b/lib/sqlite3db.cpp @@ -63,7 +63,6 @@ bool SQLite3DB::execute_statement(const char *str, char **error, int *cols, int sqlite3_stmt *statement; *error=NULL; bool ret=false; - proxy_info("executing: %s\n", str); if(sqlite3_prepare_v2(db, str, -1, &statement, 0) != SQLITE_OK) { *error=strdup(sqlite3_errmsg(db)); goto __exit_execute_statement; From d91ed1d46799c3f196f2af2d90ba4a8ced4fa75b Mon Sep 17 00:00:00 2001 From: ethanblackburn Date: Mon, 15 Feb 2016 20:02:18 -0800 Subject: [PATCH 3/7] add line --- lib/ProxySQL_Admin.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/ProxySQL_Admin.cpp b/lib/ProxySQL_Admin.cpp index f9f3778ff..9df34fb75 100644 --- a/lib/ProxySQL_Admin.cpp +++ b/lib/ProxySQL_Admin.cpp @@ -2111,6 +2111,7 @@ bool ProxySQL_Admin::is_command(std::string s) { return true; }; + void ProxySQL_Admin::dump_mysql_collations() { const CHARSET_INFO * c = compiled_charsets; char buf[1024]; From 2ab4833498048b8a0d705718fea8aaf728b4a5a6 Mon Sep 17 00:00:00 2001 From: ethanblackburn Date: Wed, 24 Feb 2016 08:12:40 -0800 Subject: [PATCH 4/7] Add checksum function to SQLite3_result --- include/proxysql_admin.h | 2 - include/sqlite3db.h | 7 +- lib/ProxySQL_Admin.cpp | 178 ++++++++++++++++++--------------------- lib/sqlite3db.cpp | 31 +++++++ 4 files changed, 118 insertions(+), 100 deletions(-) diff --git a/include/proxysql_admin.h b/include/proxysql_admin.h index c9552ebaf..7489e46e3 100644 --- a/include/proxysql_admin.h +++ b/include/proxysql_admin.h @@ -120,8 +120,6 @@ class ProxySQL_Admin { void load_mysql_variables_to_runtime() { flush_mysql_variables___database_to_runtime(admindb, true); } void save_mysql_variables_from_runtime() { flush_mysql_variables___runtime_to_database(admindb, true, true, false); } - char *table_checksum(char *tablename, char *source, char **err); - void stats___mysql_query_rules(); void stats___mysql_query_digests(); void stats___mysql_query_digests_reset(); diff --git a/include/sqlite3db.h b/include/sqlite3db.h index 7f82297a9..8d8c3aab6 100644 --- a/include/sqlite3db.h +++ b/include/sqlite3db.h @@ -3,8 +3,6 @@ #include "proxysql.h" #include "cpp.h" - - //struct _sqlite3row_t { //}; @@ -85,11 +83,15 @@ class SQLite3_result { public: int columns; int rows_count; + char *checksum(); + int64_t raw_checksum(); + std::vector column_definition; std::vector rows; 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); @@ -111,6 +113,7 @@ 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 9df34fb75..a5f32e208 100644 --- a/lib/ProxySQL_Admin.cpp +++ b/lib/ProxySQL_Admin.cpp @@ -1116,6 +1116,7 @@ SQLite3_result * ProxySQL_Admin::generate_show_table_status(const char *tablenam *err=strdup(error); free(error); if (resultset) delete resultset; + free(tn); return NULL; } @@ -1173,24 +1174,6 @@ SQLite3_result * ProxySQL_Admin::generate_show_table_status(const char *tablenam return result; } -char *parse_destination(char *query){ - char *method=(char *)"TO"; - char *pch=strstr(query, method); - if (pch){ - return pch+3; - } - return NULL; -} - -char *parse_source(char *query){ - char *method=(char *)"FROM"; - char *pch=strstr(query, method); - if (pch){ - return pch+5; - } - return NULL; -} - void admin_session_handler(MySQL_Session *sess, ProxySQL_Admin *pa, PtrSize_t *pkt) { char *error=NULL; @@ -1356,27 +1339,92 @@ void admin_session_handler(MySQL_Session *sess, ProxySQL_Admin *pa, PtrSize_t *p } } - if(!strncasecmp("CHECKSUM TABLE ", query_no_space, 15)){ + if(!strncasecmp("CHECKSUM ", query_no_space, 9)){ proxy_debug(PROXYSQL_DEBUG_ADMIN, 4, "Received CHECKSUM command\n"); - char *source=parse_source(query_no_space); - char *tablename; - if (source){ - int tablename_length=query_no_space_length-strlen(source)-20; - tablename=(char *)malloc(tablename_length); - strncpy(tablename, query_no_space+15, tablename_length); - } else { - tablename=query_no_space+15; - } + ProxySQL_Admin *SPA=(ProxySQL_Admin *)pa; + SQLite3_result *resultset=NULL; + char *tablename=NULL; char *error=NULL; - char *checksum_result=SPA->table_checksum(tablename, source, &error); + int affected_rows=0; + int cols=0; + if (strlen(query_no_space)==strlen("CHECKSUM DISK MYSQL SERVERS") && !strncasecmp("CHECKSUM DISK MYSQL SERVERS", query_no_space, strlen(query_no_space))){ + char *q=(char *)"SELECT * FROM mysql_servers ORDER BY hostgroup_id, hostname, port"; + tablename=(char *)"MYSQL SERVERS"; + SPA->configdb->execute_statement(q, &error, &cols, &affected_rows, &resultset); + } + + if (strlen(query_no_space)==strlen("CHECKSUM DISK MYSQL USERS") && !strncasecmp("CHECKSUM DISK MYSQL USERS", query_no_space, strlen(query_no_space))){ + char *q=(char *)"SELECT * FROM mysql_users ORDER BY username"; + tablename=(char *)"MYSQL USERS"; + SPA->configdb->execute_statement(q, &error, &cols, &affected_rows, &resultset); + } + + if (strlen(query_no_space)==strlen("CHECKSUM DISK MYSQL QUERY RULES") && !strncasecmp("CHECKSUM DISK MYSQL QUERY RULES", query_no_space, strlen(query_no_space))){ + char *q=(char *)"SELECT * FROM mysql_query_rules ORDER BY rule_id"; + tablename=(char *)"MYSQL QUERY RULES"; + SPA->configdb->execute_statement(q, &error, &cols, &affected_rows, &resultset); + } + + 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"; + tablename=(char *)"MYSQL VARIABLES"; + 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))) + || + (strlen(query_no_space)==strlen("CHECKSUM MYSQL SERVERS") && !strncasecmp("CHECKSUM MYSQL SERVERS", query_no_space, strlen(query_no_space)))){ + char *q=(char *)"SELECT * FROM mysql_servers ORDER BY hostgroup_id, hostname, port"; + tablename=(char *)"MYSQL SERVERS"; + SPA->admindb->execute_statement(q, &error, &cols, &affected_rows, &resultset); + } + + if ((strlen(query_no_space)==strlen("CHECKSUM MEMORY MYSQL USERS") && !strncasecmp("CHECKSUM MEMORY MYSQL USERS", query_no_space, strlen(query_no_space))) + || + (strlen(query_no_space)==strlen("CHECKSUM MEM MYSQL USERS") && !strncasecmp("CHECKSUM MEM MYSQL USERS", query_no_space, strlen(query_no_space))) + || + (strlen(query_no_space)==strlen("CHECKSUM MYSQL USERS") && !strncasecmp("CHECKSUM MYSQL USERS", query_no_space, strlen(query_no_space)))){ + char *q=(char *)"SELECT * FROM mysql_users ORDER BY username"; + tablename=(char *)"MYSQL USERS"; + SPA->admindb->execute_statement(q, &error, &cols, &affected_rows, &resultset); + } + + if ((strlen(query_no_space)==strlen("CHECKSUM MEMORY MYSQL QUERY RULES") && !strncasecmp("CHECKSUM MEMORY MYSQL QUERY RULES", query_no_space, strlen(query_no_space))) + || + (strlen(query_no_space)==strlen("CHECKSUM MEM MYSQL QUERY RULES") && !strncasecmp("CHECKSUM MEM MYSQL QUERY RULES", query_no_space, strlen(query_no_space))) + || + (strlen(query_no_space)==strlen("CHECKSUM MYSQL QUERY RULES") && !strncasecmp("CHECKSUM MYSQL QUERY RULES", query_no_space, strlen(query_no_space)))){ + char *q=(char *)"SELECT * FROM mysql_query_rules ORDER BY rule_id"; + tablename=(char *)"MYSQL QUERY RULES"; + SPA->admindb->execute_statement(q, &error, &cols, &affected_rows, &resultset); + } + + if ((strlen(query_no_space)==strlen("CHECKSUM MEMORY MYSQL VARIABLES") && !strncasecmp("CHECKSUM MEMORY MYSQL VARIABLES", query_no_space, strlen(query_no_space))) + || + (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"; + tablename=(char *)"MYSQL VARIABLES"; + SPA->admindb->execute_statement(q, &error, &cols, &affected_rows, &resultset); + } + if (error) { - SPA->send_MySQL_ERR(&sess->client_myds->myprot, error); - } else { + proxy_error("Error: %s\n", error); + char buf[1024]; + sprintf(buf,"%s", error); + SPA->send_MySQL_ERR(&sess->client_myds->myprot, buf); + run_query=false; + } else if (resultset) { char *q=(char *)"SELECT '%s' AS 'table', '%s' AS 'checksum'"; - query=(char *)malloc(strlen(q)+strlen(tablename)+strlen(checksum_result)+20); - sprintf(query,q,tablename,checksum_result); - goto __run_query; + char *checksum=(char *)resultset->checksum(); + query=(char *)malloc(strlen(q)+strlen(tablename)+strlen(checksum)+1); + sprintf(query,q,tablename,checksum); } + goto __run_query; } if (strncasecmp("SHOW ", query_no_space, 5)) { @@ -2300,68 +2348,6 @@ void ProxySQL_Admin::flush_mysql_variables___runtime_to_database(SQLite3DB *db, free(varnames); } -char *ProxySQL_Admin::table_checksum(char *tablename, char *source, char **err){ - char *error=NULL; - int cols=0; - int affected_rows=0; - char *q1=(char *)"SELECT * FROM %s ORDER BY rowid"; - char *q2=(char *)malloc(strlen(q1)+strlen(tablename)); - SQLite3_result *resultset=NULL; - sprintf(q2, q1, tablename); - if (source && !strncasecmp(source,"DISK", 4)){ - configdb->execute_statement(q2, &error, &cols, &affected_rows, &resultset); - } else{ - admindb->execute_statement(q2, &error, &cols, &affected_rows, &resultset); - } - if (error) { - *err=strdup(error); - proxy_error("Error on %s: %s\n", q2, error); - free(error); - return (char *)"NULL"; - } else if (resultset->rows_count>0) { - int tot_l=0; - int tot_s=0; - char *large_buff[resultset->rows_count]; - int column_length=resultset->columns; - for (std::vector::iterator it = resultset->rows.begin() ; it != resultset->rows.end(); ++it) { - SQLite3_row *r=*it; - char *buffs[column_length]; - int local_s=0; - for (int i=0; ifields[i]){ - int l=strlen(r->fields[i]); - local_s+=l; - buffs[i]=(char *)malloc(strlen(r->fields[i])+1); - strncpy(buffs[i], r->fields[i], strlen(r->fields[i])); - } else { - buffs[i]=(char *)""; - local_s+=1; - } - } - large_buff[tot_l]=(char *)malloc(local_s+1); - for (int i=0; irows_count==0) return 0; + uint64_t hash1, hash2; + SpookyHash myhash; + myhash.Init(19,3); + + for (std::vector::iterator it=rows.begin() ; it!=rows.end(); ++it) { + SQLite3_row *r=*it; + for (int i=0; ifields[i]) { + myhash.Update(r->fields[i],r->sizes[i]); + } else { + myhash.Update("",0); + } + } + } + myhash.Final(&hash1, &hash2); + return hash1; +} + + +char *SQLite3_result::checksum() { + uint64_t hash1=raw_checksum(); + char buf[128]; + uint32_t d32[2]; + memcpy(&d32,&hash1,sizeof(hash1)); + sprintf(buf,"0x%X%X", d32[0], d32[1]); + return strdup(buf); +} From 5885e5f5c2c72d4998f44e9ae9f4e48553db454f Mon Sep 17 00:00:00 2001 From: ethanblackburn Date: Wed, 24 Feb 2016 08:49:49 -0800 Subject: [PATCH 5/7] 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]; From bf9b8f7510ef014922a5f057c962d6b2bd393861 Mon Sep 17 00:00:00 2001 From: ethanblackburn Date: Wed, 24 Feb 2016 08:51:48 -0800 Subject: [PATCH 6/7] whitespaces --- include/proxysql_admin.h | 1 + lib/ProxySQL_Admin.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/include/proxysql_admin.h b/include/proxysql_admin.h index 7489e46e3..746a4f8a8 100644 --- a/include/proxysql_admin.h +++ b/include/proxysql_admin.h @@ -119,6 +119,7 @@ class ProxySQL_Admin { void load_mysql_variables_to_runtime() { flush_mysql_variables___database_to_runtime(admindb, true); } void save_mysql_variables_from_runtime() { flush_mysql_variables___runtime_to_database(admindb, true, true, false); } + void stats___mysql_query_rules(); void stats___mysql_query_digests(); diff --git a/lib/ProxySQL_Admin.cpp b/lib/ProxySQL_Admin.cpp index 368aa9f2c..30ec79d82 100644 --- a/lib/ProxySQL_Admin.cpp +++ b/lib/ProxySQL_Admin.cpp @@ -1173,6 +1173,7 @@ SQLite3_result * ProxySQL_Admin::generate_show_table_status(const char *tablenam return result; } + void admin_session_handler(MySQL_Session *sess, ProxySQL_Admin *pa, PtrSize_t *pkt) { char *error=NULL; From d3f3dbaed80bd782cca653b902634f0ba870365f Mon Sep 17 00:00:00 2001 From: ethanblackburn Date: Wed, 24 Feb 2016 08:52:27 -0800 Subject: [PATCH 7/7] more whitespace --- include/proxysql_admin.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/proxysql_admin.h b/include/proxysql_admin.h index 746a4f8a8..c9b04fa6b 100644 --- a/include/proxysql_admin.h +++ b/include/proxysql_admin.h @@ -120,7 +120,7 @@ class ProxySQL_Admin { void load_mysql_variables_to_runtime() { flush_mysql_variables___database_to_runtime(admindb, true); } void save_mysql_variables_from_runtime() { flush_mysql_variables___runtime_to_database(admindb, true, true, false); } - + void stats___mysql_query_rules(); void stats___mysql_query_digests(); void stats___mysql_query_digests_reset();