Skip to content

Commit

Permalink
MDEV-12179: Per-engine mysql.gtid_slave_pos table
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
knielsen committed Apr 21, 2017
1 parent 4eebf43 commit 3cc89b3
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
12 changes: 10 additions & 2 deletions sql/mysqld.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4923,11 +4923,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);
Expand Down
19 changes: 13 additions & 6 deletions sql/set_var.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1302,7 +1302,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;
Expand All @@ -1313,9 +1314,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)
Expand All @@ -1338,7 +1343,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;
Expand Down Expand Up @@ -1370,7 +1376,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;
}

Expand Down
3 changes: 2 additions & 1 deletion sql/set_var.h
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,8 @@ int sys_var_init();
uint sys_var_elements();
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);
Expand Down
6 changes: 3 additions & 3 deletions sql/sys_vars.ic
Original file line number Diff line number Diff line change
Expand Up @@ -1575,9 +1575,9 @@ public:
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;
Expand Down Expand Up @@ -1611,7 +1611,7 @@ public:
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)
Expand Down

0 comments on commit 3cc89b3

Please sign in to comment.