[Commits] 15bb23b: MDEV-12179: Per-engine mysql.gtid_slave_pos table

Kristian Nielsen knielsen at knielsen-hq.org
Thu Mar 9 16:47:16 EET 2017


revision-id: 15bb23b1b76f413060c2d0d5b6b4557056410799 (mariadb-10.1.21-2-g15bb23b)
parent(s): 483a022a0d39be2dca22a8c210fd8d5b91139d72
author: Kristian Nielsen
committer: Kristian Nielsen
timestamp: 2017-03-08 13:56:29 +0100
message:

MDEV-12179: Per-engine mysql.gtid_slave_pos table

Intermediate commit.

Refactor scan_all_gtid_slave_pos_table() so it can do generic processing on
the list of mysql.gtid_slave_pos_XXX tables.

---
 sql/rpl_rli.cc | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/sql/rpl_rli.cc b/sql/rpl_rli.cc
index e2e215a..d3cfb30 100644
--- a/sql/rpl_rli.cc
+++ b/sql/rpl_rli.cc
@@ -1559,7 +1559,8 @@ scan_one_gtid_slave_pos_table(THD *thd, HASH *hash, DYNAMIC_ARRAY *array,
   into HASH.
 */
 static int
-scan_all_gtid_slave_pos_table(THD *thd, HASH *hash, DYNAMIC_ARRAY *array)
+scan_all_gtid_slave_pos_table(THD *thd, int (*cb)(THD *, LEX_STRING *, void *),
+                              void *cb_data)
 {
   static LEX_STRING mysql_db_name= {C_STRING_WITH_LEN("mysql")};
   char path[FN_REFLEN];
@@ -1597,7 +1598,7 @@ scan_all_gtid_slave_pos_table(THD *thd, HASH *hash, DYNAMIC_ARRAY *array)
                   rpl_gtid_slave_state_table_name.str,
                   rpl_gtid_slave_state_table_name.length) == 0)
       {
-        if ((err= scan_one_gtid_slave_pos_table(thd, hash, array, files.at(i))))
+        if ((err= (*cb)(thd, files.at(i), cb_data)))
           return err;
       }
     }
@@ -1607,6 +1608,19 @@ scan_all_gtid_slave_pos_table(THD *thd, HASH *hash, DYNAMIC_ARRAY *array)
 }
 
 
+struct load_gtid_state_cb_data {
+  HASH *hash;
+  DYNAMIC_ARRAY *array;
+};
+
+static int
+load_gtid_state_cb(THD *thd, LEX_STRING *table_name, void *arg)
+{
+  load_gtid_state_cb_data *data= static_cast<load_gtid_state_cb_data *>(arg);
+  return scan_one_gtid_slave_pos_table(thd, data->hash, data->array, table_name);
+}
+
+
 int
 rpl_load_gtid_slave_state(THD *thd)
 {
@@ -1616,6 +1630,7 @@ rpl_load_gtid_slave_state(THD *thd)
   DYNAMIC_ARRAY array;
   int err= 0;
   uint32 i;
+  load_gtid_state_cb_data cb_data;
   DBUG_ENTER("rpl_load_gtid_slave_state");
 
   mysql_mutex_lock(&rpl_global_gtid_slave_state->LOCK_slave_state);
@@ -1631,7 +1646,9 @@ rpl_load_gtid_slave_state(THD *thd)
     goto end;
   array_inited= true;
 
-  if ((err= scan_all_gtid_slave_pos_table(thd, &hash, &array)))
+  cb_data.hash = &hash;
+  cb_data.array = &array;
+  if ((err= scan_all_gtid_slave_pos_table(thd, load_gtid_state_cb, &cb_data)))
     goto end;
 
   mysql_mutex_lock(&rpl_global_gtid_slave_state->LOCK_slave_state);


More information about the commits mailing list