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

Kristian Nielsen knielsen at knielsen-hq.org
Fri Mar 24 13:06:43 EET 2017


revision-id: f20b70ce943a0d7418bf6f735e75c334156db703 (mariadb-10.1.21-10-gf20b70c)
parent(s): 8253b258b6721f226adfb5ef7448b42963ce755f
author: Kristian Nielsen
committer: Kristian Nielsen
timestamp: 2017-03-24 12:06:29 +0100
message:

MDEV-12179: Per-engine mysql.gtid_slave_pos table

Intermediate commit.

Ignore unknown engines in --gtid-pos-auto-engines command-line options (but
not SET GLOBAL). This seems useful, to allow a default that auto-creates the
gtid pos table for engines like TokuDB and MyRocks (which greatly benefit
from such), but does not prevent server startup when those engines are not
available.

---
 sql/mysqld.cc   | 12 ++++++++++--
 sql/set_var.cc  | 19 +++++++++++++------
 sql/set_var.h   |  3 ++-
 sql/sys_vars.ic |  6 +++---
 4 files changed, 28 insertions(+), 12 deletions(-)

diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 389e670..de58130 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -4839,11 +4839,19 @@ init_gtid_pos_auto_engines(void)
 {
   plugin_ref *plugins;
 
+  /*
+    For the command-line option --gtid_pos_auto_engines, we allow (and ignore)
+    engines that are unknown. This is convenient, since it allows to set
+    default auto-create engines that might not be used by particular users.
+    The option sets a list of storage engines that will have gtid position
+    table auto-created for them if needed. And if the engine is not available,
+    then it will certainly not be needed.
+  */
   if (gtid_pos_auto_engines)
     plugins= resolve_engine_list(gtid_pos_auto_engines,
-                                 strlen(gtid_pos_auto_engines));
+                                 strlen(gtid_pos_auto_engines), false);
   else
-    plugins= resolve_engine_list("", 0);
+    plugins= resolve_engine_list("", 0, false);
   if (!plugins)
     return 1;
   mysql_mutex_lock(&LOCK_global_system_variables);
diff --git a/sql/set_var.cc b/sql/set_var.cc
index f9a267f..89af075 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -1241,7 +1241,8 @@ engine_list_next_item(const char **pos, const char *end_pos,
 
 static bool
 resolve_engine_list_item(plugin_ref *list, uint32 *idx,
-                         const char *pos, const char *pos_end)
+                         const char *pos, const char *pos_end,
+                         bool error_on_unknown_engine)
 {
   LEX_STRING item_str;
   plugin_ref ref;
@@ -1252,9 +1253,13 @@ resolve_engine_list_item(plugin_ref *list, uint32 *idx,
   ref= ha_resolve_by_name(NULL, &item_str, false);
   if (!ref)
   {
-    ErrConvString err(pos, pos_end-pos, system_charset_info);
-    my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), err.ptr());
-    return true;
+    if (error_on_unknown_engine)
+    {
+      ErrConvString err(pos, pos_end-pos, system_charset_info);
+      my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), err.ptr());
+      return true;
+    }
+    return false;
   }
   /* Ignore duplicates, like --plugin-load does. */
   for (i= 0; i < *idx; ++i)
@@ -1277,7 +1282,8 @@ resolve_engine_list_item(plugin_ref *list, uint32 *idx,
   array of plugin_ref.
 */
 plugin_ref *
-resolve_engine_list(const char *str_arg, size_t str_arg_len)
+resolve_engine_list(const char *str_arg, size_t str_arg_len,
+                    bool error_on_unknown_engine)
 {
   uint32 count, idx;
   const char *pos, *item_start, *item_end;
@@ -1309,7 +1315,8 @@ resolve_engine_list(const char *str_arg, size_t str_arg_len)
     DBUG_ASSERT(idx < count);
     if (idx >= count)
       break;
-    if (resolve_engine_list_item(res, &idx, item_start, item_end))
+    if (resolve_engine_list_item(res, &idx, item_start, item_end,
+                                 error_on_unknown_engine))
       goto err;
   }
 
diff --git a/sql/set_var.h b/sql/set_var.h
index 771d430..48ed319 100644
--- a/sql/set_var.h
+++ b/sql/set_var.h
@@ -417,7 +417,8 @@ CHARSET_INFO *get_old_charset_by_name(const char *old_name);
 int sys_var_init();
 int sys_var_add_options(DYNAMIC_ARRAY *long_options, int parse_flags);
 void sys_var_end(void);
-plugin_ref *resolve_engine_list(const char *str_arg, size_t str_arg_len);
+plugin_ref *resolve_engine_list(const char *str_arg, size_t str_arg_len,
+                                bool error_on_unknown_engine);
 void free_engine_list(plugin_ref *list);
 plugin_ref *copy_engine_list(plugin_ref *list);
 char *pretty_print_engine_list(THD *thd, plugin_ref *list);
diff --git a/sql/sys_vars.ic b/sql/sys_vars.ic
index eeaedac..d7e964b 100644
--- a/sql/sys_vars.ic
+++ b/sql/sys_vars.ic
@@ -1475,9 +1475,9 @@ class Sys_var_pluginlist: public sys_var
     plugin_ref *plugins;
 
     if (!(res=var->value->val_str(&str)))
-      plugins= resolve_engine_list("", 0);
+      plugins= resolve_engine_list("", 0, true);
     else
-      plugins= resolve_engine_list(res->ptr(), res->length());
+      plugins= resolve_engine_list(res->ptr(), res->length(), true);
     if (!plugins)
       return true;
     var->save_result.plugins= plugins;
@@ -1511,7 +1511,7 @@ class Sys_var_pluginlist: public sys_var
     char *default_value= *reinterpret_cast<char**>(option.def_value);
     if (!default_value)
       return 0;
-    return resolve_engine_list(default_value, strlen(default_value));
+    return resolve_engine_list(default_value, strlen(default_value), false);
   }
 
   void global_save_default(THD *thd, set_var *var)


More information about the commits mailing list