1
0
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:
Michael Widenius
2026-01-30 23:58:20 +02:00
committed by Monty
parent 5133eace02
commit 7828fb475b
23 changed files with 4542 additions and 78 deletions

4
.gitignore vendored
View File

@@ -30,6 +30,7 @@ Docs/INFO_BIN
Docs/INFO_SRC Docs/INFO_SRC
Makefile Makefile
TAGS TAGS
all_plugins/
mariadb-plugin-columnstore.install.generated mariadb-plugin-columnstore.install.generated
Testing/ Testing/
tmp/ tmp/
@@ -59,8 +60,10 @@ extra/comp_err
extra/innochecksum extra/innochecksum
extra/jemalloc/build/ extra/jemalloc/build/
extra/jemalloc/tmp/ extra/jemalloc/tmp/
extra/generate_option_list
extra/mariabackup/mariabackup extra/mariabackup/mariabackup
extra/mariabackup/mbstream extra/mariabackup/mbstream
extra/mariadb-migrate-config-file
extra/my_print_defaults extra/my_print_defaults
extra/mysql_waitpid extra/mysql_waitpid
extra/mysqld_safe_helper extra/mysqld_safe_helper
@@ -72,6 +75,7 @@ extra/wolfssl/user_settings.h
import_executables.cmake import_executables.cmake
include/*.h.tmp include/*.h.tmp
include/config.h include/config.h
include/mariadbd_options.h
include/my_config.h include/my_config.h
include/mysql_version.h include/mysql_version.h
include/mysqld_ername.h include/mysqld_ername.h

View File

@@ -496,7 +496,6 @@ ADD_SUBDIRECTORY(vio)
ADD_SUBDIRECTORY(mysys) ADD_SUBDIRECTORY(mysys)
ADD_SUBDIRECTORY(mysys_ssl) ADD_SUBDIRECTORY(mysys_ssl)
ADD_SUBDIRECTORY(client) ADD_SUBDIRECTORY(client)
ADD_SUBDIRECTORY(extra)
ADD_SUBDIRECTORY(libservices) ADD_SUBDIRECTORY(libservices)
ADD_SUBDIRECTORY(sql/share) ADD_SUBDIRECTORY(sql/share)
@@ -522,6 +521,8 @@ IF(NOT WITHOUT_SERVER)
ENDIF() ENDIF()
ENDIF() ENDIF()
ADD_SUBDIRECTORY(extra)
IF(UNIX) IF(UNIX)
ADD_SUBDIRECTORY(man) ADD_SUBDIRECTORY(man)
ENDIF() ENDIF()

View File

@@ -2157,15 +2157,16 @@ void log_msg(const char *fmt, ...)
SYNOPSIS SYNOPSIS
cat_file cat_file
ds - pointer to dynamic string where to add the files content ds - pointer to dynamic string where to add the files content
filename - name of the file to read filename - name of the file to read
max_lines - number of lines to print. 0 == all
*/ */
int cat_file(DYNAMIC_STRING* ds, const char* filename) int cat_file(DYNAMIC_STRING* ds, const char* filename, uint max_lines)
{ {
int fd; int fd;
size_t len; size_t len;
char *buff; char *buff;
uint line= 0; // Enough for mtr
if ((fd= my_open(filename, O_RDONLY, MYF(0))) < 0) if ((fd= my_open(filename, O_RDONLY, MYF(0))) < 0)
return 1; return 1;
@@ -2182,28 +2183,35 @@ int cat_file(DYNAMIC_STRING* ds, const char* filename)
len= my_read(fd, (uchar*)buff, len, MYF(0)); len= my_read(fd, (uchar*)buff, len, MYF(0));
my_close(fd, MYF(0)); my_close(fd, MYF(0));
if (!max_lines)
max_lines= 10000; // Enough for mtr
char *p= buff, *start= buff, *end=buff+len;
while (p < end && line <= max_lines)
{ {
char *p= buff, *start= buff,*end=buff+len; /* Convert cr/lf to lf */
while (p < end) if (*p == '\r' && p+1 < end && *(p+1)== '\n')
{ {
/* Convert cr/lf to lf */ /* Add fake newline instead of cr and output the line */
if (*p == '\r' && p+1 < end && *(p+1)== '\n') *p= '\n';
{ p++; /* Step past the "fake" newline */
/* Add fake newline instead of cr and output the line */ *p= 0;
*p= '\n'; replace_dynstr_append_mem(ds, start, p-start);
p++; /* Step past the "fake" newline */ p++; /* Step past the "fake" newline */
*p= 0; start= p;
replace_dynstr_append_mem(ds, start, p-start); line++;
p++; /* Step past the "fake" newline */ }
start= p; else
} {
else if (*p == '\n')
p++; line++;
p++;
} }
/* Output any chars that migh be left */
*p= 0;
replace_dynstr_append_mem(ds, start, p-start);
} }
/* Output any chars that migh be left */
*p= 0;
replace_dynstr_append_mem(ds, start, p-start);
my_free(buff); my_free(buff);
return 0; return 0;
} }
@@ -2450,11 +2458,11 @@ void show_diff(DYNAMIC_STRING* ds,
dynstr_append_mem(&ds_tmp, STRING_WITH_LEN(" --- ")); dynstr_append_mem(&ds_tmp, STRING_WITH_LEN(" --- "));
dynstr_append_mem(&ds_tmp, filename1, strlen(filename1)); dynstr_append_mem(&ds_tmp, filename1, strlen(filename1));
dynstr_append_mem(&ds_tmp, STRING_WITH_LEN(" >>>\n")); dynstr_append_mem(&ds_tmp, STRING_WITH_LEN(" >>>\n"));
cat_file(&ds_tmp, filename1); cat_file(&ds_tmp, filename1, 0);
dynstr_append_mem(&ds_tmp, STRING_WITH_LEN("<<<\n --- ")); dynstr_append_mem(&ds_tmp, STRING_WITH_LEN("<<<\n --- "));
dynstr_append_mem(&ds_tmp, filename1, strlen(filename1)); dynstr_append_mem(&ds_tmp, filename1, strlen(filename1));
dynstr_append_mem(&ds_tmp, STRING_WITH_LEN(" >>>\n")); dynstr_append_mem(&ds_tmp, STRING_WITH_LEN(" >>>\n"));
cat_file(&ds_tmp, filename2); cat_file(&ds_tmp, filename2, 0);
dynstr_append_mem(&ds_tmp, STRING_WITH_LEN("<<<<\n")); dynstr_append_mem(&ds_tmp, STRING_WITH_LEN("<<<<\n"));
} }
@@ -4851,9 +4859,11 @@ void do_append_file(struct st_command *command)
void do_cat_file(struct st_command *command) void do_cat_file(struct st_command *command)
{ {
int error; int error;
static DYNAMIC_STRING ds_filename; static DYNAMIC_STRING ds_filename, ds_lines;
uint lines= 0;
const struct command_arg cat_file_args[] = { const struct command_arg cat_file_args[] = {
{ "filename", ARG_STRING, TRUE, &ds_filename, "File to read from" } { "filename", ARG_STRING, TRUE, &ds_filename, "File to read from" },
{ "lines", ARG_STRING, FALSE, &ds_lines, "Number of lines to print"}
}; };
DBUG_ENTER("do_cat_file"); DBUG_ENTER("do_cat_file");
@@ -4865,9 +4875,13 @@ void do_cat_file(struct st_command *command)
DBUG_PRINT("info", ("Reading from, file: %s", ds_filename.str)); DBUG_PRINT("info", ("Reading from, file: %s", ds_filename.str));
error= cat_file(&ds_res, ds_filename.str); if (ds_lines.length)
lines= atoi(ds_lines.str);
error= cat_file(&ds_res, ds_filename.str, lines);
handle_command_error(command, error, my_errno); handle_command_error(command, error, my_errno);
dynstr_free(&ds_filename); dynstr_free(&ds_filename);
dynstr_free(&ds_lines);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
@@ -13281,7 +13295,7 @@ int main(int argc, char **argv)
case Q_DIFF_FILES: do_diff_files(command); break; case Q_DIFF_FILES: do_diff_files(command); break;
case Q_SEND_QUIT: do_send_quit(command); break; case Q_SEND_QUIT: do_send_quit(command); break;
case Q_CHANGE_USER: do_change_user(command); break; case Q_CHANGE_USER: do_change_user(command); break;
case Q_CAT_FILE: do_cat_file(command); break; case Q_CAT_FILE: do_cat_file(command); command_executed++; break;
case Q_COPY_FILE: do_copy_file(command); break; case Q_COPY_FILE: do_copy_file(command); break;
case Q_MOVE_FILE: do_move_file(command); break; case Q_MOVE_FILE: do_move_file(command); break;
case Q_CHMOD_FILE: do_chmod_file(command); break; case Q_CHMOD_FILE: do_chmod_file(command); break;

View File

@@ -300,6 +300,11 @@ MACRO(MYSQL_ADD_PLUGIN)
IF(ARG_CONFIG AND INSTALL_SYSCONF2DIR) IF(ARG_CONFIG AND INSTALL_SYSCONF2DIR)
INSTALL(FILES ${ARG_CONFIG} COMPONENT ${ARG_COMPONENT} DESTINATION ${INSTALL_SYSCONF2DIR}) INSTALL(FILES ${ARG_CONFIG} COMPONENT ${ARG_COMPONENT} DESTINATION ${INSTALL_SYSCONF2DIR})
ENDIF() ENDIF()
IF(NOT ARG_CLIENT)
GET_PROPERTY(my_list GLOBAL PROPERTY SERVER_DYNAMIC_PLUGINS)
LIST(APPEND my_list ${target})
SET_PROPERTY(GLOBAL PROPERTY SERVER_DYNAMIC_PLUGINS "${my_list}")
ENDIF()
ENDIF() ENDIF()
GET_FILENAME_COMPONENT(subpath ${CMAKE_CURRENT_SOURCE_DIR} NAME) GET_FILENAME_COMPONENT(subpath ${CMAKE_CURRENT_SOURCE_DIR} NAME)

View File

@@ -1,6 +1,7 @@
usr/bin/mariadb usr/bin/mariadb
usr/bin/mariadb-check usr/bin/mariadb-check
usr/bin/my_print_defaults usr/bin/my_print_defaults
usr/bin/mariadb-migrate-config-file
usr/share/man/man1/mariadb-check.1 usr/share/man/man1/mariadb-check.1
usr/share/man/man1/mariadb.1 usr/share/man/man1/mariadb.1
usr/share/man/man1/my_print_defaults.1 usr/share/man/man1/my_print_defaults.1

View File

@@ -13,7 +13,7 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${ZLIB_INCLUDE_DIRS}) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${ZLIB_INCLUDE_DIRS} ${PCRE_INCLUDE_DIRS})
# Default install component for the files is Server here # Default install component for the files is Server here
SET(MYSQL_INSTALL_COMPONENT Server) SET(MYSQL_INSTALL_COMPONENT Server)
@@ -46,6 +46,67 @@ ADD_CUSTOM_TARGET(GenError
DEPENDS DEPENDS
${CMAKE_BINARY_DIR}/include/mysqld_error.h.tmp) ${CMAKE_BINARY_DIR}/include/mysqld_error.h.tmp)
IF(NOT CMAKE_CROSSCOMPILING AND TARGET mariadbd)
ADD_EXECUTABLE(generate_option_list generate_option_list.cc)
TARGET_LINK_LIBRARIES(generate_option_list mysys pcre2-8)
TARGET_INCLUDE_DIRECTORIES(generate_option_list PRIVATE ${PCRE_INCLUDE_DIRS})
GET_PROPERTY(dynamic_plugins GLOBAL PROPERTY SERVER_DYNAMIC_PLUGINS)
GET_PROPERTY(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
IF(is_multi_config)
SET(my_plugin_dir "${CMAKE_BINARY_DIR}/all_plugins/$<CONFIG>")
ELSE()
SET(my_plugin_dir "${CMAKE_BINARY_DIR}/all_plugins")
ENDIF()
SET(populate_plugin_dir)
SET(plugin_load)
LIST(APPEND populate_plugin_dir
COMMAND ${CMAKE_COMMAND} -E rm -rf "${my_plugin_dir}"
COMMAND ${CMAKE_COMMAND} -E make_directory "${my_plugin_dir}"
)
FOREACH(target ${dynamic_plugins})
LIST(APPEND plugin_load "$<TARGET_FILE_NAME:${target}>")
IF(WIN32)
SET(maybe_create_hardlink || ${CMAKE_COMMAND} -E create_hardlink
$<TARGET_FILE:${target}>
"${my_plugin_dir}/$<TARGET_FILE_NAME:${target}>")
ENDIF()
LIST(APPEND populate_plugin_dir
COMMAND ${CMAKE_COMMAND} -E create_symlink
$<TARGET_FILE:${target}>
"${my_plugin_dir}/$<TARGET_FILE_NAME:${target}>"
${maybe_create_hardlink})
ENDFOREACH()
IF(NOT plugin_load)
SET(plugin_load " ")
ENDIF()
STRING(REPLACE ";" ":" escaped_plugin_load "${plugin_load}")
SET(genhdr ${CMAKE_BINARY_DIR}/include/mariadbd_options.h)
ADD_CUSTOM_COMMAND(OUTPUT ${genhdr}
# COMMAND ${CMAKE_COMMAND} -E echo "Executing ${populate_plugin_dir}"
${populate_plugin_dir}
#COMMAND ${CMAKE_COMMAND} -E echo "Executing generate_option_list $<TARGET_FILE:mariadbd> ${my_plugin_dir} ${escaped_plugin_load} ${genhdr}"
COMMAND generate_option_list "$<TARGET_FILE:mariadbd>" "${my_plugin_dir}" "${escaped_plugin_load}" "${genhdr}"
COMMAND_EXPAND_LISTS
)
ADD_CUSTOM_TARGET(gen_mariadbd_options_h
DEPENDS ${genhdr}
)
MYSQL_ADD_EXECUTABLE(mariadb-migrate-config-file
mariadb_migrate_config_file.c
${genhdr}
COMPONENT Client)
# Make sure consumers cannot compile before the header exists:
SET_SOURCE_FILES_PROPERTIES("${genhdr}" PROPERTIES GENERATED TRUE)
TARGET_LINK_LIBRARIES(mariadb-migrate-config-file PRIVATE mysys)
ENDIF()
MYSQL_ADD_EXECUTABLE(my_print_defaults my_print_defaults.c COMPONENT Client) MYSQL_ADD_EXECUTABLE(my_print_defaults my_print_defaults.c COMPONENT Client)
TARGET_LINK_LIBRARIES(my_print_defaults mysys) TARGET_LINK_LIBRARIES(my_print_defaults mysys)

View File

@@ -0,0 +1,346 @@
/* Copyright (c) 2024, Väinö Mäkelä
With some small changes by Michael Widenius
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335
USA */
#include <my_global.h>
#include <my_sys.h>
#include <my_dir.h>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <vector>
#define PCRE2_STATIC 1 /* Important on Windows */
#include "pcre2.h"
struct parsed
{
std::set<std::string> options;
std::map<std::string, std::vector<std::string>> enums;
std::map<std::string, std::vector<std::string>> sets;
};
#if defined(__has_feature)
# if __has_feature(memory_sanitizer)
__attribute__((no_sanitize("memory"))) /* we may run with uninstrumented std::string */
# endif
#endif
std::string read_output(FILE *f)
{
char buf[4096];
size_t read_bytes;
std::string output;
do
{
read_bytes= std::fread(buf, 1, sizeof buf, f);
output.append(buf, read_bytes);
} while (read_bytes > 0);
return output;
}
#if defined(__has_feature)
# if __has_feature(memory_sanitizer)
__attribute__((no_sanitize("memory"))) /* we may run with uninstrumented std::string */
# endif
#endif
std::string call_mariadbd(const char *mariadbd_path, const char *plugin_dir, const char *plugin_load)
{
std::string output;
std::ostringstream command;
#ifdef _WIN32
command << "\"";
#endif
command << "\"" << mariadbd_path << "\"";
command << " --no-defaults"
" --silent-startup"
" --plugin-maturity=unknown"
" --plugin-dir=";
command << plugin_dir << "";
if (plugin_load[0] != ' ' || !plugin_load[0])
{
command << " \"--plugin-load=";
command << plugin_load;
command << "\"";
}
command << " --verbose"
" --help";
#ifdef _WIN32
command << "\"";
#endif
std::cout << "Executing command: " << command.str() << '\n';
FILE *f= my_popen(command.str().c_str(), "r");
if (!f)
{
perror("failed to read mariadbd output");
my_pclose(f);
exit(1);
}
output= read_output(f);
my_pclose(f);
return output;
}
std::string remove_paretheses(std::string &str)
{
std::string result;
bool in_parens= false;
for (auto it= str.begin(); it != str.end(); ++it)
{
if (*it == '(')
{
in_parens= true;
}
else if (in_parens && *it == ')')
{
in_parens= false;
}
else if (!in_parens)
{
result.push_back(*it);
}
}
return result;
}
std::vector<std::string> split_list(std::string &str)
{
std::vector<std::string> result;
std::string current;
std::string parens_removed= remove_paretheses(str);
bool seen_dot= false;
for (auto it= parens_removed.begin(); it != parens_removed.end(); ++it)
{
switch (*it) {
case ' ':
case '\t':
case '\n':
case '\r':
case ',':
seen_dot= false;
if (!current.empty())
result.push_back(current);
current.clear();
break;
case '.':
seen_dot= true;
break;
default:
if (seen_dot)
current.push_back('.');
current.push_back(*it);
}
}
if (!current.empty())
result.push_back(current);
return result;
}
std::string capture_group(std::string &str, PCRE2_SIZE *ovector, int group)
{
return str.substr(ovector[2 * group],
ovector[2 * group + 1] - ovector[2 * group]);
}
/*
Ignore some special mariadb options from using enum/set
*/
bool ignore_option(std::string *option)
{
/*
wsrep_provider must not be threated as an enum as in mariadbd --help is both
a string and an enum.
*/
if (!strcmp(option->c_str(), "wsrep_provider"))
return 1; // Ignore
return 0;
}
struct parsed parse_output(std::string &output)
{
struct parsed result= {};
const char *pattern=
"# Consider all lines that start with ' --' or ' -x, --'as options.\n"
"^\\ \\ (?:-.,\\ )?--([^\\ =\\[]+)\n"
"(?:\n"
" # Check for possible enum or set values until we hit\n"
" # ' -' at the start of a line. This won't work for\n"
" # the last option but should work for most ones.\n"
" (?:(?<!^\\ \\ -).)*\n"
" (?:(?:One\\s+of:(.*?))|(?:Any\\s+combination\\s+of:(.*?)))\n"
" # Sets end with \" Use 'ALL'...\"\n"
" (?=^\\ \\ (?:-|Use))\n"
")?";
pcre2_match_data *match_data;
PCRE2_SIZE *ovector;
PCRE2_SIZE offset= 0;
int errornumber;
PCRE2_SIZE erroroffset;
pcre2_code *re=
pcre2_compile((PCRE2_SPTR8) pattern, PCRE2_ZERO_TERMINATED,
PCRE2_EXTENDED | PCRE2_MULTILINE | PCRE2_DOTALL,
&errornumber, &erroroffset, nullptr);
if (!re)
{
PCRE2_UCHAR buffer[256];
pcre2_get_error_message(errornumber, buffer, sizeof(buffer));
std::cerr << "PCRE2 compilation failed at offset " << erroroffset << ": "
<< buffer << '\n';
exit(1);
}
match_data= pcre2_match_data_create_from_pattern(re, nullptr);
ovector= pcre2_get_ovector_pointer(match_data);
for (;;)
{
std::string option;
std::string enum_part;
std::string set_part;
std::vector<std::string> enum_options;
std::vector<std::string> set_options;
int rc= pcre2_match(re, (PCRE2_SPTR8) output.c_str(), output.length(),
offset, 0, match_data, nullptr);
if (rc == PCRE2_ERROR_NOMATCH)
{
break;
}
if (rc < 0)
{
std::cerr << "Matching error " << rc << '\n';
exit(1);
}
offset= ovector[1];
option= capture_group(output, ovector, 1);
std::replace(option.begin(), option.end(), '-', '_');
if (rc > 2 && ovector[2 * 2] != PCRE2_UNSET)
{
enum_part= capture_group(output, ovector, 2);
enum_options= split_list(enum_part);
}
if (rc > 3 && ovector[2 * 3] != PCRE2_UNSET)
{
set_part= capture_group(output, ovector, 3);
set_options= split_list(set_part);
}
result.options.insert(option);
if (ignore_option(&option))
continue;
if (!enum_options.empty())
{
result.enums.emplace(option, enum_options);
}
if (!set_options.empty())
{
result.sets.emplace(option, set_options);
}
}
pcre2_match_data_free(match_data);
pcre2_code_free(re);
return result;
}
void write_typelibs(std::ostream &out,
std::map<std::string, std::vector<std::string>> &map)
{
for (auto option= map.begin(); option != map.end(); ++option)
{
const std::string &option_name= (*option).first;
const std::vector<std::string> &values= (*option).second;
out << "\nstatic const char *valid_" << option_name << "_values[] = {\n";
for (auto value= values.begin(); value != values.end(); ++value)
{
out << "\"" << *value << "\",\n";
}
out << "0\n};\n";
out << "static TYPELIB valid_" << option_name << "_values_typelib = {\n"
<< "array_elements(valid_" << option_name << "_values)-1,\n"
<< "\"\", valid_" << option_name << "_values, 0, 0};\n";
}
}
void write_typelib_map(std::ostream &out, std::string name,
std::map<std::string, std::vector<std::string>> &map)
{
out << "\nstatic const char *mariadbd_" << name << "_options[] = {\n";
for (auto option= map.begin(); option != map.end(); ++option)
{
out << "\"" << (*option).first << "\",\n";
}
out << "};\n"
<< "\nstatic TYPELIB *mariadbd_" << name << "_typelibs[] = {\n";
for (auto option= map.begin(); option != map.end(); ++option)
{
out << "&valid_" << (*option).first << "_values_typelib,\n";
}
out << "};\n";
}
void write_output(const char *path, struct parsed &parsed_output)
{
std::ofstream out(path);
out << "/* Automatically generated by generate_option_list */\n\n";
out << "#ifndef _mariadbd_options_h\n";
out << "#define _mariadbd_options_h\n";
out << "static const char *mariadbd_valid_options[]= {\n";
for (auto option= parsed_output.options.begin();
option != parsed_output.options.end(); ++option)
{
out << '\"' << *option << "\",\n";
}
out << "};\n";
write_typelibs(out, parsed_output.enums);
write_typelib_map(out, "enum", parsed_output.enums);
write_typelibs(out, parsed_output.sets);
write_typelib_map(out, "set", parsed_output.sets);
out << "#endif /* _mariadbd_options_h */\n";
}
int main(int argc, const char *argv[])
{
std::string mariadbd_output;
struct parsed parsed_output;
if (argc != 5)
{
std::cerr << "usage: " << argv[0] << " <mariadbd_path> <plugin_dir> <plugin_list> <output_path>\n";
return 1;
}
MY_INIT(argv[0]);
mariadbd_output= call_mariadbd(argv[1], argv[2], argv[3]);
parsed_output= parse_output(mariadbd_output);
write_output(argv[4], parsed_output);
my_end(0);
exit(0);
}

File diff suppressed because it is too large Load Diff

View File

@@ -24,6 +24,7 @@ extern MYSQL_PLUGIN_IMPORT const char *my_defaults_extra_file;
extern const char *my_defaults_group_suffix; extern const char *my_defaults_group_suffix;
extern MYSQL_PLUGIN_IMPORT const char *my_defaults_file; extern MYSQL_PLUGIN_IMPORT const char *my_defaults_file;
extern my_bool my_defaults_mark_files; extern my_bool my_defaults_mark_files;
extern my_bool my_defaults_use_original_paths;
extern int get_defaults_options(char **argv); extern int get_defaults_options(char **argv);
extern int my_load_defaults(const char *conf_file, const char **groups, extern int my_load_defaults(const char *conf_file, const char **groups,

View File

@@ -792,6 +792,7 @@ extern char * my_path(char * to,const char *progname,
const char *own_pathname_part); const char *own_pathname_part);
extern char * my_load_path(char * to, const char *path, extern char * my_load_path(char * to, const char *path,
const char *own_path_prefix); const char *own_path_prefix);
extern char *find_file_in_path(char *to,const char *name);
extern int wild_compare(const char *str,const char *wildstr, extern int wild_compare(const char *str,const char *wildstr,
pbool str_is_pattern); pbool str_is_pattern);
extern my_bool array_append_string_unique(const char *str, extern my_bool array_append_string_unique(const char *str,

View File

@@ -0,0 +1,822 @@
#
# Testing --edit=remove and !include
#
[mysqld]
invalid=true
alter_algorithm=invalid
key_buffer_size=20M
!include MYSQLTEST_VARDIR/tmp/tmp2.cnf
[mysqld]
default_regex_flags=invalid
Updated files:
MYSQLTEST_VARDIR/tmp/tmp2.cnf
MYSQLTEST_VARDIR/tmp/tmp1.cnf
3 issue/issues fixed
[mysqld]
key_buffer_size=20M
!include MYSQLTEST_VARDIR/tmp/tmp2.cnf
#
# Testing --update --edit=last with !include
#
[mysqld]
invalid=true
alter_algorithm=invalid
key_buffer_size=20M
invalid_option
!include MYSQLTEST_VARDIR/tmp/tmp2.cnf
log-bin
# Include file start
[mysqld]
log-bin=1
log_error_verbosity = 3
Note: aria_pagecache_buffer_size=20M added to [mariadbd] group
Updated files:
MYSQLTEST_VARDIR/tmp/tmp2.cnf
MYSQLTEST_VARDIR/tmp/tmp1.cnf
8 issue/issues fixed
# Changed files
[mariadbd]
key_buffer_size=20M
#key_buffer_size=64K # Recommended value if no MyISAM tables
aria_pagecache_buffer_size=20M
[mysqld-5.7]
invalid=true
alter_algorithm=invalid
key_buffer_size=20M
invalid_option
[mysqld]
!include MYSQLTEST_VARDIR/tmp/tmp2.cnf
log-bin
# Include file start
[mysqld]
log-bin=1
[mysqld-5.7]
log_error_verbosity = 3
# Verify no more changes
Note: aria_pagecache_buffer_size=20M added to [mariadbd] group
Updated files:
MYSQLTEST_VARDIR/tmp/tmp1.cnf
No issues found
#
# Testing --edit=comment
#
[mysqld]
port=38
invalid=true
alter_algorithm=invalid
Updated files:
MYSQLTEST_VARDIR/tmp/tmp1.cnf
2 issue/issues fixed
[mysqld]
port=38
#invalid=true
#alter_algorithm=invalid
#
# Testing --edit=inline --from=mariadb
#
[mysqld]
invalid=true
invalid_option
skip-grant-tables
skip-name-resolve=0
skip-networking
skip-show-database
skip-slave-start
[mariadbd]
alter_algorithm=invalid
[other]
a=b
[mariadbd]
port=30
alter_algorithm=impossible
[other]
c=d
[mariadbd]
port=32
alter_algorithm=impossible2
port=33
[mysqld]
key_buffer_size=20M
Updated files:
MYSQLTEST_VARDIR/tmp/tmp1.cnf
5 issue/issues fixed
# Changed file
[mysqld-5.7]
invalid=true
invalid_option
[mysqld]
skip-grant-tables
skip-name-resolve=0
skip-networking
skip-show-database
skip-slave-start
[mariadbd]
[options-not-recognized-by-mariadbd]
alter_algorithm=invalid
[other]
a=b
[mariadbd]
port=30
[options-not-recognized-by-mariadbd]
alter_algorithm=impossible
[other]
c=d
[mariadbd]
port=32
[options-not-recognized-by-mariadbd]
alter_algorithm=impossible2
[mariadbd]
port=33
[mysqld]
key_buffer_size=20M
#
# Testing --edit=last --from=mariadb
#
[mysqld]
invalid=true
invalid_option
[mariadbd]
alter_algorithm=invalid
[other]
a=b
[mariadbd]
port=30
alter_algorithm=impossible
[other]
c=d
[mariadbd]
port=32
alter_algorithm=impossible2
port=33
[mysqld]
key_buffer_size=20M
Updated files:
MYSQLTEST_VARDIR/tmp/tmp1.cnf
5 issue/issues fixed
# Changed file
[mariadbd]
[other]
a=b
[mariadbd]
port=30
[other]
c=d
[mariadbd]
port=32
port=33
[mysqld]
key_buffer_size=20M
[mysqld-5.7]
invalid=true
invalid_option
[options-not-recognized-by-mariadbd]
alter_algorithm=invalid
alter_algorithm=impossible
alter_algorithm=impossible2
#
# Testing --edit=last --from=mysql
# This will fail and changes will be reverted
#
[mysqld]
invalid=true
invalid_option
[mariadbd]
alter_algorithm=invalid
[other]
a=b
[mariadbd]
port=30
alter_algorithm=impossible
[other]
c=d
[mariadbd]
port=32
alter_algorithm=impossible2
port=33
[mysqld]
key_buffer_size=20M
# Original unchanged file
[mysqld]
invalid=true
invalid_option
[mariadbd]
alter_algorithm=invalid
[other]
a=b
[mariadbd]
port=30
alter_algorithm=impossible
[other]
c=d
[mariadbd]
port=32
alter_algorithm=impossible2
port=33
[mysqld]
key_buffer_size=20M
#
# Testing mariadbd section additions with --from-mariadb
#
[mariadbd]
invalid1=true
join_buffer_size=5K
invalid2=true
[mysqld]
key_buffer_size=20M
alter_algorithm=invalid
Updated files:
MYSQLTEST_VARDIR/tmp/tmp1.cnf
3 issue/issues fixed
[mariadbd]
join_buffer_size=5K
[mysqld]
key_buffer_size=20M
[unknown]
alter_algorithm=invalid
[options-not-recognized-by-mariadbd]
invalid1=true
invalid2=true
#
# Testing key_buffer_size in mysqld section with --from=mysql
#
[mysqld]
key_buffer_size=20M
Note: aria_pagecache_buffer_size=20M added to [mariadbd] group
Updated files:
MYSQLTEST_VARDIR/tmp/tmp1.cnf
4 issue/issues fixed
[mariadbd]
key_buffer_size=20M
#key_buffer_size=64K # Recommended value if no MyISAM tables
aria_pagecache_buffer_size=20M
[mysqld-5.7]
key_buffer_size=20M
#
# Testing key_buffer_size in mysqld section with --from=mysql --no-myisam
#
[mysqld]
key_buffer_size=20M
Note: 'aria_pagecache_buffer_size=20M' added to [mariadbd] group
Updated files:
MYSQLTEST_VARDIR/tmp/tmp1.cnf
3 issue/issues fixed
[mariadbd]
key_buffer_size=64K # Recommended value if no MyISAM tables
aria_pagecache_buffer_size=20M
[mysqld-5.7]
key_buffer_size=20M
#
# Testing key_buffer_size in mariadbd section
#
[mariadbd]
key_buffer_size=20M
No issues found
[mariadbd]
key_buffer_size=20M
#
# Testing --no-myisam --edit=last
#
[mysqld]
key_buffer_size=20M
Note: 'aria_pagecache_buffer_size=20M' added to [mariadbd] group
Updated files:
MYSQLTEST_VARDIR/tmp/tmp1.cnf
3 issue/issues fixed
[mariadbd]
key_buffer_size=64K # Recommended value if no MyISAM tables
aria_pagecache_buffer_size=20M
[mysqld-5.7]
key_buffer_size=20M
#
# Testing --add-skip-start-slave
#
[mysqld]
default_week_format=1
Updated files:
MYSQLTEST_VARDIR/tmp/tmp1.cnf
1 issue/issues fixed
[mysqld]
default_week_format=1
[mariadbd]
skip_slave_start
#
# Testing --add-skip-slave-start with skip_start_slave already present
#
Updated files:
MYSQLTEST_VARDIR/tmp/tmp1.cnf
No issues found
[mariadbd]
skip_slave_start
#
# Testing audit_log part 1
#
[mysqld]
plugin_load=audit_log
audit_log-a=5
audit_log-disabled
audit_log=on
In MYSQLTEST_VARDIR/tmp/tmp1.cnf at line 2: Please replace audit_log with the server_audit plugin
Updated files:
MYSQLTEST_VARDIR/tmp/tmp1.cnf
5 issue/issues fixed
[mariadbd]
skip_slave_start
[mysqld-5.7]
plugin_load=audit_log
audit_log-a=5
audit_log-disabled
audit_log=on
#
# Testing audit_log part 2
#
[mysqld]
audit_log=ON
audit_log_file=name
Warning: Please replace audit_log with the server_audit plugin
Updated files:
MYSQLTEST_VARDIR/tmp/tmp1.cnf
3 issue/issues fixed
[mariadbd]
skip_slave_start
[mysqld-5.7]
audit_log=ON
audit_log_file=name
#
# Testing audit_log part 3
#
[mysqld]
audit_log-disabled
Warning: Please replace audit_log with the server_audit plugin
Updated files:
MYSQLTEST_VARDIR/tmp/tmp1.cnf
2 issue/issues fixed
[mariadbd]
skip_slave_start
[mysqld-5.7]
audit_log-disabled
#
# Testing comments
#
[mysqld]
character_set_server = utf8mb4 # It's a new world
collation_server = utf8mb4_0900_ai_ci
log_error_verbosity = 3
Updated files:
MYSQLTEST_VARDIR/tmp/tmp1.cnf
2 issue/issues fixed
[mysqld]
character_set_server = utf8mb4 # It's a new world
collation_server = utf8mb4_0900_ai_ci
[mariadbd]
skip_slave_start
[mysqld-5.7]
log_error_verbosity = 3
#
# Testing --fix-all
#
[mysqld]
innodb_data_file_path=/var/mysql/test2
key_buffer_size=20M
Note: 'aria_pagecache_buffer_size=20M' added to [mariadbd] group
Note: Added MySQL default character sets and collation to [mariadbd] to be able to replicate to MySQL
Updated files:
MYSQLTEST_VARDIR/tmp/tmp1.cnf
17 issue/issues fixed
[mysqld]
innodb_data_file_path=/var/mysql/test2
[mariadbd]
key_buffer_size=64K # Recommended value if no MyISAM tables
aria_pagecache_buffer_size=20M
skip_slave_start
# The following options enable MariaDB to replicate to MySQL
encrypt_binlog=0
log_bin_compress=0
# Not required, but recommended for cross_replication
binlog_format=row
# Character set to be able to replicate new tables to MySQL 8.0
character_set_server=utf8mb4
collation_server=utf8mb4_0900_ai_ci
[mysqld-5.7]
key_buffer_size=20M
# The following options enable MySQL to replicate to MariaDB
loose-binlog_row_value_options=""
loose-binlog_transaction_compression=0
# Not required, but recommended for cross_replication
binlog_format=row
#
# Testing --fix-all --update-paths
#
[mysqld]
innodb_data_file_path=/var/mysql/test2
key_buffer_size=20M
Note: 'aria_pagecache_buffer_size=20M' added to [mariadbd] group
Note: Added MySQL default character sets and collation to [mariadbd] to be able to replicate to MySQL
Updated files:
MYSQLTEST_VARDIR/tmp/tmp1.cnf
19 issue/issues fixed
[mariadbd]
innodb_data_file_path=/var/mariadb/test2
key_buffer_size=64K # Recommended value if no MyISAM tables
aria_pagecache_buffer_size=20M
skip_slave_start
# The following options enable MariaDB to replicate to MySQL
encrypt_binlog=0
log_bin_compress=0
# Not required, but recommended for cross_replication
binlog_format=row
# Character set to be able to replicate new tables to MySQL 8.0
character_set_server=utf8mb4
collation_server=utf8mb4_0900_ai_ci
[mysqld-5.7]
innodb_data_file_path=/var/mysql/test2
key_buffer_size=20M
# The following options enable MySQL to replicate to MariaDB
loose-binlog_row_value_options=""
loose-binlog_transaction_compression=0
# Not required, but recommended for cross_replication
binlog_format=row
#
# Testing path copying, without error-group and silent
#
[mysqld]
innodb_data_file_path=/var/mysql/test
port=38
dummy=/var/mysql/test
log-error=/var/mysql/test2
[mysqld-8.0]
port=39
dummy2=2
innodb_data_file_path=/var/mysql/test2
In MYSQLTEST_VARDIR/tmp/tmp1.cnf at line 2: 'innodb_data_file_path=/var/mysql/test' would be replaced with 'innodb_data_file_path=/var/mariadb/test'
In MYSQLTEST_VARDIR/tmp/tmp1.cnf at line 4: Invalid option dummy
In MYSQLTEST_VARDIR/tmp/tmp1.cnf at line 5: 'log-error=/var/mysql/test2' would be replaced with 'log-error=/var/mariadb/test2'
In MYSQLTEST_VARDIR/tmp/tmp1.cnf at line 10: 'innodb_data_file_path=/var/mysql/test2' would be replaced with 'innodb_data_file_path=/var/mariadb/test2'
2 line/lines would be copied to [mariadbd] group
5 line/lines would be copied to [mysqld-5.7] group
11 issue/issues found
MYSQLTEST_VARDIR/tmp/tmp1.cnf
# Changed file
[mysqld]
port=38
[mysqld-8.0]
port=39
dummy2=2
innodb_data_file_path=/var/mysql/test2
[mariadbd]
innodb_data_file_path=/var/mariadb/test
log-error=/var/mariadb/test2
port=39
innodb_data_file_path=/var/mariadb/test2
[mysqld-5.7]
innodb_data_file_path=/var/mysql/test
dummy=/var/mysql/test
log-error=/var/mysql/test2
#
# Testing innodb_stats_sample_pages
#
[mysqld]
innodb_stats_sample_pages=1
### File [name hidden]
[mariadbd]
innodb_stats_transient_sample_pages=1
[mysqld-5.7]
innodb_stats_sample_pages=1
In MYSQLTEST_VARDIR/tmp/tmp1.cnf at line 2: 'innodb_stats_sample_pages=1' would be replaced with 'innodb_stats_transient_sample_pages=1'
1 issue/issues found
#
# Testing innodb_log_files_in_group
#
[mysqld]
innodb_log_files_in_group=4
innodb_log_file_size=2G
# Checking file
In MYSQLTEST_VARDIR/tmp/tmp1.cnf at line 2: Invalid option innodb_log_files_in_group
1 issue/issues found
# Updating file
Note: 'innodb_log_file_size=8G' added to [mariadbd] group based on innodb_log_file_size * innodb_log_files_in_group
Updated files:
MYSQLTEST_VARDIR/tmp/tmp1.cnf
2 issue/issues fixed
# Changed file
[mysqld]
innodb_log_file_size=2G
[mariadbd]
innodb_log_file_size=8G
[mysqld-5.7]
innodb_log_files_in_group=4
# Checking if file is ok now
No issues found
#
# Test not existing character set
#
[mysqld]
character_set_server=xxx
#
# Testing --add-XXX-replication-compatibility
#
[mysqld]
port=38
character-set-server=utf8mb4
# MySQL -> MariaDB compatibility
### File MYSQLTEST_VARDIR/tmp/tmp1.cnf:
[mysqld]
port=38
character-set-server=utf8mb4
[mysqld-5.7]
# The following options enable MySQL to replicate to MariaDB
loose-binlog_row_value_options=""
loose-binlog_transaction_compression=0
# Not required, but recommended for cross_replication
binlog_format=row
# MariaDB -> MySQL compatibility
### File MYSQLTEST_VARDIR/tmp/tmp1.cnf:
[mysqld]
port=38
character-set-server=utf8mb4
[mariadbd]
# The following options enable MariaDB to replicate to MySQL
encrypt_binlog=0
log_bin_compress=0
# Not required, but recommended for cross_replication
binlog_format=row
#
# Testing --add-client-server-group
#
[mysqld]
port=38
port=39
socket="/tmp/mysql.sock"
character-set-server=utf8mb4
[server]
port=50
[mysql-8.0]
port=99
socket="/tmp/mysql8.sock"
# --add-client-server-group
### File MYSQLTEST_VARDIR/tmp/tmp1.cnf:
[mysqld]
port=38
port=39
character-set-server=utf8mb4
[server]
port=50
[mysql-8.0]
port=99
socket="/tmp/mysql8.sock"
[mariadbd]
socket="/tmp/mariadb.sock"
[mysqld-5.7]
socket="/tmp/mysql.sock"
[client-server]
port=50
socket="/tmp/mariadb.sock"
# Test 2 with update and without --update-paths
[mysqld]
port=38
port=39
socket="/tmp/mysql.sock"
innodb_log_file_size=2G
[mysql-8.0]
port=99
socket="/tmp/mysql8.sock"
Updated files:
MYSQLTEST_VARDIR/tmp/tmp1.cnf
2 issue/issues fixed
# Changed file
[mysqld]
port=38
port=39
socket="/tmp/mysql.sock"
innodb_log_file_size=2G
[mysql-8.0]
port=99
socket="/tmp/mysql8.sock"
[client-server]
port=39
socket=/tmp/mysql.sock
#
# Testing copy-mysqld-groups
#
[mysqld-8.0]
socket="/tmp/mysql.sock"
# Testing with --copy-mysqld-groups=0
No issues found
# Testing with --copy-mysqld-groups=1
1 line/lines would be copied to [mariadbd] group
1 issue/issues found
Updated files:
MYSQLTEST_VARDIR/tmp/tmp1.cnf
1 issue/issues fixed
[mysqld-8.0]
socket="/tmp/mysql.sock"
[mariadbd]
socket="/tmp/mysql.sock"
#
# Testing path changing and different generated sections
#
[mysqld]
log-error = /var/log/mysql/mysqld.log
dummy=1;
default-storage-engine=innodb
socket=/var/lib/mysql/mysql.sock
datadir=/var/lib/mysql
[server]
dummy=2;
socket=dummy;
[mysqld-8.0]
default-storage-engine=misam
port=36
qqq= hello
[mysqld]
innodb_data_file_path=/var/mysql/test
port=38
dummy=/var/mysql/test
log-error=/var/mysql/test2
[mysqld-8.0]
port=39
dummy2=3
innodb_data_file_path=/var/mysql/test2
# Output from --print --edit=last --update-paths
### File [name hidden]
[mysqld]
default-storage-engine=innodb
[server]
socket=dummy;
[mysqld-8.0]
default-storage-engine=misam
port=36
qqq= hello
[mysqld]
port=38
[mysqld-8.0]
port=39
dummy2=3
innodb_data_file_path=/var/mysql/test2
[mariadbd]
log-error = /var/log/mariadb/mysqld.log
socket=/var/lib/mariadb/mysql.sock
datadir=/var/lib/mariadb
default-storage-engine=misam
port=36
innodb_data_file_path=/var/mariadb/test
log-error=/var/mariadb/test2
port=39
innodb_data_file_path=/var/mariadb/test2
[mysqld-5.7]
log-error = /var/log/mysql/mysqld.log
dummy=1;
socket=/var/lib/mysql/mysql.sock
datadir=/var/lib/mysql
dummy=2;
innodb_data_file_path=/var/mysql/test
dummy=/var/mysql/test
log-error=/var/mysql/test2
#
# Test that second update of file with 'last' will no do anything
#
Updated files:
MYSQLTEST_VARDIR/tmp/tmp1.cnf
17 issue/issues fixed
No issues found
No issues found
"Next command should not change anything"
No issues found
[mysqld]
default-storage-engine=innodb
[server]
socket=dummy;
[mysqld-8.0]
default-storage-engine=misam
port=36
qqq= hello
[mysqld]
port=38
[mysqld-8.0]
port=39
dummy2=3
innodb_data_file_path=/var/mysql/test2
[mariadbd]
log-error = /var/log/mariadb/mysqld.log
socket=/var/lib/mariadb/mysql.sock
datadir=/var/lib/mariadb
default-storage-engine=misam
port=36
innodb_data_file_path=/var/mariadb/test
log-error=/var/mariadb/test2
port=39
innodb_data_file_path=/var/mariadb/test2
[mysqld-5.7]
log-error = /var/log/mysql/mysqld.log
dummy=1;
socket=/var/lib/mysql/mysql.sock
datadir=/var/lib/mysql
dummy=2;
innodb_data_file_path=/var/mysql/test
dummy=/var/mysql/test
log-error=/var/mysql/test2

View File

@@ -0,0 +1,603 @@
if (!$MARIADB_MIGRATE_CONFIG_FILE) {
--skip MARIADB_MIGRATE_CONFIG_FILE missing
}
--echo #
--echo # Testing --edit=remove and !include
--echo #
--write_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
[mysqld]
invalid=true
alter_algorithm=invalid
key_buffer_size=20M
EOF
--exec echo "!include $MYSQLTEST_VARDIR/tmp/tmp2.cnf" >> $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--write_file $MYSQLTEST_VARDIR/tmp/tmp2.cnf
[mysqld]
default_regex_flags=invalid
EOF
--cat_file $MYSQLTEST_VARDIR/tmp/tmp2.cnf
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MARIADB_MIGRATE_CONFIG_FILE --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf --mariadbd=$MYSQLD --update --verify --edit=remove
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--cat_file $MYSQLTEST_VARDIR/tmp/tmp2.cnf
--remove_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--remove_file $MYSQLTEST_VARDIR/tmp/tmp2.cnf
--echo #
--echo # Testing --update --edit=last with !include
--echo #
--write_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
[mysqld]
invalid=true
alter_algorithm=invalid
key_buffer_size=20M
invalid_option
EOF
--exec echo "!include $MYSQLTEST_VARDIR/tmp/tmp2.cnf" >> $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--exec echo "log-bin" >> $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--write_file $MYSQLTEST_VARDIR/tmp/tmp2.cnf
# Include file start
[mysqld]
log-bin=1
log_error_verbosity = 3
EOF
--cat_file $MYSQLTEST_VARDIR/tmp/tmp2.cnf
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MARIADB_MIGRATE_CONFIG_FILE --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf --mariadbd=$MYSQLD --update --verify --edit=last
--echo # Changed files
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--cat_file $MYSQLTEST_VARDIR/tmp/tmp2.cnf
--echo # Verify no more changes
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MARIADB_MIGRATE_CONFIG_FILE --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf --mariadbd=$MYSQLD --update --verify --edit=last
--remove_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--remove_file $MYSQLTEST_VARDIR/tmp/tmp2.cnf
--echo #
--echo # Testing --edit=comment
--echo #
--write_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
[mysqld]
port=38
invalid=true
alter_algorithm=invalid
EOF
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MARIADB_MIGRATE_CONFIG_FILE --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf --mariadbd=$MYSQLD --update --verify --edit=comment
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--remove_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--echo #
--echo # Testing --edit=inline --from=mariadb
--echo #
--write_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
[mysqld]
invalid=true
invalid_option
skip-grant-tables
skip-name-resolve=0
skip-networking
skip-show-database
skip-slave-start
[mariadbd]
alter_algorithm=invalid
[other]
a=b
[mariadbd]
port=30
alter_algorithm=impossible
[other]
c=d
[mariadbd]
port=32
alter_algorithm=impossible2
port=33
[mysqld]
key_buffer_size=20M
EOF
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MARIADB_MIGRATE_CONFIG_FILE --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf --mariadbd=$MYSQLD --update --verify --error-group=mysqld-5.7 --edit=inline --from=mariadb
--echo # Changed file
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--remove_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--echo #
--echo # Testing --edit=last --from=mariadb
--echo #
--write_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
[mysqld]
invalid=true
invalid_option
[mariadbd]
alter_algorithm=invalid
[other]
a=b
[mariadbd]
port=30
alter_algorithm=impossible
[other]
c=d
[mariadbd]
port=32
alter_algorithm=impossible2
port=33
[mysqld]
key_buffer_size=20M
EOF
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MARIADB_MIGRATE_CONFIG_FILE --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf --mariadbd=$MYSQLD --update --verify --error-group=mysqld-5.7 --edit=last --from=mariadb
--echo # Changed file
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--remove_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--echo #
--echo # Testing --edit=last --from=mysql
--echo # This will fail and changes will be reverted
--echo #
--write_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
[mysqld]
invalid=true
invalid_option
[mariadbd]
alter_algorithm=invalid
[other]
a=b
[mariadbd]
port=30
alter_algorithm=impossible
[other]
c=d
[mariadbd]
port=32
alter_algorithm=impossible2
port=33
[mysqld]
key_buffer_size=20M
EOF
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--disable_result_log
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--error 2
--exec $MARIADB_MIGRATE_CONFIG_FILE --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf --mariadbd=$MYSQLD --update --verify --error-group=mysqld-5.7 --edit=last --from=mysql --verify
--enable_result_log
--echo
--echo # Original unchanged file
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--remove_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--echo #
--echo # Testing mariadbd section additions with --from-mariadb
--echo #
--write_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
[mariadbd]
invalid1=true
join_buffer_size=5K
invalid2=true
[mysqld]
key_buffer_size=20M
alter_algorithm=invalid
EOF
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MARIADB_MIGRATE_CONFIG_FILE --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf --mariadbd=$MYSQLD --update --verify --error-group=unknown --edit=last --from=mariadb
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--remove_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--echo #
--echo # Testing key_buffer_size in mysqld section with --from=mysql
--echo #
--write_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
[mysqld]
key_buffer_size=20M
EOF
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MARIADB_MIGRATE_CONFIG_FILE --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf --mariadbd=$MYSQLD --update --verify --error-group=mysqld-5.7 --edit=last --from=mysql
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--remove_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--echo #
--echo # Testing key_buffer_size in mysqld section with --from=mysql --no-myisam
--echo #
--write_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
[mysqld]
key_buffer_size=20M
EOF
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MARIADB_MIGRATE_CONFIG_FILE --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf --mariadbd=$MYSQLD --update --verify --error-group=mysqld-5.7 --edit=last --from=mysql --no-myisam
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--remove_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--echo #
--echo # Testing key_buffer_size in mariadbd section
--echo #
--write_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
[mariadbd]
key_buffer_size=20M
EOF
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MARIADB_MIGRATE_CONFIG_FILE --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf --mariadbd=$MYSQLD --update --verify --error-group=mysqld-5.7 --edit=last
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--remove_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--echo #
--echo # Testing --no-myisam --edit=last
--echo #
--write_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
[mysqld]
key_buffer_size=20M
EOF
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MARIADB_MIGRATE_CONFIG_FILE --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf --mariadbd=$MYSQLD --update --verify --error-group=mysqld-5.7 --edit=last --no-myisam
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--remove_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--echo #
--echo # Testing --add-skip-start-slave
--echo #
--write_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
[mysqld]
default_week_format=1
EOF
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MARIADB_MIGRATE_CONFIG_FILE --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf --mariadbd=$MYSQLD --update --verify --error-group=mysqld-5.7 --edit=last --add-skip-slave-start
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--remove_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--echo #
--echo # Testing --add-skip-slave-start with skip_start_slave already present
--echo #
--write_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
[mariadbd]
skip_slave_start
EOF
#--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MARIADB_MIGRATE_CONFIG_FILE --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf --mariadbd=$MYSQLD --update --verify --error-group=mysqld-5.7 --edit=last --add-skip-slave-start
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--remove_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--echo #
--echo # Testing audit_log part 1
--echo #
--write_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
[mysqld]
plugin_load=audit_log
audit_log-a=5
audit_log-disabled
audit_log=on
EOF
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MARIADB_MIGRATE_CONFIG_FILE --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf --mariadbd=$MYSQLD --update --verify --error-group=mysqld-5.7 --edit=last --add-skip-slave-start
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--remove_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--echo #
--echo # Testing audit_log part 2
--echo #
--write_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
[mysqld]
audit_log=ON
audit_log_file=name
EOF
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MARIADB_MIGRATE_CONFIG_FILE --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf --mariadbd=$MYSQLD --update --verify --error-group=mysqld-5.7 --edit=last --add-skip-slave-start
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--remove_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--echo #
--echo # Testing audit_log part 3
--echo #
--write_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
[mysqld]
audit_log-disabled
EOF
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MARIADB_MIGRATE_CONFIG_FILE --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf --mariadbd=$MYSQLD --update --verify --error-group=mysqld-5.7 --edit=last --add-skip-slave-start
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--remove_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--echo #
--echo # Testing comments
--echo #
--write_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
[mysqld]
character_set_server = utf8mb4 # It's a new world
collation_server = utf8mb4_0900_ai_ci
log_error_verbosity = 3
EOF
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MARIADB_MIGRATE_CONFIG_FILE --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf --mariadbd=$MYSQLD --update --verify --error-group=mysqld-5.7 --edit=last --add-skip-slave-start
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--remove_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--echo #
--echo # Testing --fix-all
--echo #
--write_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
[mysqld]
innodb_data_file_path=/var/mysql/test2
key_buffer_size=20M
EOF
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MARIADB_MIGRATE_CONFIG_FILE --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf --mariadbd=$MYSQLD --update --verify --error-group=mysqld-5.7 --edit=last --fix-all
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--remove_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--echo #
--echo # Testing --fix-all --update-paths
--echo #
--write_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
[mysqld]
innodb_data_file_path=/var/mysql/test2
key_buffer_size=20M
EOF
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MARIADB_MIGRATE_CONFIG_FILE --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf --mariadbd=$MYSQLD --update --verify --error-group=mysqld-5.7 --edit=last --fix-all --update-paths
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--remove_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--echo #
--echo # Testing path copying, without error-group and silent
--echo #
--write_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
[mysqld]
innodb_data_file_path=/var/mysql/test
port=38
dummy=/var/mysql/test
log-error=/var/mysql/test2
[mysqld-8.0]
port=39
dummy2=2
innodb_data_file_path=/var/mysql/test2
EOF
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--error 2
--exec $MARIADB_MIGRATE_CONFIG_FILE --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf --update-paths --add-mariadb-replication-compatibility
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MARIADB_MIGRATE_CONFIG_FILE --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf --mariadbd="not_found_here" --update --verify --edit=last --silent --update-paths --verify=0
--echo # Changed file
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--remove_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--echo #
--echo # Testing innodb_stats_sample_pages
--echo #
--write_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
[mysqld]
innodb_stats_sample_pages=1
EOF
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--replace_regex /### File[^\n]*/### File [name hidden]/
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MARIADB_MIGRATE_CONFIG_FILE --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf --print --edit=last
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--error 2
--exec $MARIADB_MIGRATE_CONFIG_FILE --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf
--remove_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--echo #
--echo # Testing innodb_log_files_in_group
--echo #
--write_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
[mysqld]
innodb_log_files_in_group=4
innodb_log_file_size=2G
EOF
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--echo # Checking file
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--error 2
--exec $MARIADB_MIGRATE_CONFIG_FILE --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf
--echo # Updating file
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MARIADB_MIGRATE_CONFIG_FILE --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf --update --verify --edit=last --mariadbd=$MYSQLD --verify
--echo # Changed file
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--echo # Checking if file is ok now
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MARIADB_MIGRATE_CONFIG_FILE --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf --verify=0
--remove_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--echo #
--echo # Test not existing character set
--echo #
--write_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
[mysqld]
character_set_server=xxx
EOF
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--error 2
--exec $MARIADB_MIGRATE_CONFIG_FILE --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf --update --verify --edit=last --mariadbd=$MYSQLD --verify
--remove_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--echo #
--echo # Testing --add-XXX-replication-compatibility
--echo #
--write_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
[mysqld]
port=38
character-set-server=utf8mb4
EOF
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--echo # MySQL -> MariaDB compatibility
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MARIADB_MIGRATE_CONFIG_FILE --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf --print --edit=last --verify=0 --add-mariadb-replication-compatibility
--echo # MariaDB -> MySQL compatibility
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MARIADB_MIGRATE_CONFIG_FILE --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf --print --edit=last --verify=0 --add-mysql-replication-compatibility
--remove_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--echo #
--echo # Testing --add-client-server-group
--echo #
--write_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
[mysqld]
port=38
port=39
socket="/tmp/mysql.sock"
character-set-server=utf8mb4
[server]
port=50
[mysql-8.0]
port=99
socket="/tmp/mysql8.sock"
EOF
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--echo # --add-client-server-group
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MARIADB_MIGRATE_CONFIG_FILE --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf --print --edit=last --verify=0 --add-client-server-group --update-paths
--remove_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--echo # Test 2 with update and without --update-paths
--write_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
[mysqld]
port=38
port=39
socket="/tmp/mysql.sock"
innodb_log_file_size=2G
[mysql-8.0]
port=99
socket="/tmp/mysql8.sock"
EOF
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MARIADB_MIGRATE_CONFIG_FILE --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf --update --edit=last --add-client-server-group --mariadbd=$MYSQLD --verify
--echo # Changed file
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--remove_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--echo #
--echo # Testing copy-mysqld-groups
--echo #
--write_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
[mysqld-8.0]
socket="/tmp/mysql.sock"
EOF
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--echo # Testing with --copy-mysqld-groups=0
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MARIADB_MIGRATE_CONFIG_FILE --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf --update --edit=last --copy-mysqld-groups=0 --mariadbd=$MYSQLD --verify
--echo # Testing with --copy-mysqld-groups=1
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--error 2
--exec $MARIADB_MIGRATE_CONFIG_FILE --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf --copy-mysqld-groups=1
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MARIADB_MIGRATE_CONFIG_FILE --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf --update --edit=last --copy-mysqld-groups=1 --mariadbd=$MYSQLD --verify
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--remove_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--echo #
--echo # Testing path changing and different generated sections
--echo #
--write_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
[mysqld]
log-error = /var/log/mysql/mysqld.log
dummy=1;
default-storage-engine=innodb
socket=/var/lib/mysql/mysql.sock
datadir=/var/lib/mysql
[server]
dummy=2;
socket=dummy;
[mysqld-8.0]
default-storage-engine=misam
port=36
qqq= hello
[mysqld]
innodb_data_file_path=/var/mysql/test
port=38
dummy=/var/mysql/test
log-error=/var/mysql/test2
[mysqld-8.0]
port=39
dummy2=3
innodb_data_file_path=/var/mysql/test2
EOF
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--echo # Output from --print --edit=last --update-paths
--replace_regex /### File[^\n]*/### File [name hidden]/
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MARIADB_MIGRATE_CONFIG_FILE --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf --mariadbd="not_found_here" --print --edit=last --update-paths
--echo #
--echo # Test that second update of file with 'last' will no do anything
--echo #
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MARIADB_MIGRATE_CONFIG_FILE --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf --update --edit=last --update-paths --verify=0
# Check file
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MARIADB_MIGRATE_CONFIG_FILE --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf --mariadbd=$MYSQLD --copy-mysqld-groups=0
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MARIADB_MIGRATE_CONFIG_FILE --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf --update-paths --mariadbd=$MYSQLD --copy-mysqld-groups=0
--echo "Next command should not change anything"
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MARIADB_MIGRATE_CONFIG_FILE --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf --update --edit=last --update-paths --backup --verify=0
--cat_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--remove_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf

View File

@@ -4,9 +4,7 @@ flush tables;
# Check that we don't write any data to wrong or not existing datadir # Check that we don't write any data to wrong or not existing datadir
# #
[Warning] --table-cache is deprecated and will be removed in a future release. Please use --table-open-cache instead. [Warning] --table-cache is deprecated and will be removed in a future release. Please use --table-open-cache instead.
[Warning] Could not open mysql.plugin table: "Table 'mysql.plugin' doesn't exist". Some options may be missing from the help text
# #
# Check with existing directory # Check with existing directory
# #
[Warning] --table-cache is deprecated and will be removed in a future release. Please use --table-open-cache instead. [Warning] --table-cache is deprecated and will be removed in a future release. Please use --table-open-cache instead.
[Warning] Could not open mysql.plugin table: "Table 'mysql.plugin' doesn't exist". Some options may be missing from the help text

View File

@@ -1343,7 +1343,8 @@ The following specify which files/extra groups are read (specified before remain
the transaction) the transaction)
--show-slave-auth-info --show-slave-auth-info
Show user and password in SHOW SLAVE HOSTS on this master Show user and password in SHOW SLAVE HOSTS on this master
--silent-startup Don't print [Note] to the error log during startup --silent-startup Don't print [Note] or failed plugin_loads to the error
log during startup
--skip-grant-tables Start without grant tables. This gives all users FULL --skip-grant-tables Start without grant tables. This gives all users FULL
ACCESS to all tables ACCESS to all tables
--skip-host-cache Don't cache host names --skip-host-cache Don't cache host names

View File

@@ -1544,7 +1544,7 @@ sub command_line_setup {
$opt_vardir= $default_vardir; $opt_vardir= $default_vardir;
} }
# We make the path absolute, as the server will do a chdir() before usage # We make the path asbolute, as the server will do a chdir() before usage
unless ( $opt_vardir =~ m,^/, or unless ( $opt_vardir =~ m,^/, or
(IS_WINDOWS and $opt_vardir =~ m,^[a-z]:[/\\],i) ) (IS_WINDOWS and $opt_vardir =~ m,^[a-z]:[/\\],i) )
{ {
@@ -2284,6 +2284,14 @@ sub environment_setup {
"$path_client_bindir/my_print_defaults"); "$path_client_bindir/my_print_defaults");
$ENV{'MYSQL_MY_PRINT_DEFAULTS'}= native_path($exe_my_print_defaults); $ENV{'MYSQL_MY_PRINT_DEFAULTS'}= native_path($exe_my_print_defaults);
# ----------------------------------------------------
# mariadb-migrate-config-file
# ----------------------------------------------------
my $exe_mariadb_migrate_config_file=
mtr_exe_maybe_exists("$bindir/extra$multiconfig/mariadb-migrate-config-file",
"$path_client_bindir/mariadb-migrate-config-file");
$ENV{'MARIADB_MIGRATE_CONFIG_FILE'}= native_path($exe_mariadb_migrate_config_file) if $exe_mariadb_migrate_config_file;
# ---------------------------------------------------- # ----------------------------------------------------
# myisam tools # myisam tools
# ---------------------------------------------------- # ----------------------------------------------------

View File

@@ -16,8 +16,6 @@
#include "mysys_priv.h" #include "mysys_priv.h"
#include <m_string.h> #include <m_string.h>
static char *find_file_in_path(char *to,const char *name);
/* Finds where program can find it's files. /* Finds where program can find it's files.
pre_pathname is found by first locking at progname (argv[0]). pre_pathname is found by first locking at progname (argv[0]).
if progname contains path the path is returned. if progname contains path the path is returned.
@@ -82,7 +80,7 @@ char * my_path(char * to, const char *progname,
#define PATH_SEP ':' #define PATH_SEP ':'
#endif #endif
static char *find_file_in_path(char *to, const char *name) char *find_file_in_path(char *to, const char *name)
{ {
char *path,*pos,dir[2]; char *path,*pos,dir[2];
const char *ext=""; const char *ext="";

View File

@@ -52,6 +52,8 @@
*/ */
static char *file_marker= (char*)"----file-marker----"; static char *file_marker= (char*)"----file-marker----";
my_bool my_defaults_mark_files= FALSE; my_bool my_defaults_mark_files= FALSE;
my_bool my_defaults_use_original_paths= FALSE;
my_bool is_file_marker(const char* arg) my_bool is_file_marker(const char* arg)
{ {
return arg == file_marker; return arg == file_marker;
@@ -208,7 +210,7 @@ static int my_search_option_files(const char *conf_file,
goto err; goto err;
} }
} }
else if (dirname_length(conf_file)) else if (dirname_length(conf_file) || !default_directories)
{ {
if ((error= search_default_file(ctx, NullS, conf_file)) < 0) if ((error= search_default_file(ctx, NullS, conf_file)) < 0)
goto err; goto err;
@@ -325,13 +327,15 @@ int get_defaults_options(char **argv)
if (! my_defaults_group_suffix) if (! my_defaults_group_suffix)
my_defaults_group_suffix= getenv("MYSQL_GROUP_SUFFIX"); my_defaults_group_suffix= getenv("MYSQL_GROUP_SUFFIX");
if (my_defaults_extra_file && my_defaults_extra_file != extra_file_buffer) if (my_defaults_extra_file && my_defaults_extra_file != extra_file_buffer &&
! my_defaults_use_original_paths)
{ {
my_realpath(extra_file_buffer, my_defaults_extra_file, MYF(0)); my_realpath(extra_file_buffer, my_defaults_extra_file, MYF(0));
my_defaults_extra_file= extra_file_buffer; my_defaults_extra_file= extra_file_buffer;
} }
if (my_defaults_file && my_defaults_file != file_buffer) if (my_defaults_file && my_defaults_file != file_buffer &&
! my_defaults_use_original_paths)
{ {
my_realpath(file_buffer, my_defaults_file, MYF(0)); my_realpath(file_buffer, my_defaults_file, MYF(0));
my_defaults_file= file_buffer; my_defaults_file= file_buffer;
@@ -401,6 +405,8 @@ int load_defaults(const char *conf_file, const char **groups,
- 1 is returned if the given conf_file didn't exist. In this case, the - 1 is returned if the given conf_file didn't exist. In this case, the
value pointed to by default_directories is undefined. value pointed to by default_directories is undefined.
- 4 is returned --print-defaults was used. The caller should just do exit(0)
in this ase
*/ */

View File

@@ -202,6 +202,7 @@ error:
/* /*
Remove directory recursively. Remove directory recursively.
Symlinks are deleted, not followed
*/ */
int my_rmtree(const char *dir, myf MyFlags) int my_rmtree(const char *dir, myf MyFlags)
{ {
@@ -210,7 +211,9 @@ int my_rmtree(const char *dir, myf MyFlags)
int err = 0; int err = 0;
size_t i; size_t i;
MY_DIR *dir_info = my_dir(dir, MYF(MY_DONT_SORT | MY_WANT_STAT)); MY_DIR *dir_info = my_dir(dir,
MYF(MY_DONT_SORT | MY_WANT_STAT |
(MyFlags & (MY_NOSYMLINKS | MY_WME))));
if (!dir_info) if (!dir_info)
return 1; return 1;
@@ -225,7 +228,7 @@ int my_rmtree(const char *dir, myf MyFlags)
if (!MY_S_ISDIR(file->mystat->st_mode)) if (!MY_S_ISDIR(file->mystat->st_mode))
{ {
err = my_delete(path, MyFlags); err = my_delete(path, (MyFlags & ~MY_NOSYMLINKS));
#ifdef _WIN32 #ifdef _WIN32
/* /*
On Windows, check and possible reset readonly attribute. On Windows, check and possible reset readonly attribute.

View File

@@ -350,11 +350,19 @@ MY_STAT *my_stat(const char *path, MY_STAT *stat_area, myf my_flags)
if ((m_used= (stat_area == NULL))) if ((m_used= (stat_area == NULL)))
if (!(stat_area= (MY_STAT *) my_malloc(key_memory_MY_STAT, sizeof(MY_STAT), if (!(stat_area= (MY_STAT *) my_malloc(key_memory_MY_STAT, sizeof(MY_STAT),
my_flags))) my_flags)))
goto error; goto err;
#ifndef _WIN32 #ifndef _WIN32
if (!stat((char *) path, (struct stat *) stat_area))
{ {
DBUG_RETURN(stat_area); int error;
if (my_flags & MY_NOSYMLINKS)
error= lstat((char *) path, (struct stat *) stat_area);
else
error= stat((char *) path, (struct stat *) stat_area);
if (!error)
{
DBUG_RETURN(stat_area);
}
} }
#else #else
if (!my_win_stat(path, stat_area)) if (!my_win_stat(path, stat_area))
@@ -365,7 +373,7 @@ MY_STAT *my_stat(const char *path, MY_STAT *stat_area, myf my_flags)
if (m_used) /* Free if new area */ if (m_used) /* Free if new area */
my_free(stat_area); my_free(stat_area);
error: err:
if (my_flags & (MY_FAE+MY_WME)) if (my_flags & (MY_FAE+MY_WME))
{ {
my_error(EE_STAT, MYF(ME_BELL), path, my_errno); my_error(EE_STAT, MYF(ME_BELL), path, my_errno);

View File

@@ -338,7 +338,7 @@ PSI_statement_info stmt_info_rpl;
static bool lower_case_table_names_used= 0; static bool lower_case_table_names_used= 0;
static bool volatile select_thread_in_use, signal_thread_in_use; static bool volatile select_thread_in_use, signal_thread_in_use;
static my_bool opt_debugging= 0, opt_external_locking= 0, opt_console= 0; static my_bool opt_debugging= 0, opt_external_locking= 0, opt_console= 0;
static my_bool opt_short_log_format= 0, opt_silent_startup= 0; static my_bool opt_short_log_format= 0;
ulong max_used_connections; ulong max_used_connections;
time_t max_used_connections_time; time_t max_used_connections_time;
@@ -375,6 +375,7 @@ uint opt_bin_log_compress_min_len;
my_bool opt_log, debug_assert_if_crashed_table= 0, opt_help= 0; my_bool opt_log, debug_assert_if_crashed_table= 0, opt_help= 0;
my_bool debug_assert_on_not_freed_memory= 0; my_bool debug_assert_on_not_freed_memory= 0;
my_bool disable_log_notes, opt_support_flashback= 0; my_bool disable_log_notes, opt_support_flashback= 0;
my_bool opt_silent_startup= 0;
static my_bool opt_abort; static my_bool opt_abort;
ulonglong log_output_options; ulonglong log_output_options;
my_bool opt_userstat_running; my_bool opt_userstat_running;
@@ -6924,8 +6925,10 @@ struct my_option my_long_options[]=
"Show user and password in SHOW SLAVE HOSTS on this master", "Show user and password in SHOW SLAVE HOSTS on this master",
&opt_show_slave_auth_info, &opt_show_slave_auth_info, 0, &opt_show_slave_auth_info, &opt_show_slave_auth_info, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"silent-startup", OPT_SILENT, "Don't print [Note] to the error log during startup", {"silent-startup", OPT_SILENT, "Don't print [Note] or failed plugin_loads "
&opt_silent_startup, &opt_silent_startup, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, "to the error log during startup",
&opt_silent_startup, &opt_silent_startup, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"skip-host-cache", OPT_SKIP_HOST_CACHE, "Don't cache host names", 0, 0, 0, {"skip-host-cache", OPT_SKIP_HOST_CACHE, "Don't cache host names", 0, 0, 0,
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"skip-slave-start", 0, {"skip-slave-start", 0,

View File

@@ -122,6 +122,7 @@ extern MYSQL_PLUGIN_IMPORT bool volatile abort_loop;
extern my_bool opt_safe_user_create; extern my_bool opt_safe_user_create;
extern my_bool opt_local_infile, opt_myisam_use_mmap; extern my_bool opt_local_infile, opt_myisam_use_mmap;
extern my_bool opt_slave_compressed_protocol, use_temp_pool; extern my_bool opt_slave_compressed_protocol, use_temp_pool;
extern my_bool opt_silent_startup;
extern ulong slave_exec_mode_options, slave_ddl_exec_mode_options; extern ulong slave_exec_mode_options, slave_ddl_exec_mode_options;
extern ulong slave_retried_transactions; extern ulong slave_retried_transactions;
extern ulong transactions_multi_engine; extern ulong transactions_multi_engine;

View File

@@ -1215,7 +1215,7 @@ public:
done before any other THD constructors and decrement - after any other THD done before any other THD constructors and decrement - after any other THD
destructors. destructors.
Destructor unblocks close_conneciton() if there are no more THD's left. Destructor unblocks close_connection() if there are no more THD's left.
*/ */
struct THD_count struct THD_count
{ {

View File

@@ -545,7 +545,9 @@ static my_bool read_mysql_plugin_info(struct st_plugin_dl *plugin_dl,
/* Determine interface version */ /* Determine interface version */
if (!sym) 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); DBUG_RETURN(TRUE);
} }
plugin_dl->mariaversion= 0; 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 Actually this branch impossible because in case of absence of maria
version we try mysql version. version we try mysql version.
*/ */
my_error(ER_CANT_FIND_DL_ENTRY, MyFlags, if (!opt_silent_startup)
maria_plugin_interface_version_sym, dlpath); my_error(ER_CANT_FIND_DL_ENTRY, MyFlags,
maria_plugin_interface_version_sym, dlpath);
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
plugin_dl->mariaversion= *(int *)sym; 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 */ /* Open new dll handle */
if (!(plugin_dl.handle= dlopen(dlpath, RTLD_NOW))) 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; goto ret;
} }
dlopen_count++; dlopen_count++;
@@ -822,7 +827,8 @@ static st_plugin_dl *plugin_dl_add(const LEX_CSTRING *dl, myf MyFlags)
my_snprintf(buf, sizeof(buf), my_snprintf(buf, sizeof(buf),
"service '%s' interface version mismatch", "service '%s' interface version mismatch",
list_of_services[i].name); 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; goto ret;
} }
tmp_backup[plugin_dl.nbackups++].save(ptr); 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 NOTE
Requires that a write-lock is held on LOCK_system_variables_hash 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, static enum install_status
const LEX_CSTRING *name, LEX_CSTRING *dl, myf MyFlags) 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_plugin_int tmp, *maybe_dupe;
struct st_maria_plugin *plugin; 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 && if (!name->str &&
(maybe_dupe= plugin_find_internal(&tmp.name, MYSQL_ANY_PLUGIN))) (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); my_error(ER_UDF_EXISTS, MyFlags, plugin->name);
DBUG_RETURN(INSTALL_FAIL_NOT_OK); 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) 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", if (!opt_silent_startup)
tmp.name.str, sql_print_warning("Plugin '%s' is of maturity level %s while the server is %s",
plugin_maturity_names[plugin->maturity], tmp.name.str,
plugin_maturity_names[SERVER_MATURITY_LEVEL]); plugin_maturity_names[plugin->maturity],
plugin_maturity_names[SERVER_MATURITY_LEVEL]);
} }
tmp.plugin= plugin; tmp.plugin= plugin;
@@ -1910,14 +1918,10 @@ static void plugin_load(MEM_ROOT *tmp_root)
if (result) if (result)
{ {
DBUG_PRINT("error",("Can't open plugin table")); 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\". " sql_print_error("Could not open mysql.plugin table: \"%s\". "
"Some plugins may be not loaded", "Some plugins may be not loaded",
new_thd->get_stmt_da()->message()); 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; goto end;
} }
@@ -2003,8 +2007,10 @@ static bool plugin_load_list(MEM_ROOT *tmp_root, const char *list)
{ {
char buffer[FN_REFLEN]; char buffer[FN_REFLEN];
LEX_CSTRING name= {buffer, 0}, dl= {NULL, 0}, *str= &name; LEX_CSTRING name= {buffer, 0}, dl= {NULL, 0}, *str= &name;
bool got_error= 0;
char *p= buffer; char *p= buffer;
DBUG_ENTER("plugin_load_list"); DBUG_ENTER("plugin_load_list");
while (list) while (list)
{ {
if (p == buffer + sizeof(buffer) - 1) 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 */ list= NULL; /* terminate the loop */
/* fall through */ /* fall through */
case ';': case ';':
#ifndef _WIN32 case ':':
case ':': /* can't use this as delimiter as it may be drive letter */
#endif
p[-1]= 0; p[-1]= 0;
if (str == &name) // load all plugins in named module 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++; str->length++;
continue; continue;
} }
}
DBUG_RETURN(FALSE);
error: error:
mysql_mutex_unlock(&LOCK_plugin); got_error= 1;
if (name.str) mysql_mutex_unlock(&LOCK_plugin);
sql_print_error("Couldn't load plugin '%s' from '%s'.", if (!opt_silent_startup)
name.str, dl.str); {
else if (name.str)
sql_print_error("Couldn't load plugins from '%s'.", dl.str); sql_print_error("Couldn't load plugin '%s' from '%s'.",
DBUG_RETURN(TRUE); 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)) (opt->flags & PLUGIN_VAR_MEMALLOC))
{ {
char *def_val= *(char**)var_def_ptr(opt); 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; *(char**)val= def_val ? my_strdup(PSI_INSTRUMENT_ME, def_val, MYF(0)) : NULL;
} }
else else