mirror of
https://github.com/MariaDB/server.git
synced 2026-10-23 18:49:29 +03:00
MDEV-32745 Add a simple MySQL to MariaDB upgrade helper
The tool is named mariadb-migrate-config-file. The main purpose of the tool is to change MySQL option files to work both for MySQL and MariaDB. There are options to do the changes in the options file inline, or at-end-of-file. One can also remove or comment unknown options. The list of supported options is generated compile time from mariadbd --help. All server options, including compiled plugins, are supported. The bulk of the code comes from Väinö. Monty has updated it with a lot of extra options. Wlad helped with cmake integration Other things: - Fixed a memory leak in sql_plugin.cc - plugin-load will now in case of errors try to load all given plugins before aborted - If silent-startup is used, plugin-load will not give errors for plugins it cannot load or warnings about plugin marturity level. - my_rm_tree() will now delete symlinks, not the actual file, if MY_NOSYMLINK flag is used. - my_stat() will now give data for symlink if MY_NOSYMLINKS is used. - Added 'number of lines' option to mysqltest --cat_file @Authors: Väinö Mäkelä <vaino.makela@iki.fi>,monty@mariadb.com
This commit is contained in:
@@ -545,7 +545,9 @@ static my_bool read_mysql_plugin_info(struct st_plugin_dl *plugin_dl,
|
||||
/* Determine interface version */
|
||||
if (!sym)
|
||||
{
|
||||
my_error(ER_CANT_FIND_DL_ENTRY, MyFlags, plugin_interface_version_sym, dlpath);
|
||||
if (!opt_silent_startup)
|
||||
my_error(ER_CANT_FIND_DL_ENTRY, MyFlags, plugin_interface_version_sym,
|
||||
dlpath);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
plugin_dl->mariaversion= 0;
|
||||
@@ -664,8 +666,9 @@ static my_bool read_maria_plugin_info(struct st_plugin_dl *plugin_dl,
|
||||
Actually this branch impossible because in case of absence of maria
|
||||
version we try mysql version.
|
||||
*/
|
||||
my_error(ER_CANT_FIND_DL_ENTRY, MyFlags,
|
||||
maria_plugin_interface_version_sym, dlpath);
|
||||
if (!opt_silent_startup)
|
||||
my_error(ER_CANT_FIND_DL_ENTRY, MyFlags,
|
||||
maria_plugin_interface_version_sym, dlpath);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
plugin_dl->mariaversion= *(int *)sym;
|
||||
@@ -779,7 +782,9 @@ static st_plugin_dl *plugin_dl_add(const LEX_CSTRING *dl, myf MyFlags)
|
||||
/* Open new dll handle */
|
||||
if (!(plugin_dl.handle= dlopen(dlpath, RTLD_NOW)))
|
||||
{
|
||||
my_error(ER_CANT_OPEN_LIBRARY, MyFlags, dlpath, errno, my_dlerror(dlpath));
|
||||
if (!opt_silent_startup)
|
||||
my_error(ER_CANT_OPEN_LIBRARY, MyFlags, dlpath, errno,
|
||||
my_dlerror(dlpath));
|
||||
goto ret;
|
||||
}
|
||||
dlopen_count++;
|
||||
@@ -822,7 +827,8 @@ static st_plugin_dl *plugin_dl_add(const LEX_CSTRING *dl, myf MyFlags)
|
||||
my_snprintf(buf, sizeof(buf),
|
||||
"service '%s' interface version mismatch",
|
||||
list_of_services[i].name);
|
||||
my_error(ER_CANT_OPEN_LIBRARY, MyFlags, dlpath, ENOEXEC, buf);
|
||||
if (!opt_silent_startup)
|
||||
my_error(ER_CANT_OPEN_LIBRARY, MyFlags, dlpath, ENOEXEC, buf);
|
||||
goto ret;
|
||||
}
|
||||
tmp_backup[plugin_dl.nbackups++].save(ptr);
|
||||
@@ -1112,8 +1118,9 @@ static st_plugin_int *plugin_insert_or_reuse(struct st_plugin_int *plugin)
|
||||
NOTE
|
||||
Requires that a write-lock is held on LOCK_system_variables_hash
|
||||
*/
|
||||
static enum install_status plugin_add(MEM_ROOT *tmp_root, bool if_not_exists,
|
||||
const LEX_CSTRING *name, LEX_CSTRING *dl, myf MyFlags)
|
||||
static enum install_status
|
||||
plugin_add(MEM_ROOT *tmp_root, bool if_not_exists,
|
||||
const LEX_CSTRING *name, LEX_CSTRING *dl, myf MyFlags)
|
||||
{
|
||||
struct st_plugin_int tmp, *maybe_dupe;
|
||||
struct st_maria_plugin *plugin;
|
||||
@@ -1153,7 +1160,7 @@ static enum install_status plugin_add(MEM_ROOT *tmp_root, bool if_not_exists,
|
||||
if (!name->str &&
|
||||
(maybe_dupe= plugin_find_internal(&tmp.name, MYSQL_ANY_PLUGIN)))
|
||||
{
|
||||
if (plugin->name != maybe_dupe->plugin->name)
|
||||
if (plugin->name != maybe_dupe->plugin->name && !opt_silent_startup)
|
||||
{
|
||||
my_error(ER_UDF_EXISTS, MyFlags, plugin->name);
|
||||
DBUG_RETURN(INSTALL_FAIL_NOT_OK);
|
||||
@@ -1190,10 +1197,11 @@ static enum install_status plugin_add(MEM_ROOT *tmp_root, bool if_not_exists,
|
||||
}
|
||||
else if (plugin_maturity_map[plugin->maturity] < SERVER_MATURITY_LEVEL)
|
||||
{
|
||||
sql_print_warning("Plugin '%s' is of maturity level %s while the server is %s",
|
||||
tmp.name.str,
|
||||
plugin_maturity_names[plugin->maturity],
|
||||
plugin_maturity_names[SERVER_MATURITY_LEVEL]);
|
||||
if (!opt_silent_startup)
|
||||
sql_print_warning("Plugin '%s' is of maturity level %s while the server is %s",
|
||||
tmp.name.str,
|
||||
plugin_maturity_names[plugin->maturity],
|
||||
plugin_maturity_names[SERVER_MATURITY_LEVEL]);
|
||||
}
|
||||
|
||||
tmp.plugin= plugin;
|
||||
@@ -1910,14 +1918,10 @@ static void plugin_load(MEM_ROOT *tmp_root)
|
||||
if (result)
|
||||
{
|
||||
DBUG_PRINT("error",("Can't open plugin table"));
|
||||
if (!opt_help)
|
||||
if (!opt_silent_startup)
|
||||
sql_print_error("Could not open mysql.plugin table: \"%s\". "
|
||||
"Some plugins may be not loaded",
|
||||
new_thd->get_stmt_da()->message());
|
||||
else
|
||||
sql_print_warning("Could not open mysql.plugin table: \"%s\". "
|
||||
"Some options may be missing from the help text",
|
||||
new_thd->get_stmt_da()->message());
|
||||
goto end;
|
||||
}
|
||||
|
||||
@@ -2003,8 +2007,10 @@ static bool plugin_load_list(MEM_ROOT *tmp_root, const char *list)
|
||||
{
|
||||
char buffer[FN_REFLEN];
|
||||
LEX_CSTRING name= {buffer, 0}, dl= {NULL, 0}, *str= &name;
|
||||
bool got_error= 0;
|
||||
char *p= buffer;
|
||||
DBUG_ENTER("plugin_load_list");
|
||||
|
||||
while (list)
|
||||
{
|
||||
if (p == buffer + sizeof(buffer) - 1)
|
||||
@@ -2018,9 +2024,7 @@ static bool plugin_load_list(MEM_ROOT *tmp_root, const char *list)
|
||||
list= NULL; /* terminate the loop */
|
||||
/* fall through */
|
||||
case ';':
|
||||
#ifndef _WIN32
|
||||
case ':': /* can't use this as delimiter as it may be drive letter */
|
||||
#endif
|
||||
case ':':
|
||||
p[-1]= 0;
|
||||
if (str == &name) // load all plugins in named module
|
||||
{
|
||||
@@ -2065,16 +2069,23 @@ static bool plugin_load_list(MEM_ROOT *tmp_root, const char *list)
|
||||
str->length++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
DBUG_RETURN(FALSE);
|
||||
|
||||
error:
|
||||
mysql_mutex_unlock(&LOCK_plugin);
|
||||
if (name.str)
|
||||
sql_print_error("Couldn't load plugin '%s' from '%s'.",
|
||||
name.str, dl.str);
|
||||
else
|
||||
sql_print_error("Couldn't load plugins from '%s'.", dl.str);
|
||||
DBUG_RETURN(TRUE);
|
||||
got_error= 1;
|
||||
mysql_mutex_unlock(&LOCK_plugin);
|
||||
if (!opt_silent_startup)
|
||||
{
|
||||
if (name.str)
|
||||
sql_print_error("Couldn't load plugin '%s' from '%s'.",
|
||||
name.str, dl.str);
|
||||
else
|
||||
sql_print_error("Couldn't load plugins from '%s'.", dl.str);
|
||||
}
|
||||
name.length= dl.length= 0;
|
||||
dl.str= NULL; name.str= p= buffer;
|
||||
str= &name;
|
||||
} // Continue with next plugin
|
||||
DBUG_RETURN(got_error);
|
||||
}
|
||||
|
||||
|
||||
@@ -4066,6 +4077,7 @@ static int construct_options(MEM_ROOT *mem_root, struct st_plugin_int *tmp,
|
||||
(opt->flags & PLUGIN_VAR_MEMALLOC))
|
||||
{
|
||||
char *def_val= *(char**)var_def_ptr(opt);
|
||||
my_free(*(char**)val);
|
||||
*(char**)val= def_val ? my_strdup(PSI_INSTRUMENT_ME, def_val, MYF(0)) : NULL;
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user