Make PROXYSLQTEST 22 and 24 return the number of row affected

pull/4096/head
Javier Sánchez Parra 3 years ago
parent ba41bad72c
commit 2c13dfdc52

@ -418,11 +418,11 @@ class ProxySQL_Admin {
void p_update_metrics();
void stats___mysql_query_rules();
void stats___save_mysql_query_digest_to_sqlite(
int stats___save_mysql_query_digest_to_sqlite(
const bool reset, const bool copy, const SQLite3_result *resultset,
const umap_query_digest *digest_umap, const umap_query_digest_text *digest_text_umap
);
void stats___mysql_query_digests(bool reset, bool copy=false);
int stats___mysql_query_digests(bool reset, bool copy=false);
//void stats___mysql_query_digests_reset();
void stats___mysql_commands_counters();
void stats___mysql_processlist();

@ -323,8 +323,8 @@ class Query_Processor {
SQLite3_result * get_stats_commands_counters();
SQLite3_result * get_query_digests();
SQLite3_result * get_query_digests_reset();
SQLite3_result * get_query_digests_v2(const bool use_resultset = true);
SQLite3_result * get_query_digests_reset_v2(const bool use_resultset = true);
std::pair<SQLite3_result *, int> get_query_digests_v2(const bool use_resultset = true);
std::pair<SQLite3_result *, int> get_query_digests_reset_v2(const bool use_resultset = true);
void get_query_digests_reset(umap_query_digest *uqd, umap_query_digest_text *uqdt);
unsigned long long purge_query_digests(bool async_purge, bool parallel, char **msg);
unsigned long long purge_query_digests_async(char **msg);

@ -1076,15 +1076,15 @@ incoming_servers_t::incoming_servers_t(
int ProxySQL_Test___GetDigestTable_v2(bool reset, bool use_resultset) {
int r = 0;
if (!GloQPro) return 0;
SQLite3_result * resultset=NULL;
std::pair<SQLite3_result *, int> res;
if (reset==true) {
resultset=GloQPro->get_query_digests_reset_v2(use_resultset);
res = GloQPro->get_query_digests_reset_v2(use_resultset);
} else {
resultset=GloQPro->get_query_digests_v2(use_resultset);
res = GloQPro->get_query_digests_v2(use_resultset);
}
if (resultset==NULL) return 0;
r = resultset->rows_count;
delete resultset;
if (res.first == NULL) return res.second;
r = res.first->rows_count;
delete res.first;
return r;
}
@ -4062,8 +4062,8 @@ void admin_session_handler(MySQL_Session *sess, void *_pa, PtrSize_t *pkt) {
// get all the entries from the digest map, but WRITING to DB
// it uses multiple threads
// It locks the maps while generating the resultset
SPA->stats___mysql_query_digests(false, true);
SPA->send_MySQL_OK(&sess->client_myds->myprot, NULL, 0);
r1 = SPA->stats___mysql_query_digests(false, true);
SPA->send_MySQL_OK(&sess->client_myds->myprot, NULL, r1);
run_query=false;
break;
case 23:
@ -9450,7 +9450,7 @@ void ProxySQL_Admin::stats___proxysql_message_metrics(bool reset) {
delete resultset;
}
void ProxySQL_Admin::stats___save_mysql_query_digest_to_sqlite(
int ProxySQL_Admin::stats___save_mysql_query_digest_to_sqlite(
const bool reset, const bool copy, const SQLite3_result *resultset, const umap_query_digest *digest_umap,
const umap_query_digest_text *digest_text_umap
) {
@ -9551,17 +9551,19 @@ void ProxySQL_Admin::stats___save_mysql_query_digest_to_sqlite(
}
}
statsdb->execute("COMMIT");
return row_idx;
}
void ProxySQL_Admin::stats___mysql_query_digests(bool reset, bool copy) {
if (!GloQPro) return;
int ProxySQL_Admin::stats___mysql_query_digests(bool reset, bool copy) {
if (!GloQPro) return 0;
SQLite3_result * resultset=NULL;
if (reset==true) {
resultset=GloQPro->get_query_digests_reset();
} else {
resultset=GloQPro->get_query_digests();
}
if (resultset==NULL) return;
if (resultset==NULL) return 0;
statsdb->execute("BEGIN");
int rc;
sqlite3_stmt *statement1=NULL;
@ -9656,6 +9658,8 @@ void ProxySQL_Admin::stats___mysql_query_digests(bool reset, bool copy) {
}
statsdb->execute("COMMIT");
delete resultset;
return row_idx;
}
void ProxySQL_Admin::stats___mysql_client_host_cache(bool reset) {

@ -1189,7 +1189,7 @@ unsigned long long Query_Processor::get_query_digests_total_size() {
return ret;
}
SQLite3_result * Query_Processor::get_query_digests_v2(const bool use_resultset) {
std::pair<SQLite3_result *, int> Query_Processor::get_query_digests_v2(const bool use_resultset) {
proxy_debug(PROXY_DEBUG_MYSQL_QUERY_PROCESSOR, 4, "Dumping current query digest\n");
SQLite3_result *result = NULL;
// Create two auxiliary maps and swap its content with the main maps. This
@ -1259,7 +1259,7 @@ SQLite3_result * Query_Processor::get_query_digests_v2(const bool use_resultset)
}
}
}
GloAdmin->stats___save_mysql_query_digest_to_sqlite(
int num_rows = GloAdmin->stats___save_mysql_query_digest_to_sqlite(
false, false, result, &digest_umap_aux, &digest_text_umap_aux
);
if (map_size >= DIGEST_STATS_FAST_MINSIZE) {
@ -1294,7 +1294,8 @@ SQLite3_result * Query_Processor::get_query_digests_v2(const bool use_resultset)
digest_text_umap_aux.clear();
pthread_rwlock_unlock(&digest_rwlock);
return result;
std::pair<SQLite3_result *, int> res{result, num_rows};
return res;
}
SQLite3_result * Query_Processor::get_query_digests() {
@ -1364,7 +1365,7 @@ SQLite3_result * Query_Processor::get_query_digests() {
return result;
}
SQLite3_result * Query_Processor::get_query_digests_reset_v2(const bool use_resultset) {
std::pair<SQLite3_result *, int> Query_Processor::get_query_digests_reset_v2(const bool use_resultset) {
SQLite3_result *result = NULL;
umap_query_digest digest_umap_aux;
umap_query_digest_text digest_text_umap_aux;
@ -1438,7 +1439,7 @@ SQLite3_result * Query_Processor::get_query_digests_reset_v2(const bool use_resu
}
}
}
GloAdmin->stats___save_mysql_query_digest_to_sqlite(
int num_rows = GloAdmin->stats___save_mysql_query_digest_to_sqlite(
false, false, result, &digest_umap_aux, &digest_text_umap_aux
);
digest_umap_aux.clear();
@ -1464,7 +1465,9 @@ SQLite3_result * Query_Processor::get_query_digests_reset_v2(const bool use_resu
}
}
}
return result;
std::pair<SQLite3_result *, int> res{result, num_rows};
return res;
}
void Query_Processor::get_query_digests_reset(umap_query_digest *uqd, umap_query_digest_text *uqdt) {

Loading…
Cancel
Save