[Commits] e3fd0ab: Postreview

Oleksandr Byelkin sanja at mariadb.com
Fri Sep 16 22:29:32 EEST 2016


revision-id: e3fd0ab95555b04ce6694ffbe8d0b3e252f40a6f (mariadb-10.1.17-12-ge3fd0ab)
parent(s): 325a9c760c9b13a9748a0cee27a98455b558df30
committer: Oleksandr Byelkin
timestamp: 2016-09-16 21:29:32 +0200
message:

Postreview

---
 plugin/qc_info/qc_info.cc | 5 ++---
 sql/sql_cache.cc          | 3 ++-
 sql/sql_cache.h           | 9 ++++++++-
 3 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/plugin/qc_info/qc_info.cc b/plugin/qc_info/qc_info.cc
index da5d310..1dcef00 100644
--- a/plugin/qc_info/qc_info.cc
+++ b/plugin/qc_info/qc_info.cc
@@ -227,9 +227,8 @@ static int qc_info_fill_table(THD *thd, TABLE_LIST *tables,
 
     /* If we have result blocks, process them */
     first_result_block= query_cache_query->result();
-    if(first_result_block &&
-       // better do not touch unfinished result
-       first_result_block->type == Query_cache_block::RESULT)
+    if(query_cache_query->is_results_ready() &&
+       first_result_block)
     {
       /* initialize so we can loop over the result blocks*/
       result_block= first_result_block;
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index 91dd8ad..c69303c 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -961,7 +961,7 @@ inline void Query_cache_query::unlock_reading()
 void Query_cache_query::init_n_lock()
 {
   DBUG_ENTER("Query_cache_query::init_n_lock");
-  res=0; wri = 0; len = 0;
+  res=0; wri = 0; len = 0; ready= 0;
   mysql_rwlock_init(key_rwlock_query_cache_query_lock, &lock);
   lock_writing();
   DBUG_PRINT("qcache", ("inited & locked query for block 0x%lx",
@@ -1226,6 +1226,7 @@ void Query_cache::end_of_result(THD *thd)
       query_cache.split_block(last_result_block,len);
 
     header->found_rows(limit_found_rows);
+    header->set_results_ready(); // signal for plugin
     header->result()->type= Query_cache_block::RESULT;
 
     /* Drop the writer. */
diff --git a/sql/sql_cache.h b/sql/sql_cache.h
index 00ba9bf..657caf4 100644
--- a/sql/sql_cache.h
+++ b/sql/sql_cache.h
@@ -156,8 +156,9 @@ struct Query_cache_query
   Query_cache_block *res;
   Query_cache_tls *wri;
   ulong len;
-  uint8 tbls_type;
   unsigned int last_pkt_nr;
+  uint8 tbls_type;
+  uint8 ready;
 
   Query_cache_query() {}                      /* Remove gcc warning */
   inline void init_n_lock();
@@ -177,6 +178,12 @@ struct Query_cache_query
   {
     return (((uchar*)this) + ALIGN_SIZE(sizeof(Query_cache_query)));
   }
+  /**
+    following used to check if result ready in plugin without
+    locking rw_lock of the query.
+  */
+  inline void set_results_ready()          { ready= 1; }
+  inline bool is_results_ready()           { return ready; }
   void lock_writing();
   void lock_reading();
   bool try_lock_writing();


More information about the commits mailing list