Add get_current_query_rules_fast_routing_count()

Query_Processor::get_current_query_rules_fast_routing_count() now allows to
quickly execute this query is ran on Admin:
SELECT COUNT(*) FROM runtime_mysql_query_rules_fast_routing
pull/3305/head
René Cannaò 5 years ago
parent ca10cf0631
commit f7bb4d201b

@ -335,6 +335,7 @@ class Query_Processor {
SQLite3_result * fast_routing_resultset;
void load_fast_routing(SQLite3_result *resultset);
SQLite3_result * get_current_query_rules_fast_routing();
int get_current_query_rules_fast_routing_count();
int testing___find_HG_in_mysql_query_rules_fast_routing(char *username, char *schemaname, int flagIN);
int testing___find_HG_in_mysql_query_rules_fast_routing_dual(char *username, char *schemaname, int flagIN);

@ -3621,6 +3621,20 @@ void admin_session_handler(MySQL_Session *sess, void *_pa, PtrSize_t *pkt) {
}
}
}
// if the client simply executes:
// SELECT COUNT(*) FROM runtime_mysql_query_rules_fast_routing
// we just return the count
if (strcmp("SELECT COUNT(*) FROM runtime_mysql_query_rules_fast_routing", query_no_space)==0) {
int cnt = GloQPro->get_current_query_rules_fast_routing_count();
l_free(query_length,query);
char buf[256];
sprintf(buf,"SELECT %d AS 'COUNT(*)'", cnt);
query=l_strdup(buf);
query_length=strlen(query)+1;
goto __run_query;
}
if (!strncasecmp("TRUNCATE ", query_no_space, strlen("TRUNCATE "))) {
if (sess->session_type == PROXYSQL_SESSION_ADMIN) { // no stats
if (strstr(query_no_space,"stats_mysql_query_digest")) {

@ -840,6 +840,14 @@ SQLite3_result * Query_Processor::get_current_query_rules() {
return result;
}
int Query_Processor::get_current_query_rules_fast_routing_count() {
int result = 0;
pthread_rwlock_rdlock(&rwlock);
result = fast_routing_resultset->rows_count;
pthread_rwlock_unlock(&rwlock);
return result;
}
SQLite3_result * Query_Processor::get_current_query_rules_fast_routing() {
proxy_debug(PROXY_DEBUG_MYSQL_QUERY_PROCESSOR, 4, "Dumping current query rules fast_routing, using Global version %d\n", version);
SQLite3_result *result=new SQLite3_result(5);

Loading…
Cancel
Save