From 6fb18bd2ac35902044d35da1c457f8d36e3afc45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20S=C3=A1nchez=20Parra?= Date: Fri, 10 Feb 2023 09:41:50 +0100 Subject: [PATCH] Move get digest text code to its own function --- include/query_processor.h | 1 + lib/Query_Processor.cpp | 38 +++++++++++++++++++++++++------------- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/include/query_processor.h b/include/query_processor.h index fc0566c63..d9110d13f 100644 --- a/include/query_processor.h +++ b/include/query_processor.h @@ -66,6 +66,7 @@ class QP_query_digest_stats { unsigned long long cnt = 1 ); ~QP_query_digest_stats(); + char *get_digest_text(const umap_query_digest_text *digest_text_umap); char **get_row(umap_query_digest_text *digest_text_umap, query_digest_stats_pointers_t *qdsp); }; diff --git a/lib/Query_Processor.cpp b/lib/Query_Processor.cpp index 96daa9c6e..2bc89256a 100644 --- a/lib/Query_Processor.cpp +++ b/lib/Query_Processor.cpp @@ -232,6 +232,30 @@ QP_query_digest_stats::~QP_query_digest_stats() { client_address=NULL; } } + +// Funtion to get the digest text associated to a QP_query_digest_stats. +// QP_query_digest_stats member type "char *digest_text" may by NULL, so we +// have to get the digest text from "digest_text_umap". +char *QP_query_digest_stats::get_digest_text(const umap_query_digest_text *digest_text_umap) { + char *digest_text_str = NULL; + + if (digest_text) { + digest_text_str = digest_text; + } else { + std::unordered_map::const_iterator it; + it = digest_text_umap->find(digest); + if (it != digest_text_umap->end()) { + digest_text_str = it->second; + } else { + // LCOV_EXCL_START + assert(0); + // LCOV_EXCL_STOP + } + } + + return digest_text_str; +} + char **QP_query_digest_stats::get_row(umap_query_digest_text *digest_text_umap, query_digest_stats_pointers_t *qdsp) { char **pta=qdsp->pta; @@ -247,19 +271,7 @@ char **QP_query_digest_stats::get_row(umap_query_digest_text *digest_text_umap, sprintf(qdsp->digest,"0x%016llX", (long long unsigned int)digest); pta[3]=qdsp->digest; - if (digest_text) { - pta[4]=digest_text; - } else { - std::unordered_map::iterator it; - it=digest_text_umap->find(digest); - if (it != digest_text_umap->end()) { - pta[4] = it->second; - } else { - // LCOV_EXCL_START - assert(0); - // LCOV_EXCL_STOP - } - } + pta[4] = get_digest_text(digest_text_umap); //sprintf(qdsp->count_star,"%u",count_star); my_itoa(qdsp->count_star, count_star);