summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/completion_hash.cc3
-rw-r--r--client/mysqldump.c593
-rw-r--r--cmake/Internal/CPack/CPackRPM.cmake42
-rw-r--r--include/my_sys.h7
m---------libmariadb0
-rw-r--r--man/mysqldump.1117
-rw-r--r--mysql-test/main/alter_user.result4
-rw-r--r--mysql-test/main/alter_user.test3
-rw-r--r--mysql-test/main/mysqldump-system,win.rdiff21
-rw-r--r--mysql-test/main/mysqldump-system.result497
-rw-r--r--mysql-test/main/mysqldump-system.test155
-rw-r--r--mysql-test/main/mysqldump.result5
-rw-r--r--mysql-test/main/set_password.result20
-rw-r--r--mysql-test/main/set_password.test19
-rw-r--r--mysql-test/suite/innodb/r/instant_alter_bugs.result12
-rw-r--r--mysql-test/suite/innodb/t/instant_alter_bugs.test13
-rw-r--r--mysql-test/suite/wsrep/r/variables.result125
-rw-r--r--mysql-test/suite/wsrep/t/variables.test14
-rw-r--r--mysys/array.c5
-rw-r--r--mysys/my_alloc.c2
-rw-r--r--plugin/server_audit/server_audit.c8
-rw-r--r--sql/field.cc8
-rw-r--r--sql/handler.h6
-rw-r--r--sql/item_func.cc3
-rw-r--r--sql/item_sum.cc14
-rw-r--r--sql/lex_string.h6
-rw-r--r--sql/mf_iocache_encr.cc15
-rw-r--r--sql/opt_range.cc107
-rw-r--r--sql/opt_split.cc12
-rw-r--r--sql/sql_acl.cc12
-rw-r--r--sql/sql_class.cc3
-rw-r--r--sql/sql_join_cache.cc3
-rw-r--r--sql/sql_lex.cc3
-rw-r--r--sql/sql_prepare.cc22
-rw-r--r--sql/sql_select.cc6
-rw-r--r--sql/sql_string.cc9
-rw-r--r--sql/table.h3
-rw-r--r--sql/unireg.cc7
-rw-r--r--sql/unireg.h3
-rw-r--r--storage/innobase/handler/handler0alter.cc3
-rw-r--r--storage/myisam/mi_key.c7
-rw-r--r--storage/perfschema/pfs_setup_object.cc14
-rw-r--r--strings/ctype-bin.c4
-rw-r--r--strings/ctype-tis620.c6
44 files changed, 1705 insertions, 236 deletions
diff --git a/client/completion_hash.cc b/client/completion_hash.cc
index 0bfb4e879e4..0a13b79084f 100644
--- a/client/completion_hash.cc
+++ b/client/completion_hash.cc
@@ -205,7 +205,8 @@ Bucket *find_longest_match(HashTable *ht, char *str, uint length,
void completion_hash_clean(HashTable *ht)
{
free_root(&ht->mem_root,MYF(0));
- bzero((char*) ht->arBuckets,ht->nTableSize*sizeof(Bucket *));
+ if (size_t s= ht->nTableSize)
+ bzero((char*) ht->arBuckets, s * sizeof(Bucket *));
}
diff --git a/client/mysqldump.c b/client/mysqldump.c
index 4f5bb02d0c2..da4ec2756eb 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -39,7 +39,8 @@
** 10 Jun 2003: SET NAMES and --no-set-names by Alexander Barkov
*/
-#define DUMP_VERSION "10.18"
+/* on merge conflict, bump to a higher version again */
+#define DUMP_VERSION "10.19"
#include <my_global.h>
#include <my_sys.h>
@@ -119,6 +120,21 @@ static my_bool verbose= 0, opt_no_create_info= 0, opt_no_data= 0, opt_no_data_m
opt_events= 0, opt_comments_used= 0,
opt_alltspcs=0, opt_notspcs= 0, opt_logging,
opt_drop_trigger= 0 ;
+#define OPT_SYSTEM_ALL 1
+#define OPT_SYSTEM_USERS 2
+#define OPT_SYSTEM_PLUGINS 4
+#define OPT_SYSTEM_UDFS 8
+#define OPT_SYSTEM_SERVERS 16
+#define OPT_SYSTEM_STATS 32
+#define OPT_SYSTEM_TIMEZONES 64
+static const char *opt_system_type_values[]=
+ {"all", "users", "plugins", "udfs", "servers", "stats", "timezones"};
+static TYPELIB opt_system_types=
+{
+ array_elements(opt_system_type_values), "system dump options",
+ opt_system_type_values, NULL
+};
+static ulonglong opt_system= 0ULL;
static my_bool insert_pat_inited= 0, debug_info_flag= 0, debug_check_flag= 0,
select_field_names_inited= 0;
static ulong opt_max_allowed_packet, opt_net_buffer_length;
@@ -533,6 +549,8 @@ static struct my_option my_long_options[] =
&opt_mysql_unix_port, &opt_mysql_unix_port, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#include <sslopt-longopts.h>
+ {"system", 256, "Dump system tables as portable SQL",
+ &opt_system, &opt_system, &opt_system_types, GET_SET, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"tab",'T',
"Create tab-separated textfile for each table to given path. (Create .sql "
"and .txt files.) NOTE: This only works if mysqldump is run on the same "
@@ -576,7 +594,7 @@ static const char *load_default_groups[]=
static void maybe_exit(int error);
static void die(int error, const char* reason, ...);
static void maybe_die(int error, const char* reason, ...);
-static void write_header(FILE *sql_file, char *db_name);
+static void write_header(FILE *sql_file, const char *db_name);
static void print_value(FILE *file, MYSQL_RES *result, MYSQL_ROW row,
const char *prefix,const char *name,
int string_value);
@@ -587,6 +605,12 @@ static int init_dumping_tables(char *);
static int init_dumping(char *, int init_func(char*));
static int dump_databases(char **);
static int dump_all_databases();
+static int dump_all_users_roles_and_grants();
+static int dump_all_plugins();
+static int dump_all_udfs();
+static int dump_all_servers();
+static int dump_all_stats();
+static int dump_all_timezones();
static char *quote_name(const char *name, char *buff, my_bool force);
char check_if_ignore_table(const char *table_name, char *table_type);
static char *primary_key_fields(const char *table_name);
@@ -648,9 +672,10 @@ static void print_version(void)
static void short_usage_sub(FILE *f)
{
fprintf(f, "Usage: %s [OPTIONS] database [tables]\n", my_progname_short);
- fprintf(f, "OR %s [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]\n",
+ fprintf(f, "OR %s [OPTIONS] --databases DB1 [DB2 DB3...]\n",
my_progname_short);
- fprintf(f, "OR %s [OPTIONS] --all-databases [OPTIONS]\n", my_progname_short);
+ fprintf(f, "OR %s [OPTIONS] --all-databases\n", my_progname_short);
+ fprintf(f, "OR %s [OPTIONS] --system=[SYSTEMOPTIONS]]\n", my_progname_short);
}
@@ -698,7 +723,7 @@ static const char *fix_for_comment(const char *ident)
}
-static void write_header(FILE *sql_file, char *db_name)
+static void write_header(FILE *sql_file, const char *db_name)
{
if (opt_xml)
{
@@ -1048,6 +1073,100 @@ static int get_options(int *argc, char ***argv)
if ((ho_error= handle_options(argc, argv, my_long_options, get_one_option)))
return(ho_error);
+ if (opt_system & OPT_SYSTEM_ALL)
+ opt_system|= ~0;
+
+ if (opt_system & OPT_SYSTEM_USERS &&
+ (my_hash_insert(&ignore_table,
+ (uchar*) my_strdup(PSI_NOT_INSTRUMENTED,
+ "mysql.db", MYF(MY_WME))) ||
+ my_hash_insert(&ignore_table,
+ (uchar*) my_strdup(PSI_NOT_INSTRUMENTED,
+ "mysql.global_priv", MYF(MY_WME))) ||
+ my_hash_insert(&ignore_table,
+ (uchar*) my_strdup(PSI_NOT_INSTRUMENTED,
+ "mysql.tables_priv", MYF(MY_WME))) ||
+ my_hash_insert(&ignore_table,
+ (uchar*) my_strdup(PSI_NOT_INSTRUMENTED,
+ "mysql.columns_priv", MYF(MY_WME))) ||
+ my_hash_insert(&ignore_table,
+ (uchar*) my_strdup(PSI_NOT_INSTRUMENTED,
+ "mysql.procs_priv", MYF(MY_WME))) ||
+ my_hash_insert(&ignore_table,
+ (uchar*) my_strdup(PSI_NOT_INSTRUMENTED,
+ "mysql.user", MYF(MY_WME))) ||
+ my_hash_insert(&ignore_table,
+ (uchar*) my_strdup(PSI_NOT_INSTRUMENTED,
+ "mysql.host", MYF(MY_WME))) ||
+ my_hash_insert(&ignore_table,
+ (uchar*) my_strdup(PSI_NOT_INSTRUMENTED,
+ "mysql.proxies_priv", MYF(MY_WME))) ||
+ my_hash_insert(&ignore_table,
+ (uchar*) my_strdup(PSI_NOT_INSTRUMENTED,
+ "mysql.roles_mapping", MYF(MY_WME))) ||
+ /* and MySQL-8.0 role tables (role_edges and default_roles) as well */
+ my_hash_insert(&ignore_table,
+ (uchar*) my_strdup(PSI_NOT_INSTRUMENTED,
+ "mysql.role_edges", MYF(MY_WME))) ||
+ my_hash_insert(&ignore_table,
+ (uchar*) my_strdup(PSI_NOT_INSTRUMENTED,
+ "mysql.default_roles", MYF(MY_WME)))))
+ return(EX_EOM);
+
+ if (opt_system & OPT_SYSTEM_PLUGINS &&
+ my_hash_insert(&ignore_table,
+ (uchar*) my_strdup(PSI_NOT_INSTRUMENTED,
+ "mysql.plugin", MYF(MY_WME))))
+ return(EX_EOM);
+
+ if (opt_system & OPT_SYSTEM_UDFS &&
+ my_hash_insert(&ignore_table,
+ (uchar*) my_strdup(PSI_NOT_INSTRUMENTED,
+ "mysql.func", MYF(MY_WME))))
+ return(EX_EOM);
+
+ if (opt_system & OPT_SYSTEM_SERVERS &&
+ my_hash_insert(&ignore_table,
+ (uchar*) my_strdup(PSI_NOT_INSTRUMENTED,
+ "mysql.servers", MYF(MY_WME))))
+ return(EX_EOM);
+
+ if (opt_system & OPT_SYSTEM_STATS &&
+ (my_hash_insert(&ignore_table,
+ (uchar*) my_strdup(PSI_NOT_INSTRUMENTED,
+ "mysql.column_stats", MYF(MY_WME))) ||
+ my_hash_insert(&ignore_table,
+ (uchar*) my_strdup(PSI_NOT_INSTRUMENTED,
+ "mysql.index_stats", MYF(MY_WME))) ||
+ my_hash_insert(&ignore_table,
+ (uchar*) my_strdup(PSI_NOT_INSTRUMENTED,
+ "mysql.table_stats", MYF(MY_WME))) ||
+ my_hash_insert(&ignore_table,
+ (uchar*) my_strdup(PSI_NOT_INSTRUMENTED,
+ "mysql.innodb_table_stats", MYF(MY_WME))) ||
+ my_hash_insert(&ignore_table,
+ (uchar*) my_strdup(PSI_NOT_INSTRUMENTED,
+ "mysql.innodb_index_stats", MYF(MY_WME)))))
+ return(EX_EOM);
+
+ if (opt_system & OPT_SYSTEM_TIMEZONES &&
+ (my_hash_insert(&ignore_table,
+ (uchar*) my_strdup(PSI_NOT_INSTRUMENTED,
+ "mysql.time_zone", MYF(MY_WME))) ||
+ my_hash_insert(&ignore_table,
+ (uchar*) my_strdup(PSI_NOT_INSTRUMENTED,
+ "mysql.time_zone_leap_second", MYF(MY_WME))) ||
+ my_hash_insert(&ignore_table,
+ (uchar*) my_strdup(PSI_NOT_INSTRUMENTED,
+ "mysql.time_zone_name", MYF(MY_WME))) ||
+ my_hash_insert(&ignore_table,
+ (uchar*) my_strdup(PSI_NOT_INSTRUMENTED,
+ "mysql.time_zone_transition", MYF(MY_WME))) ||
+ my_hash_insert(&ignore_table,
+ (uchar*) my_strdup(PSI_NOT_INSTRUMENTED,
+ "mysql.time_zone_transition_type", MYF(MY_WME)))))
+ return(EX_EOM);
+
*mysql_params->p_max_allowed_packet= opt_max_allowed_packet;
*mysql_params->p_net_buffer_length= opt_net_buffer_length;
if (debug_info_flag)
@@ -1112,7 +1231,7 @@ static int get_options(int *argc, char ***argv)
!(charset_info= get_charset_by_csname(default_charset,
MY_CS_PRIMARY, MYF(MY_WME))))
exit(1);
- if ((*argc < 1 && !opt_alldbs) || (*argc > 0 && opt_alldbs))
+ if ((*argc < 1 && (!opt_alldbs && !opt_system)) || (*argc > 0 && opt_alldbs))
{
short_usage(stderr);
return EX_USAGE;
@@ -1236,7 +1355,6 @@ static int fetch_db_collation(const char *db_name,
my_bool err_status= FALSE;
MYSQL_RES *db_cl_res;
MYSQL_ROW db_cl_row;
-
if (mysql_select_db(mysql, db_name))
{
DB_error(mysql, "when selecting the database");
@@ -2821,7 +2939,7 @@ static void get_sequence_structure(const char *seq, const char *db)
number of fields in table, 0 if error
*/
-static uint get_table_structure(char *table, char *db, char *table_type,
+static uint get_table_structure(const char *table, const char *db, char *table_type,
char *ignore_flag)
{
my_bool init=0, delayed, write_data, complete_insert;
@@ -3790,7 +3908,7 @@ static char *alloc_query_str(size_t size)
*/
-static void dump_table(char *table, char *db, const uchar *hash_key, size_t len)
+static void dump_table(const char *table, const char *db, const uchar *hash_key, size_t len)
{
char ignore_flag;
char buf[200], table_buff[NAME_LEN+3];
@@ -4340,6 +4458,442 @@ static char *getTableName(int reset)
/*
+ dump user/role grants
+ ARGS
+ user_role: is either a user, or a role
+*/
+
+static int dump_grants(const char *user_role)
+{
+ DYNAMIC_STRING sqlbuf;
+ MYSQL_ROW row;
+ MYSQL_RES *tableres;
+
+ init_dynamic_string_checked(&sqlbuf, "SHOW GRANTS FOR ", 256, 1024);
+ dynstr_append_checked(&sqlbuf, user_role);
+
+ if (mysql_query_with_error_report(mysql, &tableres, sqlbuf.str))
+ {
+ dynstr_free(&sqlbuf);
+ return 1;
+ }
+ while ((row= mysql_fetch_row(tableres)))
+ {
+ if (strncmp(row[0], "SET DEFAULT ROLE", sizeof("SET DEFAULT ROLE") - 1) == 0)
+ continue;
+ fprintf(md_result_file, "%s;\n", row[0]);
+ }
+ mysql_free_result(tableres);
+ dynstr_free(&sqlbuf);
+ return 0;
+}
+
+
+/*
+ dump create user
+*/
+
+static int dump_create_user(const char *user)
+{
+ DYNAMIC_STRING sqlbuf;
+ MYSQL_ROW row;
+ MYSQL_RES *tableres;
+
+ init_dynamic_string_checked(&sqlbuf, "SHOW CREATE USER ", 256, 1024);
+ dynstr_append_checked(&sqlbuf, user);
+
+ if (mysql_query_with_error_report(mysql, &tableres, sqlbuf.str))
+ {
+ dynstr_free(&sqlbuf);
+ return 1;
+ }
+ while ((row= mysql_fetch_row(tableres)))
+ {
+ fprintf(md_result_file, "CREATE %sUSER %s%s;\n", opt_replace_into ? "/*M!100103 OR REPLACE */ ": "",
+ opt_ignore ? "IF NOT EXISTS " : "",
+ row[0] + sizeof("CREATE USER"));
+ }
+ mysql_free_result(tableres);
+ dynstr_free(&sqlbuf);
+ return 0;
+}
+
+
+/*
+ dump all users, roles and their grants
+*/
+
+static int dump_all_users_roles_and_grants()
+{
+ MYSQL_ROW row;
+ MYSQL_RES *tableres;
+ int result= 0;
+ /* Roles added in MariaDB-10.0.5 or MySQL-8.0 */
+ my_bool maria_roles_exist= (mysql_get_server_version(mysql) >= 100005);
+ my_bool mysql_roles_exist= (mysql_get_server_version(mysql) >= 80001) && !maria_roles_exist;
+
+ if (mysql_query_with_error_report(mysql, &tableres,
+ "SELECT CONCAT(QUOTE(u.user), '@', QUOTE(u.Host)) AS u "
+ "FROM mysql.user u "
+ " /*!80001 LEFT JOIN mysql.role_edges e "
+ " ON u.user=e.from_user "
+ " AND u.host=e.from_host "
+ " WHERE e.from_user IS NULL */"
+ " /*M!100005 WHERE is_role='N' */"))
+ return 1;
+ while ((row= mysql_fetch_row(tableres)))
+ {
+ if (opt_replace_into)
+ /* Protection against removing the current import user */
+ /* MySQL-8.0 export capability */
+ fprintf(md_result_file,
+ "DELIMITER |\n"
+ "/*M!100101 IF current_user()=\"%s\" THEN\n"
+ " SIGNAL SQLSTATE '45000' SET MYSQL_ERRNO=30001,"
+ " MESSAGE_TEXT=\"Don't remove current user %s'\";\n"
+ "END IF */|\n"
+ "DELIMITER ;\n"
+ "/*!50701 DROP USER IF EXISTS %s */;\n", row[0], row[0], row[0]);
+ if (dump_create_user(row[0]))
+ result= 1;
+ /* if roles exist, defer dumping grants until after roles created */
+ if (maria_roles_exist || mysql_roles_exist)
+ continue;
+ if (dump_grants(row[0]))
+ result= 1;
+ }
+ mysql_free_result(tableres);
+
+ if (!(maria_roles_exist || mysql_roles_exist))
+ goto exit;
+
+ /*
+ Preserve current role active role, in case this dump is imported
+ in the same connection that assumes the active role at the beginning
+ is the same as at the end of the connection. This is so:
+
+ #!/bin/sh
+ (
+ echo "set role special_role; ";
+ cat mysqldump.sql;
+ echo "$dosomethingspecial"
+ ) | mysql -h $host
+
+ doesn't end up with a suprise that the $dosomethingspecial cannot
+ be done because `special_role` isn't active.
+
+ We create a new role for importing that becomes the default admin for new
+ roles. This is because without being a admin on new roles we don't
+ have the necessary privileges to grant users to a created role or to
+ create new admins for the created role.
+
+ At the end of the import the mariadb_dump_import_role is be dropped,
+ which implictly drops all its admin aspects of the dropped role.
+ This is significiantly easlier than revoking the ADMIN of each role
+ from the current user.
+ */
+ fputs("SELECT COALESCE(CURRENT_ROLE(),'NONE') into @current_role;\n"
+ "CREATE ROLE IF NOT EXISTS mariadb_dump_import_role;\n"
+ "GRANT mariadb_dump_import_role TO CURRENT_USER();\n"
+ "SET ROLE mariadb_dump_import_role;\n"
+ , md_result_file);
+ /* No show create role yet, MDEV-22311 */
+ /* Roles, with user admins first, then roles they administer, and recurse on that */
+ if (maria_roles_exist && mysql_query_with_error_report(mysql, &tableres,
+ "WITH RECURSIVE create_role_order AS"
+ " (SELECT 1 as n, roles_mapping.*"
+ " FROM mysql.roles_mapping"
+ " JOIN mysql.user USING (user,host)"
+ " WHERE is_role='N'"
+ " AND Admin_option='Y'"
+ " UNION SELECT c.n+1, r.*"
+ " FROM create_role_order c"
+ " JOIN mysql.roles_mapping r ON c.role=r.user"
+ " AND r.host=''"
+ " AND r.Admin_option='Y') "
+ "SELECT QUOTE(ROLE) AS r,"
+ " CONCAT(QUOTE(user),"
+ " IF(HOST='', '', CONCAT('@', QUOTE(HOST)))) AS c,"
+ " Admin_option "
+ "FROM create_role_order ORDER BY n, r, user"))
+ return 1;
+ /*
+ TODO Mysql - misses roles that have no admin or role members.
+ MySQL roles don't require an admin.
+ */
+ if (mysql_roles_exist && mysql_query_with_error_report(mysql, &tableres,
+ "WITH RECURSIVE create_role_order AS"
+ " (SELECT 1 AS n,"
+ " re.*"
+ " FROM mysql.role_edges re"
+ " JOIN mysql.user u ON re.TO_HOST=u.HOST"
+ " AND re.TO_USER = u.USER"
+ " LEFT JOIN mysql.role_edges re2 ON re.TO_USER=re2.FROM_USER"
+ " AND re2.TO_HOST=re2.FROM_HOST"
+ " WHERE re2.FROM_USER IS NULL"
+ " UNION SELECT c.n+1,"
+ " re.*"
+ " FROM create_role_order c"
+ " JOIN mysql.role_edges re ON c.FROM_USER=re.TO_USER"
+ " AND c.FROM_HOST=re.TO_HOST) "
+ "SELECT CONCAT(QUOTE(FROM_USER), '/*!80001 @', QUOTE(FROM_HOST), '*/') AS r,"
+ " CONCAT(QUOTE(TO_USER), IF(n=1, CONCAT('@', QUOTE(TO_HOST)),"
+ " CONCAT('/*!80001 @', QUOTE(TO_HOST), ' */'))) AS u,"
+ " WITH_ADMIN_OPTION "
+ "FROM create_role_order "
+ "ORDER BY n,"
+ " FROM_USER,"
+ " FROM_HOST,"
+ " TO_USER,"
+ " TO_HOST,"
+ " WITH_ADMIN_OPTION"))
+ return 1;
+ while ((row= mysql_fetch_row(tableres)))
+ {
+ /* MySQL-8.0 export capability */
+ if (opt_replace_into)
+ fprintf(md_result_file,
+ "/*!80001 DROP ROLE IF EXISTS %s */;\n", row[0]);
+ fprintf(md_result_file,
+ "/*!80001 CREATE ROLE %s%s */;\n", opt_ignore ? "IF NOT EXISTS " : "", row[0]);
+ /* By default created with current role */
+ fprintf(md_result_file,
+ "%sROLE %s%s WITH ADMIN mariadb_dump_import_role */;\n",
+ opt_replace_into ? "/*M!100103 CREATE OR REPLACE ": "/*M!100005 CREATE ",
+ opt_ignore ? "IF NOT EXISTS " : "", row[0]);
+ fprintf(md_result_file, "/*M!100005 GRANT %s TO %s%s*/;\n",
+ row[0], row[1], (row[2][0] == 'Y') ? " WITH ADMIN OPTION " : "");
+ }
+ mysql_free_result(tableres);
+
+ /* users and their default role */
+ if (maria_roles_exist && mysql_query_with_error_report(mysql, &tableres,
+ "select IF(default_role='', 'NONE', QUOTE(default_role)) as r,"
+ "concat(QUOTE(User), '@', QUOTE(Host)) as u FROM mysql.user "
+ "/*M!100005 WHERE is_role='N' */"))
+ return 1;
+ if (mysql_roles_exist && mysql_query_with_error_report(mysql, &tableres,
+ "SELECT IF(DEFAULT_ROLE_HOST IS NULL, 'NONE', CONCAT(QUOTE(DEFAULT_ROLE_USER),"
+ " '@', QUOTE(DEFAULT_ROLE_HOST))) as r,"
+ " CONCAT(QUOTE(mu.USER),'@',QUOTE(mu.HOST)) as u "
+ "FROM mysql.user mu LEFT JOIN mysql.default_roles using (USER, HOST)"))
+ return 1;
+ while ((row= mysql_fetch_row(tableres)))
+ {
+ if (dump_grants(row[1]))
+ result= 1;
+ fprintf(md_result_file, "/*M!100005 SET DEFAULT ROLE %s FOR %s */;\n", row[0], row[1]);
+ fprintf(md_result_file, "/*!80001 ALTER USER %s DEFAULT ROLE %s */;\n", row[1], row[0]);
+ }
+ mysql_free_result(tableres);
+
+ if (maria_roles_exist && mysql_query_with_error_report(mysql, &tableres,
+ "SELECT DISTINCT QUOTE(m.role) AS r "
+ " FROM mysql.roles_mapping m"
+ " JOIN mysql.user u ON u.user = m.role"
+ " WHERE is_role='Y'"
+ " AND Admin_option='Y'"
+ " ORDER BY m.role"))
+ return 1;
+ if (mysql_roles_exist && mysql_query_with_error_report(mysql, &tableres,
+ "SELECT DISTINCT CONCAT(QUOTE(FROM_USER),'@', QUOTE(FROM_HOST)) AS r "
+ "FROM mysql.role_edges"))
+ return 1;
+ while ((row= mysql_fetch_row(tableres)))
+ {
+ if (dump_grants(row[0]))
+ result= 1;
+ }
+ mysql_free_result(tableres);
+ /* switch back */
+ fputs("SET ROLE NONE;\n"
+ "DROP ROLE mariadb_dump_import_role;\n"
+ "/*M!100203 EXECUTE IMMEDIATE CONCAT('SET ROLE ', @current_role) */;\n",
+ md_result_file);
+exit:
+
+ return result;
+}
+
+
+/*
+ dump all plugins
+*/
+
+static int dump_all_plugins()
+{
+ MYSQL_ROW row;
+ MYSQL_RES *tableres;
+
+ if (mysql_query_with_error_report(mysql, &tableres, "SHOW PLUGINS"))
+ return 1;
+ /* Name, Status, Type, Library, License */
+ while ((row= mysql_fetch_row(tableres)))
+ {
+ if (strcmp("ACTIVE", row[1]) != 0)
+ continue;
+ /* Should we be skipping builtins? */
+ if (row[3] == NULL)
+ continue;
+ if (opt_replace_into)
+ {
+ fprintf(md_result_file, "/*M!100401 UNINSTALL PLUGIN IF EXIST %s */;\n",
+ row[0]);
+ }
+ fprintf(md_result_file,
+ "INSTALL PLUGIN %s %s SONAME '%s';\n", row[0],
+ opt_ignore ? "/*M!100401 IF NOT EXISTS */" : "", row[3]);
+ }
+ mysql_free_result(tableres);
+
+ return 0;
+}
+
+
+/*
+ dump all udfs
+*/
+
+static int dump_all_udfs()
+{
+ /* we don't support all these types yet, but get prepared if we do */
+ static const char *udf_types[] = {"STRING", "REAL", "INT", "ROW", "DECIMAL", "TIME" };
+ MYSQL_ROW row;
+ MYSQL_RES *tableres;
+ int retresult, result= 0;
+
+ if (mysql_query_with_error_report(mysql, &tableres, "SELECT * FROM mysql.func"))
+ return 1;
+ /* Name, ret, dl, type*/
+ while ((row= mysql_fetch_row(tableres)))
+ {
+ retresult= atoi(row[1]);
+ if (retresult < 0 || array_elements(udf_types) <= (size_t) retresult)
+ {
+ fprintf(stderr, "%s: Error: invalid return type on udf function '%s'\n",
+ my_progname_short, row[0]);
+ result= 1;
+ continue;
+ }
+ if (opt_replace_into)
+ {
+ fprintf(md_result_file, "/*!50701 DROP FUNCTION IF EXISTS %s */;\n",
+ row[0]);
+ }
+ fprintf(md_result_file,
+ "CREATE %s%sFUNCTION %s%s RETURNS %s SONAME '%s';\n",
+ opt_replace_into ? "/*M!100103 OR REPLACE */ ": "",
+ (strcmp("AGGREGATE", row[2])==0 ? "AGGREGATE " : ""),
+ opt_ignore ? "IF NOT EXISTS " : "", row[0], udf_types[retresult], row[2]);
+ }
+ mysql_free_result(tableres);
+
+ return result;
+}
+
+
+/*
+ dump all servers
+*/
+
+static int dump_all_servers()
+{
+ /* No create server yet - MDEV-15696 */
+ MYSQL_ROW row;
+ MYSQL_RES *tableres;
+ MYSQL_FIELD *f;
+ unsigned int num_fields, i;
+ my_bool comma_prepend= 0;
+ const char *qstring;
+
+ if (mysql_query_with_error_report(mysql, &tableres, "SELECT * FROM mysql.servers"))
+ return 1;
+ num_fields= mysql_num_fields(tableres);
+ while ((row= mysql_fetch_row(tableres)))
+ {
+ fprintf(md_result_file,"CREATE %sSERVER %s%s FOREIGN DATA WRAPPER %s OPTIONS (",
+ opt_replace_into ? "/*M!100103 OR REPLACE */ ": "",
+ opt_ignore ? "/*M!100103 IF NOT EXISTS */ " : "", row[0], row[7]);
+ for (i= 1; i < num_fields; i++)
+ {
+ if (i == 7 || row[i][0] == '\0') /* Wrapper or empty string */
+ continue;
+ f= &tableres->fields[i];
+ qstring= (f->type == MYSQL_TYPE_STRING || f->type == MYSQL_TYPE_VAR_STRING) ? "'" : "";
+ fprintf(md_result_file, "%s%s %s%s%s",
+ (comma_prepend ? ", " : ""), f->name, qstring, row[i], qstring);
+ comma_prepend= 1;
+ }
+ fputs(");\n", md_result_file);
+ }
+ mysql_free_result(tableres);
+
+ return 0;
+}
+
+
+/*
+ dump all system statistical tables
+*/
+
+static int dump_all_stats()
+{
+ my_bool prev_no_create_info;
+
+ if (mysql_select_db(mysql, "mysql"))
+ {
+ DB_error(mysql, "when selecting the database");
+ return 1; /* If --force */
+ }
+ fprintf(md_result_file,"\nUSE mysql;\n");
+ prev_no_create_info= opt_no_create_info;
+ opt_no_create_info= 1; /* don't overwrite recreate tables */
+ /* EITS added in 10.0.1 */
+ if (mysql_get_server_version(mysql) >= 100001)
+ {
+ dump_table("column_stats", "mysql", NULL, 0);
+ dump_table("index_stats", "mysql", NULL, 0);
+ dump_table("table_stats", "mysql", NULL, 0);
+ }
+ /* Innodb may be disabled */
+ if (!mysql_query(mysql, "show fields from innodb_index_stats"))
+ {
+ MYSQL_RES *tableres= mysql_store_result(mysql);
+ mysql_free_result(tableres);
+ dump_table("innodb_index_stats", "mysql", NULL, 0);
+ dump_table("innodb_table_stats", "mysql", NULL, 0);
+ }
+ opt_no_create_info= prev_no_create_info;
+ return 0;
+}
+
+
+/*
+ dump all system timezones
+*/
+
+static int dump_all_timezones()
+{
+ my_bool opt_prev_no_create_info;
+ if (mysql_select_db(mysql, "mysql"))
+ {
+ DB_error(mysql, "when selecting the database");
+ return 1; /* If --force */
+ }
+ opt_prev_no_create_info= opt_no_create_info;
+ opt_no_create_info= 1;
+ fprintf(md_result_file,"\nUSE mysql;\n");
+ dump_table("time_zone", "mysql", NULL, 0);
+ dump_table("time_zone_name", "mysql", NULL, 0);
+ dump_table("time_zone_leap_second", "mysql", NULL, 0);
+ dump_table("time_zone_transition", "mysql", NULL, 0);
+ dump_table("time_zone_transition_type", "mysql", NULL, 0);
+ opt_no_create_info= opt_prev_no_create_info;
+ return 0;
+}
+
+
+/*
dump all logfile groups and tablespaces
*/
@@ -6375,7 +6929,7 @@ int main(int argc, char **argv)
dump_tablespaces_for_tables(*argv, (argv + 1), (argc - 1));
dump_selected_tables(*argv, (argv + 1), (argc - 1));
}
- else
+ else if (argc > 0)
{
/* One or more databases, all tables */
if (!opt_alltspcs && !opt_notspcs)
@@ -6384,6 +6938,25 @@ int main(int argc, char **argv)
}
}
+ if (opt_system & OPT_SYSTEM_PLUGINS)
+ dump_all_plugins();
+
+ if (opt_system & OPT_SYSTEM_USERS)
+ dump_all_users_roles_and_grants();
+
+ if (opt_system & OPT_SYSTEM_UDFS)
+ dump_all_udfs();
+
+ if (opt_system & OPT_SYSTEM_SERVERS)
+ dump_all_servers();
+
+ /* These must be last as they explictly change the current database to mysql */
+ if (opt_system & OPT_SYSTEM_STATS)
+ dump_all_stats();
+
+ if (opt_system & OPT_SYSTEM_TIMEZONES)
+ dump_all_timezones();
+
/* add 'START SLAVE' to end of dump */
if (opt_slave_apply && add_slave_statements())
goto err;
diff --git a/cmake/Internal/CPack/CPackRPM.cmake b/cmake/Internal/CPack/CPackRPM.cmake
index 4e3af5ed4c2..6e376b2255f 100644
--- a/cmake/Internal/CPack/CPackRPM.cmake
+++ b/cmake/Internal/CPack/CPackRPM.cmake
@@ -31,26 +31,28 @@ set_from_component(VENDOR)
# the scriptlet, if present, is appended (together with the %posttrans tag)
# to the pre-uninstall scriptlet
#
-set(base_time "PRE")
-set(base_type "UNINSTALL")
-set(base_var CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_${base_time}_${base_type}_SCRIPT_FILE)
-set(acc)
+if(CMAKE_VERSION VERSION_LESS 3.18)
+ set(base_time "PRE")
+ set(base_type "UNINSTALL")
+ set(base_var CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_${base_time}_${base_type}_SCRIPT_FILE)
+ set(acc)
-macro(read_one_file time_ type_ tag_)
- set(var CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_${time_}_${type_}_SCRIPT_FILE)
- if (${var})
- file(READ ${${var}} content)
- set(acc "${tag_}\n${content}\n\n${acc}")
- endif()
-endmacro()
+ macro(read_one_file time_ type_ tag_)
+ set(var CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_${time_}_${type_}_SCRIPT_FILE)
+ if (${var})
+ file(READ ${${var}} content)
+ set(acc "${tag_}\n${content}\n\n${acc}")
+ endif()
+ endmacro()
-read_one_file("POST" "TRANS" "%posttrans")
-if (acc)
- set(orig_${base_var} ${${base_var}})
- read_one_file(${base_time} ${base_type} "")
- set(${base_var} ${CPACK_TOPLEVEL_DIRECTORY}/SPECS/${CPACK_RPM_PACKAGE_COMPONENT}_${base_time}_${base_type}.scriptlet)
- file(WRITE ${${base_var}} "${acc}")
-endif()
+ read_one_file("POST" "TRANS" "%posttrans")
+ if (acc)
+ set(orig_${base_var} ${${base_var}})
+ read_one_file(${base_time} ${base_type} "")
+ set(${base_var} ${CPACK_TOPLEVEL_DIRECTORY}/SPECS/${CPACK_RPM_PACKAGE_COMPONENT}_${base_time}_${base_type}.scriptlet)
+ file(WRITE ${${base_var}} "${acc}")
+ endif()
+endif(CMAKE_VERSION VERSION_LESS 3.18)
#
# Support for the Recommends: tag.
@@ -78,7 +80,9 @@ set(CMAKE_MODULE_PATH ${orig_CMAKE_MODULE_PATH})
restore(LICENSE)
restore(VENDOR)
-set(${base_var} ${orig_${base_var}})
+if(${orig_${base_var}})
+ set(${base_var} ${orig_${base_var}})
+endif()
# per-component cleanup
foreach(_RPM_SPEC_HEADER URL REQUIRES SUGGESTS PROVIDES OBSOLETES PREFIX CONFLICTS AUTOPROV AUTOREQ AUTOREQPROV)
diff --git a/include/my_sys.h b/include/my_sys.h
index a66bfd8217c..59d88f193c6 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -511,8 +511,11 @@ static inline int my_b_write(IO_CACHE *info, const uchar *Buffer, size_t Count)
MEM_CHECK_DEFINED(Buffer, Count);
if (info->write_pos + Count <= info->write_end)
{
- memcpy(info->write_pos, Buffer, Count);
- info->write_pos+= Count;
+ if (Count)
+ {
+ memcpy(info->write_pos, Buffer, Count);
+ info->write_pos+= Count;
+ }
return 0;
}
return _my_b_write(info, Buffer, Count);
diff --git a/libmariadb b/libmariadb
-Subproject 62427520a5ba20e42fe51f5045062a7a9cadb46
+Subproject e38244220646a7e95c9be22576460aa7a4eb715
diff --git a/man/mysqldump.1 b/man/mysqldump.1
index fae61fbdfd9..43f9227488e 100644
--- a/man/mysqldump.1
+++ b/man/mysqldump.1
@@ -1,6 +1,6 @@
'\" t
.\"
-.TH "\FBMYSQLDUMP\FR" "1" "27 June 2019" "MariaDB 10\&.5" "MariaDB Database System"
+.TH "\FBMYSQLDUMP\FR" "1" "24 October 2020" "MariaDB 10\&.5" "MariaDB Database System"
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
@@ -36,7 +36,7 @@ tables, consider using the
instead because it can accomplish faster backups and faster restores\&. See
\fBmysqlhotcopy\fR(1)\&.
.PP
-There are three general ways to invoke
+There are four general ways to invoke
\fBmysqldump\fR:
.sp
.if n \{\
@@ -46,6 +46,7 @@ There are three general ways to invoke
shell> \fBmysqldump [\fR\fB\fIoptions\fR\fR\fB] \fR\fB\fIdb_name\fR\fR\fB [\fR\fB\fItbl_name\fR\fR\fB \&.\&.\&.]\fR
shell> \fBmysqldump [\fR\fB\fIoptions\fR\fR\fB] \-\-databases \fR\fB\fIdb_name\fR\fR\fB \&.\&.\&.\fR
shell> \fBmysqldump [\fR\fB\fIoptions\fR\fR\fB] \-\-all\-databases\fR
+shell> \fBmysqldump [\fR\fB\fIoptions\fR\fR\fB] \-\-system={options}\fR
.fi
.if n \{\
.RE
@@ -2208,6 +2209,110 @@ Verify server's "Common Name" in its cert against hostname used when connecting.
.sp -1
.IP \(bu 2.3
.\}
+.\" mysqladmin: Dump system tables option
+.\" Dump system tables option: mysqladmin
+\fB\-\-system=\fR\fB\fI{all, users, plugins, udfs, servers, stats, timezones}\fR\fR
+.sp
+Dump the system tables in the mysql database in a logical form\&. This option is an empty set by default\&.
+.sp
+One or more options can be listed in comma separated list\&.
+.sp
+The options here are:
+.sp
+.RS 4
+.ie n \{\
+\h'-04'\(bu\h'+03'\c
+.\}
+.el \{\
+.sp -1
+.IP \(bu 2.3
+.\}
+all \- an alias to enabling all of the below options\&.
+.RE
+.RS 4
+.ie n \{\
+\h'-04'\(bu\h'+03'\c
+.\}
+.el \{\
+.sp -1
+.IP \(bu 2.3
+.\}
+users \- the users, roles and their grants outputed as \fBCREATE USER\fB, \fBCREATE ROLE\fR, \fBGRANT\fR, and \fBSET DEFAULT ROLE\fR (\fBALTER USER\fR for MySQL-8.0+)\&.
+.RE
+.RS 4
+.ie n \{\
+\h'-04'\(bu\h'+03'\c
+.\}
+.el \{\
+.sp -1
+.IP \(bu 2.3
+.\}
+plugins \- active plugins of the server outputed as \fBINSTALL PLUGIN\fR\&.
+.RE
+.RS 4
+.ie n \{\
+\h'-04'\(bu\h'+03'\c
+.\}
+.el \{\
+.sp -1
+.IP \(bu 2.3
+.\}
+udfs \- user define functions outputed as \fBCREATE FUNCTION\fR\&.
+.RE
+.RS 4
+.ie n \{\
+\h'-04'\(bu\h'+03'\c
+.\}
+.el \{\
+.sp -1
+.IP \(bu 2.3
+.\}
+servers \- remote (federated) servers as \fBCREATE SERVER\fR\&.
+.RE
+.RS 4
+.ie n \{\
+\h'-04'\(bu\h'+03'\c
+.\}
+.el \{\
+.sp -1
+.IP \(bu 2.3
+.\}
+stats \- statistics tables, InnoDB and Engine Independent Table Statistics (EITS), are dumped as \fBINSERT\fR/\fBREPLACE INFO\fR statements without (re)creating tables\&.
+.RE
+.RS 4
+.ie n \{\
+\h'-04'\(bu\h'+03'\c
+.\}
+.el \{\
+.sp -1
+.IP \(bu 2.3
+.\}
+timezones \- timezone related system tables dumped as \fBINSERT\fR/\fBREPLACE INTO\fR statements without (re)creating tables\&.
+.RE
+.sp
+The format of the output is affected by \fB\-\-replace\fR and \fB\-\-insert\-into\fR\&. The \fB\-\-replace\fR option will output \fBCREATE OR REPLACE\fR
+forms of SQL, and also \fBDROP IF EXISTS\fR prior to \fBCREATE\fR, if a \fBCREATE OR REPLACE\fR option isn't available.
+.sp
+With \fB\-\-system=user\fR (or \fBall\fR), and \fB\-\-replace\fR, SQL is generated to generate an error if attempting to import the dump with a connection user that is being replaced within the dump\&.
+.sp
+The \fB\-\-insert\-into\fR option will cause \fBCREATE IF NOT EXIST\fR forms of SQL to generated if available.
+.sp
+For stats, and timezones, \fB\-\-replace\fR and \fB\-\-insert\-info\fR have the usual effects.
+.sp
+Enabling specific options here will cause the relevant tables in the mysql database to be ignored when dumping the mysql database or \fB\-\-all\-databases\fR\&.
+.sp
+Experimentally this option is designed to be able to dump system information from MySQL-5\&.7 and 8\&.0 servers\&. SQL generated is also
+experimentally compatible with MySQL-5\&.7/8\&.0\&. Mappings of implemenation specific grants/plugins isn't always one-to-one however\&.
+.sp
+.RE
+.RS 4
+.ie n \{\
+\h'-04'\(bu\h'+03'\c
+.\}
+.el \{\
+.sp -1
+.IP \(bu 2.3
+.\}
.\" mysqldump: tab option
.\" tab option: mysqldump
\fB\-\-tab=\fR\fB\fIpath\fR\fR,
@@ -2689,7 +2794,7 @@ If you encounter problems backing up views, please read the section that covers
.SH "COPYRIGHT"
.br
.PP
-Copyright 2007-2008 MySQL AB, 2008-2010 Sun Microsystems, Inc., 2010-2019 MariaDB Foundation
+Copyright 2007-2008 MySQL AB, 2008-2010 Sun Microsystems, Inc., 2010-2020 MariaDB Foundation
.PP
This documentation is free software; you can redistribute it and/or modify it only under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License.
.PP
@@ -2697,12 +2802,6 @@ This documentation is distributed in the hope that it will be useful, but WITHOU
.PP
You should have received a copy of the GNU General Public License along with the program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA or see http://www.gnu.org/licenses/.
.sp
-.SH "NOTES"
-.IP " 1." 4
-Bug#30123
-.RS 4
-\%http://bugs.mysql.com/bug.php?id=30123
-.RE
.SH "SEE ALSO"
For more information, please refer to the MariaDB Knowledge Base, available online at https://mariadb.com/kb/
.SH AUTHOR
diff --git a/mysql-test/main/alter_user.result b/mysql-test/main/alter_user.result
index 233870084b7..0bbf0aa6788 100644
--- a/mysql-test/main/alter_user.result
+++ b/mysql-test/main/alter_user.result
@@ -67,6 +67,10 @@ alter user foo identified by password '*88C89BE093D4ECF72D039F62EBB7477EA1FD4D63
select * from mysql.user where user = 'foo';
Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv Delete_history_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string password_expired is_role default_role max_statement_time
% foo *88C89BE093D4ECF72D039F62EBB7477EA1FD4D63 N N N N N N N N N N N N N N N N N N N N N N N N N Y N N N N 0 0 0 0 mysql_native_password *88C89BE093D4ECF72D039F62EBB7477EA1FD4D63 N N 0.000000
+alter user foo identified by password 'invalid';
+select * from mysql.user where user = 'foo';
+Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv Delete_history_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string password_expired is_role default_role max_statement_time
+% foo invalid N N N N N N N N N N N N N N N N N N N N N N N N N Y N N N N 0 0 0 0 mysql_native_password invalid N N 0.000000
alter user foo identified with 'somecoolplugin';
ERROR HY000: Operation ALTER USER failed for 'foo'@'%'
show warnings;
diff --git a/mysql-test/main/alter_user.test b/mysql-test/main/alter_user.test
index 52970a4cfed..37f77c26496 100644
--- a/mysql-test/main/alter_user.test
+++ b/mysql-test/main/alter_user.test
@@ -66,6 +66,9 @@ select * from mysql.user where user = 'foo';
alter user foo identified by password '*88C89BE093D4ECF72D039F62EBB7477EA1FD4D63';
select * from mysql.user where user = 'foo';
+alter user foo identified by password 'invalid';
+select * from mysql.user where user = 'foo';
+
--error ER_CANNOT_USER
alter user foo identified with 'somecoolplugin';
show warnings;
diff --git a/mysql-test/main/mysqldump-system,win.rdiff b/mysql-test/main/mysqldump-system,win.rdiff
new file mode 100644
index 00000000000..a46b422e95f
--- /dev/null
+++ b/mysql-test/main/mysqldump-system,win.rdiff
@@ -0,0 +1,21 @@
+--- mysqldump-system.result
++++ mysqldump-system,win.result
+@@ -442,7 +442,7 @@
+ mysql.time_zone_transition 3895294076
+ mysql.plugin 0
+ mysql.servers 2783974349
+-mysql.func 3241572444
++mysql.func 310494789
+ mysql.innodb_table_stats 347867921
+ mysql.table_stats 664320059
+ # Opps....
+@@ -477,7 +477,7 @@
+ mysql.time_zone_transition 3895294076
+ mysql.plugin 0
+ mysql.servers 2783974349
+-mysql.func 3241572444
++mysql.func 310494789
+ mysql.innodb_table_stats 347867921
+ mysql.table_stats 664320059
+ DROP FUNCTION IF EXISTS metaphon;
+
diff --git a/mysql-test/main/mysqldump-system.result b/mysql-test/main/mysqldump-system.result
new file mode 100644
index 00000000000..356396a5169
--- /dev/null
+++ b/mysql-test/main/mysqldump-system.result
@@ -0,0 +1,497 @@
+#
+# MDEV-23630: mysqldump to logically dump system tables
+#
+#
+create table backup_users like mysql.global_priv;
+create table tables_priv like mysql.tables_priv;
+insert into backup_users select * from mysql.global_priv;
+insert into tables_priv select * from mysql.tables_priv;
+delete from mysql.global_priv where host not in ('localhost');
+flush privileges;
+alter user 'mariadb.sys'@'localhost' ACCOUNT UNLOCK;
+create user USER;
+CREATE ROLE role_1;
+CREATE ROLE role_2 WITH ADMIN role_1;
+GRANT SHOW DATABASES ON *.* TO role_1;
+GRANT role_1 TO USER;
+GRANT role_2 TO USER;
+SET DEFAULT ROLE role_2 FOR USER;
+ALTER TABLE mysql.roles_mapping ORDER BY Host, User, Role;
+set @save_innodb_stats_persistent= @@innodb_stats_persistent;
+create table mysql.tz like mysql.time_zone_transition;
+alter table mysql.tz engine=innodb;
+insert into mysql.tz select * from mysql.time_zone_transition;
+set global innodb_stats_persistent=1;
+ANALYZE TABLE mysql.tz PERSISTENT FOR ALL;
+Table Op Msg_type Msg_text
+mysql.tz analyze status Engine-independent statistics collected
+mysql.tz analyze status OK
+delete from mysql.index_stats where prefix_arity!=1;
+delete from mysql.column_stats where column_name!='Time_zone_id';
+set time_zone="+03:00";
+update mysql.innodb_index_stats set last_update="2020-01-01" where database_name="mysql" and table_name="tz";
+update mysql.innodb_table_stats set last_update="2020-01-01" where database_name="mysql" and table_name="tz";
+set global innodb_stats_persistent= @save_innodb_stats_persistent;
+alter table mysql.time_zone_name ORDER BY Name;
+CREATE SERVER s1 FOREIGN DATA WRAPPER mysql OPTIONS(Host 'localhost');
+CREATE FUNCTION metaphon RETURNS STRING SONAME "UDF_EXAMPLE_LIB";
+#
+# mysqldump of system tables with --system=all
+#
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!40101 SET NAMES utf8mb4 */;
+/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
+/*!40103 SET TIME_ZONE='+00:00' */;
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+CREATE USER `mariadb.sys`@`localhost` PASSWORD EXPIRE;
+CREATE USER `root`@`localhost`;
+CREATE USER `USER`@`%`;
+SELECT COALESCE(CURRENT_ROLE(),'NONE') into @current_role;
+CREATE ROLE IF NOT EXISTS mariadb_dump_import_role;
+GRANT mariadb_dump_import_role TO CURRENT_USER();
+SET ROLE mariadb_dump_import_role;
+/*!80001 CREATE ROLE 'role_1' */;
+/*M!100005 CREATE ROLE 'role_1' WITH ADMIN mariadb_dump_import_role */;
+/*M!100005 GRANT 'role_1' TO 'root'@'localhost' WITH ADMIN OPTION */;
+/*!80001 CREATE ROLE 'role_2' */;
+/*M!100005 CREATE ROLE 'role_2' WITH ADMIN mariadb_dump_import_role */;
+/*M!100005 GRANT 'role_2' TO 'role_1' WITH ADMIN OPTION */;
+GRANT USAGE ON *.* TO `mariadb.sys`@`localhost`;
+GRANT SELECT, DELETE ON `mysql`.`global_priv` TO `mariadb.sys`@`localhost`;
+/*M!100005 SET DEFAULT ROLE NONE FOR 'mariadb.sys'@'localhost' */;
+/*!80001 ALTER USER 'mariadb.sys'@'localhost' DEFAULT ROLE NONE */;
+GRANT `role_1` TO `root`@`localhost` WITH ADMIN OPTION;
+GRANT ALL PRIVILEGES ON *.* TO `root`@`localhost` WITH GRANT OPTION;
+GRANT PROXY ON ''@'%' TO 'root'@'localhost' WITH GRANT OPTION;
+/*M!100005 SET DEFAULT ROLE NONE FOR 'root'@'localhost' */;
+/*!80001 ALTER USER 'root'@'localhost' DEFAULT ROLE NONE */;
+GRANT `role_1` TO `USER`@`%`;
+GRANT `role_2` TO `USER`@`%`;
+GRANT USAGE ON *.* TO `USER`@`%`;
+/*M!100005 SET DEFAULT ROLE 'role_2' FOR 'USER'@'%' */;
+/*!80001 ALTER USER 'USER'@'%' DEFAULT ROLE 'role_2' */;
+GRANT `role_2` TO `role_1` WITH ADMIN OPTION;
+GRANT SHOW DATABASES ON *.* TO `role_1`;
+GRANT USAGE ON *.* TO `role_2`;
+GRANT USAGE ON *.* TO `role_2`;
+SET ROLE NONE;
+DROP ROLE mariadb_dump_import_role;
+/*M!100203 EXECUTE IMMEDIATE CONCAT('SET ROLE ', @current_role) */;
+CREATE FUNCTION metaphon RETURNS STRING SONAME 'UDF_EXAMPLE_LIB';
+CREATE SERVER s1 FOREIGN DATA WRAPPER mysql OPTIONS (Host 'localhost', Port 3306);
+
+USE mysql;
+
+LOCK TABLES `column_stats` WRITE;
+/*!40000 ALTER TABLE `column_stats` DISABLE KEYS */;
+INSERT INTO `column_stats` VALUES ('mysql','tz','Time_zone_id','1','5',0.0000,4.0000,98.2500,254,'DOUBLE_PREC_HB','\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿');
+/*!40000 ALTER TABLE `column_stats` ENABLE KEYS */;
+UNLOCK TABLES;
+
+LOCK TABLES `index_stats` WRITE;
+/*!40000 ALTER TABLE `index_stats` DISABLE KEYS */;
+INSERT INTO `index_stats` VALUES ('mysql','tz','PRIMARY',1,98.2500);
+/*!40000 ALTER TABLE `index_stats` ENABLE KEYS */;
+UNLOCK TABLES;
+
+LOCK TABLES `table_stats` WRITE;
+/*!40000 ALTER TABLE `table_stats` DISABLE KEYS */;
+INSERT INTO `table_stats` VALUES ('mysql','tz',393);
+/*!40000 ALTER TABLE `table_stats` ENABLE KEYS */;
+UNLOCK TABLES;
+
+LOCK TABLES `innodb_index_stats` WRITE;
+/*!40000 ALTER TABLE `innodb_index_stats` DISABLE KEYS */;
+INSERT INTO `innodb_index_stats` VALUES ('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_diff_pfx01',4,1,'Time_zone_id'),('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_diff_pfx02',393,1,'Time_zone_id,Transition_time'),('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_leaf_pages',1,NULL,'Number of leaf pages in the index'),('mysql','tz','PRIMARY','2019-12-31 21:00:00','size',1,NULL,'Number of pages in the index');
+/*!40000 ALTER TABLE `innodb_index_stats` ENABLE KEYS */;
+UNLOCK TABLES;
+
+LOCK TABLES `innodb_table_stats` WRITE;
+/*!40000 ALTER TABLE `innodb_table_stats` DISABLE KEYS */;
+INSERT INTO `innodb_table_stats` VALUES ('mysql','tz','2019-12-31 21:00:00',393,1,0);
+/*!40000 ALTER TABLE `innodb_table_stats` ENABLE KEYS */;
+UNLOCK TABLES;
+
+USE mysql;
+
+LOCK TABLES `time_zone` WRITE;
+/*!40000 ALTER TABLE `time_zone` DISABLE KEYS */;
+INSERT INTO `time_zone` VALUES (1,'N'),(2,'N'),(3,'N'),(4,'Y'),(5,'N');
+/*!40000 ALTER TABLE `time_zone` ENABLE KEYS */;
+UNLOCK TABLES;
+
+LOCK TABLES `time_zone_name` WRITE;
+/*!40000 ALTER TABLE `time_zone_name` DISABLE KEYS */;
+INSERT INTO `time_zone_name` VALUES ('Europe/Moscow',3),('Japan',5),('leap/Europe/Moscow',4),('MET',1),('Universal',2),('UTC',2);
+/*!40000 ALTER TABLE `time_zone_name` ENABLE KEYS */;
+UNLOCK TABLES;
+
+LOCK TABLES `time_zone_leap_second` WRITE;
+/*!40000 ALTER TABLE `time_zone_leap_second` DISABLE KEYS */;
+INSERT INTO `time_zone_leap_second` VALUES (78796800,1),(94694401,2),(126230402,3),(157766403,4),(189302404,5),(220924805,6),(252460806,7),(283996807,8),(315532808,9),(362793609,10),(394329610,11),(425865611,12),(489024012,13),(567993613,14),(631152014,15),(662688015,16),(709948816,17),(741484817,18),(773020818,19),(820454419,20),(867715220,21),(915148821,22);
+/*!40000 ALTER TABLE `time_zone_leap_second` ENABLE KEYS */;
+UNLOCK TABLES;
+
+LOCK TABLES `time_zone_transition` WRITE;
+/*!40000 ALTER TABLE `time_zone_transition` DISABLE KEYS */;
+INSERT INTO `time_zone_transition` VALUES (1,-1693706400,0),(1,-1680483600,1),(1,-1663455600,2),(1,-1650150000,3),(1,-1632006000,2),(1,-1618700400,3),(1,-938905200,2),(1,-857257200,3),(1,-844556400,2),(1,-828226800,3),(1,-812502000,2),(1,-796777200,3),(1,228877200,2),(1,243997200,3),(1,260326800,2),(1,276051600,3),(1,291776400,2),(1,307501200,3),(1,323830800,2),(1,338950800,3),(1,354675600,2),(1,370400400,3),(1,386125200,2),(1,401850000,3),(1,417574800,2),(1,433299600,3),(1,449024400,2),(1,465354000,3),(1,481078800,2),(1,496803600,3),(1,512528400,2),(1,528253200,3),(1,543978000,2),(1,559702800,3),(1,575427600,2),(1,591152400,3),(1,606877200,2),(1,622602000,3),(1,638326800,2),(1,654656400,3),(1,670381200,2),(1,686106000,3),(1,701830800,2),(1,717555600,3),(1,733280400,2),(1,749005200,3),(1,764730000,2),(1,780454800,3),(1,796179600,2),(1,811904400,3),(1,828234000,2),(1,846378000,3),(1,859683600,2),(1,877827600,3),(1,891133200,2),(1,909277200,3),(1,922582800,2),(1,941331600,3),(1,954032400,2),(1,972781200,3),(1,985482000,2),(1,1004230800,3),(1,1017536400,2),(1,1035680400,3),(1,1048986000,2),(1,1067130000,3),(1,1080435600,2),(1,1099184400,3),(1,1111885200,2),(1,1130634000,3),(1,1143334800,2),(1,1162083600,3),(1,1174784400,2),(1,1193533200,3),(1,1206838800,2),(1,1224982800,3),(1,1238288400,2),(1,1256432400,3),(1,1269738000,2),(1,1288486800,3),(1,1301187600,2),(1,1319936400,3),(1,1332637200,2),(1,1351386000,3),(1,1364691600,2),(1,1382835600,3),(1,1396141200,2),(1,1414285200,3),(1,1427590800,2),(1,1445734800,3),(1,1459040400,2),(1,1477789200,3),(1,1490490000,2),(1,1509238800,3),(1,1521939600,2),(1,1540688400,3),(1,1553994000,2),(1,1572138000,3),(1,1585443600,2),(1,1603587600,3),(1,1616893200,2),(1,1635642000,3),(1,1648342800,2),(1,1667091600,3),(1,1679792400,2),(1,1698541200,3),(1,1711846800,2),(1,1729990800,3),(1,1743296400,2),(1,1761440400,3),(1,1774746000,2),(1,1792890000,3),(1,1806195600,2),(1,1824944400,3),(1,1837645200,2),(1,1856394000,3),(1,1869094800,2),(1,1887843600,3),(1,1901149200,2),(1,1919293200,3),(1,1932598800,2),(1,1950742800,3),(1,1964048400,2),(1,1982797200,3),(1,1995498000,2),(1,2014246800,3),(1,2026947600,2),(1,2045696400,3),(1,2058397200,2),(1,2077146000,3),(1,2090451600,2),(1,2108595600,3),(1,2121901200,2),(1,2140045200,3),(3,-1688265000,2),(3,-1656819048,1),(3,-1641353448,2),(3,-1627965048,3),(3,-1618716648,1),(3,-1596429048,3),(3,-1593829848,5),(3,-1589860800,4),(3,-1542427200,5),(3,-1539493200,6),(3,-1525323600,5),(3,-1522728000,4),(3,-1491188400,7),(3,-1247536800,4),(3,354920400,5),(3,370728000,4),(3,386456400,5),(3,402264000,4),(3,417992400,5),(3,433800000,4),(3,449614800,5),(3,465346800,8),(3,481071600,9),(3,496796400,8),(3,512521200,9),(3,528246000,8),(3,543970800,9),(3,559695600,8),(3,575420400,9),(3,591145200,8),(3,606870000,9),(3,622594800,8),(3,638319600,9),(3,654649200,8),(3,670374000,10),(3,686102400,11),(3,695779200,8),(3,701812800,5),(3,717534000,4),(3,733273200,9),(3,748998000,8),(3,764722800,9),(3,780447600,8),(3,796172400,9),(3,811897200,8),(3,828226800,9),(3,846370800,8),(3,859676400,9),(3,877820400,8),(3,891126000,9),(3,909270000,8),(3,922575600,9),(3,941324400,8),(3,954025200,9),(3,972774000,8),(3,985474800,9),(3,1004223600,8),(3,1017529200,9),(3,1035673200,8),(3,1048978800,9),(3,1067122800,8),(3,1080428400,9),(3,1099177200,8),(3,1111878000,9),(3,1130626800,8),(3,1143327600,9),(3,1162076400,8),(3,1174777200,9),(3,1193526000,8),(3,1206831600,9),(3,1224975600,8),(3,1238281200,9),(3,1256425200,8),(3,1269730800,9),(3,1288479600,8),(3,1301180400,9),(3,1319929200,8),(3,1332630000,9),(3,1351378800,8),(3,1364684400,9),(3,1382828400,8),(3,1396134000,9),(3,1414278000,8),(3,1427583600,9),(3,1445727600,8),(3,1459033200,9),(3,1477782000,8),(3,1490482800,9),(3,1509231600,8),(3,1521932400,9),(3,1540681200,8),(3,1553986800,9),(3,1572130800,8),(3,1585436400,9),(3,1603580400,8),(3,1616886000,9),(3,1635634800,8),(3,1648335600,9),(3,1667084400,8),(3,1679785200,9),(3,1698534000,8),(3,1711839600,9),(3,1729983600,8),(3,1743289200,9),(3,1761433200,8),(3,1774738800,9),(3,1792882800,8),(3,1806188400,9),(3,1824937200,8),(3,1837638000,9),(3,1856386800,8),(3,1869087600,9),(3,1887836400,8),(3,1901142000,9),(3,1919286000,8),(3,1932591600,9),(3,1950735600,8),(3,1964041200,9),(3,1982790000,8),(3,1995490800,9),(3,2014239600,8),(3,2026940400,9),(3,2045689200,8),(3,2058390000,9),(3,2077138800,8),(3,2090444400,9),(3,2108588400,8),(3,2121894000,9),(3,2140038000,8),(4,-1688265000,2),(4,-1656819048,1),(4,-1641353448,2),(4,-1627965048,3),(4,-1618716648,1),(4,-1596429048,3),(4,-1593829848,5),(4,-1589860800,4),(4,-1542427200,5),(4,-1539493200,6),(4,-1525323600,5),(4,-1522728000,4),(4,-1491188400,7),(4,-1247536800,4),(4,354920409,5),(4,370728010,4),(4,386456410,5),(4,402264011,4),(4,417992411,5),(4,433800012,4),(4,449614812,5),(4,465346812,8),(4,481071612,9),(4,496796413,8),(4,512521213,9),(4,528246013,8),(4,543970813,9),(4,559695613,8),(4,575420414,9),(4,591145214,8),(4,606870014,9),(4,622594814,8),(4,638319615,9),(4,654649215,8),(4,670374016,10),(4,686102416,11),(4,695779216,8),(4,701812816,5),(4,717534017,4),(4,733273217,9),(4,748998018,8),(4,764722818,9),(4,780447619,8),(4,796172419,9),(4,811897219,8),(4,828226820,9),(4,846370820,8),(4,859676420,9),(4,877820421,8),(4,891126021,9),(4,909270021,8),(4,922575622,9),(4,941324422,8),(4,954025222,9),(4,972774022,8),(4,985474822,9),(4,1004223622,8),(4,1017529222,9),(4,1035673222,8),(4,1048978822,9),(4,1067122822,8),(4,1080428422,9),(4,1099177222,8),(4,1111878022,9),(4,1130626822,8),(4,1143327622,9),(4,1162076422,8),(4,1174777222,9),(4,1193526022,8),(4,1206831622,9),(4,1224975622,8),(4,1238281222,9),(4,1256425222,8),(4,1269730822,9),(4,1288479622,8),(4,1301180422,9),(4,1319929222,8),(4,1332630022,9),(4,1351378822,8),(4,1364684422,9),(4,1382828422,8),(4,1396134022,9),(4,1414278022,8),(4,1427583622,9),(4,1445727622,8),(4,1459033222,9),(4,1477782022,8),(4,1490482822,9),(4,1509231622,8),(4,1521932422,9),(4,1540681222,8),(4,1553986822,9),(4,1572130822,8),(4,1585436422,9),(4,1603580422,8),(4,1616886022,9),(4,1635634822,8),(4,1648335622,9),(4,1667084422,8),(4,1679785222,9),(4,1698534022,8),(4,1711839622,9),(4,1729983622,8),(4,1743289222,9),(4,1761433222,8),(4,1774738822,9),(4,1792882822,8),(4,1806188422,9),(4,1824937222,8),(4,1837638022,9),(4,1856386822,8),(4,1869087622,9),(4,1887836422,8),(4,1901142022,9),(4,1919286022,8),(4,1932591622,9),(4,1950735622,8),(4,1964041222,9),(4,1982790022,8),(4,1995490822,9),(4,2014239622,8),(4,2026940422,9),(4,2045689222,8),(4,2058390022,9),(4,2077138822,8),(4,2090444422,9),(4,2108588422,8),(4,2121894022,9),(4,2140038022,8),(5,-1009875600,1);
+/*!40000 ALTER TABLE `time_zone_transition` ENABLE KEYS */;
+UNLOCK TABLES;
+
+LOCK TABLES `time_zone_transition_type` WRITE;
+/*!40000 ALTER TABLE `time_zone_transition_type` DISABLE KEYS */;
+INSERT INTO `time_zone_transition_type` VALUES (1,0,7200,1,'MEST'),(1,1,3600,0,'MET'),(1,2,7200,1,'MEST'),(1,3,3600,0,'MET'),(2,0,0,0,'UTC'),(3,0,9000,0,'MMT'),(3,1,12648,1,'MST'),(3,2,9048,0,'MMT'),(3,3,16248,1,'MDST'),(3,4,10800,0,'MSK'),(3,5,14400,1,'MSD'),(3,6,18000,1,'MSD'),(3,7,7200,0,'EET'),(3,8,10800,0,'MSK'),(3,9,14400,1,'MSD'),(3,10,10800,1,'EEST'),(3,11,7200,0,'EET'),(4,0,9000,0,'MMT'),(4,1,12648,1,'MST'),(4,2,9048,0,'MMT'),(4,3,16248,1,'MDST'),(4,4,10800,0,'MSK'),(4,5,14400,1,'MSD'),(4,6,18000,1,'MSD'),(4,7,7200,0,'EET'),(4,8,10800,0,'MSK'),(4,9,14400,1,'MSD'),(4,10,10800,1,'EEST'),(4,11,7200,0,'EET'),(5,0,32400,0,'CJT'),(5,1,32400,0,'JST');
+/*!40000 ALTER TABLE `time_zone_transition_type` ENABLE KEYS */;
+UNLOCK TABLES;
+/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
+/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+
+#
+# mysqldump of system tables with --system=all --replace
+#
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!40101 SET NAMES utf8mb4 */;
+/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
+/*!40103 SET TIME_ZONE='+00:00' */;
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+DELIMITER |
+/*M!100101 IF current_user()="'mariadb.sys'@'localhost'" THEN
+ SIGNAL SQLSTATE '45000' SET MYSQL_ERRNO=30001, MESSAGE_TEXT="Don't remove current user 'mariadb.sys'@'localhost''";
+END IF */|
+DELIMITER ;
+/*!50701 DROP USER IF EXISTS 'mariadb.sys'@'localhost' */;
+CREATE /*M!100103 OR REPLACE */ USER `mariadb.sys`@`localhost` PASSWORD EXPIRE;
+DELIMITER |
+/*M!100101 IF current_user()="'root'@'localhost'" THEN
+ SIGNAL SQLSTATE '45000' SET MYSQL_ERRNO=30001, MESSAGE_TEXT="Don't remove current user 'root'@'localhost''";
+END IF */|
+DELIMITER ;
+/*!50701 DROP USER IF EXISTS 'root'@'localhost' */;
+CREATE /*M!100103 OR REPLACE */ USER `root`@`localhost`;
+DELIMITER |
+/*M!100101 IF current_user()="'USER'@'%'" THEN
+ SIGNAL SQLSTATE '45000' SET MYSQL_ERRNO=30001, MESSAGE_TEXT="Don't remove current user 'USER'@'%''";
+END IF */|
+DELIMITER ;
+/*!50701 DROP USER IF EXISTS 'USER'@'%' */;
+CREATE /*M!100103 OR REPLACE */ USER `USER`@`%`;
+SELECT COALESCE(CURRENT_ROLE(),'NONE') into @current_role;
+CREATE ROLE IF NOT EXISTS mariadb_dump_import_role;
+GRANT mariadb_dump_import_role TO CURRENT_USER();
+SET ROLE mariadb_dump_import_role;
+/*!80001 DROP ROLE IF EXISTS 'role_1' */;
+/*!80001 CREATE ROLE 'role_1' */;
+/*M!100103 CREATE OR REPLACE ROLE 'role_1' WITH ADMIN mariadb_dump_import_role */;
+/*M!100005 GRANT 'role_1' TO 'root'@'localhost' WITH ADMIN OPTION */;
+/*!80001 DROP ROLE IF EXISTS 'role_2' */;
+/*!80001 CREATE ROLE 'role_2' */;
+/*M!100103 CREATE OR REPLACE ROLE 'role_2' WITH ADMIN mariadb_dump_import_role */;
+/*M!100005 GRANT 'role_2' TO 'role_1' WITH ADMIN OPTION */;
+GRANT USAGE ON *.* TO `mariadb.sys`@`localhost`;
+GRANT SELECT, DELETE ON `mysql`.`global_priv` TO `mariadb.sys`@`localhost`;
+/*M!100005 SET DEFAULT ROLE NONE FOR 'mariadb.sys'@'localhost' */;
+/*!80001 ALTER USER 'mariadb.sys'@'localhost' DEFAULT ROLE NONE */;
+GRANT `role_1` TO `root`@`localhost` WITH ADMIN OPTION;
+GRANT ALL PRIVILEGES ON *.* TO `root`@`localhost` WITH GRANT OPTION;
+GRANT PROXY ON ''@'%' TO 'root'@'localhost' WITH GRANT OPTION;
+/*M!100005 SET DEFAULT ROLE NONE FOR 'root'@'localhost' */;
+/*!80001 ALTER USER 'root'@'localhost' DEFAULT ROLE NONE */;
+GRANT `role_1` TO `USER`@`%`;
+GRANT `role_2` TO `USER`@`%`;
+GRANT USAGE ON *.* TO `USER`@`%`;
+/*M!100005 SET DEFAULT ROLE 'role_2' FOR 'USER'@'%' */;
+/*!80001 ALTER USER 'USER'@'%' DEFAULT ROLE 'role_2' */;
+GRANT `role_2` TO `role_1` WITH ADMIN OPTION;
+GRANT SHOW DATABASES ON *.* TO `role_1`;
+GRANT USAGE ON *.* TO `role_2`;
+GRANT USAGE ON *.* TO `role_2`;
+SET ROLE NONE;
+DROP ROLE mariadb_dump_import_role;
+/*M!100203 EXECUTE IMMEDIATE CONCAT('SET ROLE ', @current_role) */;
+/*!50701 DROP FUNCTION IF EXISTS metaphon */;
+CREATE /*M!100103 OR REPLACE */ FUNCTION metaphon RETURNS STRING SONAME 'UDF_EXAMPLE_LIB';
+CREATE /*M!100103 OR REPLACE */ SERVER s1 FOREIGN DATA WRAPPER mysql OPTIONS (Host 'localhost', Port 3306);
+
+USE mysql;
+
+LOCK TABLES `column_stats` WRITE;
+/*!40000 ALTER TABLE `column_stats` DISABLE KEYS */;
+REPLACE INTO `column_stats` VALUES ('mysql','tz','Time_zone_id','1','5',0.0000,4.0000,98.2500,254,'DOUBLE_PREC_HB','\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿');
+/*!40000 ALTER TABLE `column_stats` ENABLE KEYS */;
+UNLOCK TABLES;
+
+LOCK TABLES `index_stats` WRITE;
+/*!40000 ALTER TABLE `index_stats` DISABLE KEYS */;
+REPLACE INTO `index_stats` VALUES ('mysql','tz','PRIMARY',1,98.2500);
+/*!40000 ALTER TABLE `index_stats` ENABLE KEYS */;
+UNLOCK TABLES;
+
+LOCK TABLES `table_stats` WRITE;
+/*!40000 ALTER TABLE `table_stats` DISABLE KEYS */;
+REPLACE INTO `table_stats` VALUES ('mysql','tz',393);
+/*!40000 ALTER TABLE `table_stats` ENABLE KEYS */;
+UNLOCK TABLES;
+
+LOCK TABLES `innodb_index_stats` WRITE;
+/*!40000 ALTER TABLE `innodb_index_stats` DISABLE KEYS */;
+REPLACE INTO `innodb_index_stats` VALUES ('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_diff_pfx01',4,1,'Time_zone_id'),('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_diff_pfx02',393,1,'Time_zone_id,Transition_time'),('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_leaf_pages',1,NULL,'Number of leaf pages in the index'),('mysql','tz','PRIMARY','2019-12-31 21:00:00','size',1,NULL,'Number of pages in the index');
+/*!40000 ALTER TABLE `innodb_index_stats` ENABLE KEYS */;
+UNLOCK TABLES;
+
+LOCK TABLES `innodb_table_stats` WRITE;
+/*!40000 ALTER TABLE `innodb_table_stats` DISABLE KEYS */;
+REPLACE INTO `innodb_table_stats` VALUES ('mysql','tz','2019-12-31 21:00:00',393,1,0);
+/*!40000 ALTER TABLE `innodb_table_stats` ENABLE KEYS */;
+UNLOCK TABLES;
+
+USE mysql;
+
+LOCK TABLES `time_zone` WRITE;
+/*!40000 ALTER TABLE `time_zone` DISABLE KEYS */;
+REPLACE INTO `time_zone` VALUES (1,'N'),(2,'N'),(3,'N'),(4,'Y'),(5,'N');
+/*!40000 ALTER TABLE `time_zone` ENABLE KEYS */;
+UNLOCK TABLES;
+
+LOCK TABLES `time_zone_name` WRITE;
+/*!40000 ALTER TABLE `time_zone_name` DISABLE KEYS */;
+REPLACE INTO `time_zone_name` VALUES ('Europe/Moscow',3),('Japan',5),('leap/Europe/Moscow',4),('MET',1),('Universal',2),('UTC',2);
+/*!40000 ALTER TABLE `time_zone_name` ENABLE KEYS */;
+UNLOCK TABLES;
+
+LOCK TABLES `time_zone_leap_second` WRITE;
+/*!40000 ALTER TABLE `time_zone_leap_second` DISABLE KEYS */;
+REPLACE INTO `time_zone_leap_second` VALUES (78796800,1),(94694401,2),(126230402,3),(157766403,4),(189302404,5),(220924805,6),(252460806,7),(283996807,8),(315532808,9),(362793609,10),(394329610,11),(425865611,12),(489024012,13),(567993613,14),(631152014,15),(662688015,16),(709948816,17),(741484817,18),(773020818,19),(820454419,20),(867715220,21),(915148821,22);
+/*!40000 ALTER TABLE `time_zone_leap_second` ENABLE KEYS */;
+UNLOCK TABLES;
+
+LOCK TABLES `time_zone_transition` WRITE;
+/*!40000 ALTER TABLE `time_zone_transition` DISABLE KEYS */;
+REPLACE INTO `time_zone_transition` VALUES (1,-1693706400,0),(1,-1680483600,1),(1,-1663455600,2),(1,-1650150000,3),(1,-1632006000,2),(1,-1618700400,3),(1,-938905200,2),(1,-857257200,3),(1,-844556400,2),(1,-828226800,3),(1,-812502000,2),(1,-796777200,3),(1,228877200,2),(1,243997200,3),(1,260326800,2),(1,276051600,3),(1,291776400,2),(1,307501200,3),(1,323830800,2),(1,338950800,3),(1,354675600,2),(1,370400400,3),(1,386125200,2),(1,401850000,3),(1,417574800,2),(1,433299600,3),(1,449024400,2),(1,465354000,3),(1,481078800,2),(1,496803600,3),(1,512528400,2),(1,528253200,3),(1,543978000,2),(1,559702800,3),(1,575427600,2),(1,591152400,3),(1,606877200,2),(1,622602000,3),(1,638326800,2),(1,654656400,3),(1,670381200,2),(1,686106000,3),(1,701830800,2),(1,717555600,3),(1,733280400,2),(1,749005200,3),(1,764730000,2),(1,780454800,3),(1,796179600,2),(1,811904400,3),(1,828234000,2),(1,846378000,3),(1,859683600,2),(1,877827600,3),(1,891133200,2),(1,909277200,3),(1,922582800,2),(1,941331600,3),(1,954032400,2),(1,972781200,3),(1,985482000,2),(1,1004230800,3),(1,1017536400,2),(1,1035680400,3),(1,1048986000,2),(1,1067130000,3),(1,1080435600,2),(1,1099184400,3),(1,1111885200,2),(1,1130634000,3),(1,1143334800,2),(1,1162083600,3),(1,1174784400,2),(1,1193533200,3),(1,1206838800,2),(1,1224982800,3),(1,1238288400,2),(1,1256432400,3),(1,1269738000,2),(1,1288486800,3),(1,1301187600,2),(1,1319936400,3),(1,1332637200,2),(1,1351386000,3),(1,1364691600,2),(1,1382835600,3),(1,1396141200,2),(1,1414285200,3),(1,1427590800,2),(1,1445734800,3),(1,1459040400,2),(1,1477789200,3),(1,1490490000,2),(1,1509238800,3),(1,1521939600,2),(1,1540688400,3),(1,1553994000,2),(1,1572138000,3),(1,1585443600,2),(1,1603587600,3),(1,1616893200,2),(1,1635642000,3),(1,1648342800,2),(1,1667091600,3),(1,1679792400,2),(1,1698541200,3),(1,1711846800,2),(1,1729990800,3),(1,1743296400,2),(1,1761440400,3),(1,1774746000,2),(1,1792890000,3),(1,1806195600,2),(1,1824944400,3),(1,1837645200,2),(1,1856394000,3),(1,1869094800,2),(1,1887843600,3),(1,1901149200,2),(1,1919293200,3),(1,1932598800,2),(1,1950742800,3),(1,1964048400,2),(1,1982797200,3),(1,1995498000,2),(1,2014246800,3),(1,2026947600,2),(1,2045696400,3),(1,2058397200,2),(1,2077146000,3),(1,2090451600,2),(1,2108595600,3),(1,2121901200,2),(1,2140045200,3),(3,-1688265000,2),(3,-1656819048,1),(3,-1641353448,2),(3,-1627965048,3),(3,-1618716648,1),(3,-1596429048,3),(3,-1593829848,5),(3,-1589860800,4),(3,-1542427200,5),(3,-1539493200,6),(3,-1525323600,5),(3,-1522728000,4),(3,-1491188400,7),(3,-1247536800,4),(3,354920400,5),(3,370728000,4),(3,386456400,5),(3,402264000,4),(3,417992400,5),(3,433800000,4),(3,449614800,5),(3,465346800,8),(3,481071600,9),(3,496796400,8),(3,512521200,9),(3,528246000,8),(3,543970800,9),(3,559695600,8),(3,575420400,9),(3,591145200,8),(3,606870000,9),(3,622594800,8),(3,638319600,9),(3,654649200,8),(3,670374000,10),(3,686102400,11),(3,695779200,8),(3,701812800,5),(3,717534000,4),(3,733273200,9),(3,748998000,8),(3,764722800,9),(3,780447600,8),(3,796172400,9),(3,811897200,8),(3,828226800,9),(3,846370800,8),(3,859676400,9),(3,877820400,8),(3,891126000,9),(3,909270000,8),(3,922575600,9),(3,941324400,8),(3,954025200,9),(3,972774000,8),(3,985474800,9),(3,1004223600,8),(3,1017529200,9),(3,1035673200,8),(3,1048978800,9),(3,1067122800,8),(3,1080428400,9),(3,1099177200,8),(3,1111878000,9),(3,1130626800,8),(3,1143327600,9),(3,1162076400,8),(3,1174777200,9),(3,1193526000,8),(3,1206831600,9),(3,1224975600,8),(3,1238281200,9),(3,1256425200,8),(3,1269730800,9),(3,1288479600,8),(3,1301180400,9),(3,1319929200,8),(3,1332630000,9),(3,1351378800,8),(3,1364684400,9),(3,1382828400,8),(3,1396134000,9),(3,1414278000,8),(3,1427583600,9),(3,1445727600,8),(3,1459033200,9),(3,1477782000,8),(3,1490482800,9),(3,1509231600,8),(3,1521932400,9),(3,1540681200,8),(3,1553986800,9),(3,1572130800,8),(3,1585436400,9),(3,1603580400,8),(3,1616886000,9),(3,1635634800,8),(3,1648335600,9),(3,1667084400,8),(3,1679785200,9),(3,1698534000,8),(3,1711839600,9),(3,1729983600,8),(3,1743289200,9),(3,1761433200,8),(3,1774738800,9),(3,1792882800,8),(3,1806188400,9),(3,1824937200,8),(3,1837638000,9),(3,1856386800,8),(3,1869087600,9),(3,1887836400,8),(3,1901142000,9),(3,1919286000,8),(3,1932591600,9),(3,1950735600,8),(3,1964041200,9),(3,1982790000,8),(3,1995490800,9),(3,2014239600,8),(3,2026940400,9),(3,2045689200,8),(3,2058390000,9),(3,2077138800,8),(3,2090444400,9),(3,2108588400,8),(3,2121894000,9),(3,2140038000,8),(4,-1688265000,2),(4,-1656819048,1),(4,-1641353448,2),(4,-1627965048,3),(4,-1618716648,1),(4,-1596429048,3),(4,-1593829848,5),(4,-1589860800,4),(4,-1542427200,5),(4,-1539493200,6),(4,-1525323600,5),(4,-1522728000,4),(4,-1491188400,7),(4,-1247536800,4),(4,354920409,5),(4,370728010,4),(4,386456410,5),(4,402264011,4),(4,417992411,5),(4,433800012,4),(4,449614812,5),(4,465346812,8),(4,481071612,9),(4,496796413,8),(4,512521213,9),(4,528246013,8),(4,543970813,9),(4,559695613,8),(4,575420414,9),(4,591145214,8),(4,606870014,9),(4,622594814,8),(4,638319615,9),(4,654649215,8),(4,670374016,10),(4,686102416,11),(4,695779216,8),(4,701812816,5),(4,717534017,4),(4,733273217,9),(4,748998018,8),(4,764722818,9),(4,780447619,8),(4,796172419,9),(4,811897219,8),(4,828226820,9),(4,846370820,8),(4,859676420,9),(4,877820421,8),(4,891126021,9),(4,909270021,8),(4,922575622,9),(4,941324422,8),(4,954025222,9),(4,972774022,8),(4,985474822,9),(4,1004223622,8),(4,1017529222,9),(4,1035673222,8),(4,1048978822,9),(4,1067122822,8),(4,1080428422,9),(4,1099177222,8),(4,1111878022,9),(4,1130626822,8),(4,1143327622,9),(4,1162076422,8),(4,1174777222,9),(4,1193526022,8),(4,1206831622,9),(4,1224975622,8),(4,1238281222,9),(4,1256425222,8),(4,1269730822,9),(4,1288479622,8),(4,1301180422,9),(4,1319929222,8),(4,1332630022,9),(4,1351378822,8),(4,1364684422,9),(4,1382828422,8),(4,1396134022,9),(4,1414278022,8),(4,1427583622,9),(4,1445727622,8),(4,1459033222,9),(4,1477782022,8),(4,1490482822,9),(4,1509231622,8),(4,1521932422,9),(4,1540681222,8),(4,1553986822,9),(4,1572130822,8),(4,1585436422,9),(4,1603580422,8),(4,1616886022,9),(4,1635634822,8),(4,1648335622,9),(4,1667084422,8),(4,1679785222,9),(4,1698534022,8),(4,1711839622,9),(4,1729983622,8),(4,1743289222,9),(4,1761433222,8),(4,1774738822,9),(4,1792882822,8),(4,1806188422,9),(4,1824937222,8),(4,1837638022,9),(4,1856386822,8),(4,1869087622,9),(4,1887836422,8),(4,1901142022,9),(4,1919286022,8),(4,1932591622,9),(4,1950735622,8),(4,1964041222,9),(4,1982790022,8),(4,1995490822,9),(4,2014239622,8),(4,2026940422,9),(4,2045689222,8),(4,2058390022,9),(4,2077138822,8),(4,2090444422,9),(4,2108588422,8),(4,2121894022,9),(4,2140038022,8),(5,-1009875600,1);
+/*!40000 ALTER TABLE `time_zone_transition` ENABLE KEYS */;
+UNLOCK TABLES;
+
+LOCK TABLES `time_zone_transition_type` WRITE;
+/*!40000 ALTER TABLE `time_zone_transition_type` DISABLE KEYS */;
+REPLACE INTO `time_zone_transition_type` VALUES (1,0,7200,1,'MEST'),(1,1,3600,0,'MET'),(1,2,7200,1,'MEST'),(1,3,3600,0,'MET'),(2,0,0,0,'UTC'),(3,0,9000,0,'MMT'),(3,1,12648,1,'MST'),(3,2,9048,0,'MMT'),(3,3,16248,1,'MDST'),(3,4,10800,0,'MSK'),(3,5,14400,1,'MSD'),(3,6,18000,1,'MSD'),(3,7,7200,0,'EET'),(3,8,10800,0,'MSK'),(3,9,14400,1,'MSD'),(3,10,10800,1,'EEST'),(3,11,7200,0,'EET'),(4,0,9000,0,'MMT'),(4,1,12648,1,'MST'),(4,2,9048,0,'MMT'),(4,3,16248,1,'MDST'),(4,4,10800,0,'MSK'),(4,5,14400,1,'MSD'),(4,6,18000,1,'MSD'),(4,7,7200,0,'EET'),(4,8,10800,0,'MSK'),(4,9,14400,1,'MSD'),(4,10,10800,1,'EEST'),(4,11,7200,0,'EET'),(5,0,32400,0,'CJT'),(5,1,32400,0,'JST');
+/*!40000 ALTER TABLE `time_zone_transition_type` ENABLE KEYS */;
+UNLOCK TABLES;
+/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
+/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+
+#
+# mysqldump of system tables with --system=all --insert-ignore
+#
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!40101 SET NAMES utf8mb4 */;
+/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
+/*!40103 SET TIME_ZONE='+00:00' */;
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+CREATE USER IF NOT EXISTS `mariadb.sys`@`localhost` PASSWORD EXPIRE;
+CREATE USER IF NOT EXISTS `root`@`localhost`;
+CREATE USER IF NOT EXISTS `USER`@`%`;
+SELECT COALESCE(CURRENT_ROLE(),'NONE') into @current_role;
+CREATE ROLE IF NOT EXISTS mariadb_dump_import_role;
+GRANT mariadb_dump_import_role TO CURRENT_USER();
+SET ROLE mariadb_dump_import_role;
+/*!80001 CREATE ROLE IF NOT EXISTS 'role_1' */;
+/*M!100005 CREATE ROLE IF NOT EXISTS 'role_1' WITH ADMIN mariadb_dump_import_role */;
+/*M!100005 GRANT 'role_1' TO 'root'@'localhost' WITH ADMIN OPTION */;
+/*!80001 CREATE ROLE IF NOT EXISTS 'role_2' */;
+/*M!100005 CREATE ROLE IF NOT EXISTS 'role_2' WITH ADMIN mariadb_dump_import_role */;
+/*M!100005 GRANT 'role_2' TO 'role_1' WITH ADMIN OPTION */;
+GRANT USAGE ON *.* TO `mariadb.sys`@`localhost`;
+GRANT SELECT, DELETE ON `mysql`.`global_priv` TO `mariadb.sys`@`localhost`;
+/*M!100005 SET DEFAULT ROLE NONE FOR 'mariadb.sys'@'localhost' */;
+/*!80001 ALTER USER 'mariadb.sys'@'localhost' DEFAULT ROLE NONE */;
+GRANT `role_1` TO `root`@`localhost` WITH ADMIN OPTION;
+GRANT ALL PRIVILEGES ON *.* TO `root`@`localhost` WITH GRANT OPTION;
+GRANT PROXY ON ''@'%' TO 'root'@'localhost' WITH GRANT OPTION;
+/*M!100005 SET DEFAULT ROLE NONE FOR 'root'@'localhost' */;
+/*!80001 ALTER USER 'root'@'localhost' DEFAULT ROLE NONE */;
+GRANT `role_1` TO `USER`@`%`;
+GRANT `role_2` TO `USER`@`%`;
+GRANT USAGE ON *.* TO `USER`@`%`;
+/*M!100005 SET DEFAULT ROLE 'role_2' FOR 'USER'@'%' */;
+/*!80001 ALTER USER 'USER'@'%' DEFAULT ROLE 'role_2' */;
+GRANT `role_2` TO `role_1` WITH ADMIN OPTION;
+GRANT SHOW DATABASES ON *.* TO `role_1`;
+GRANT USAGE ON *.* TO `role_2`;
+GRANT USAGE ON *.* TO `role_2`;
+SET ROLE NONE;
+DROP ROLE mariadb_dump_import_role;
+/*M!100203 EXECUTE IMMEDIATE CONCAT('SET ROLE ', @current_role) */;
+CREATE FUNCTION IF NOT EXISTS metaphon RETURNS STRING SONAME 'UDF_EXAMPLE_LIB';
+CREATE SERVER /*M!100103 IF NOT EXISTS */ s1 FOREIGN DATA WRAPPER mysql OPTIONS (Host 'localhost', Port 3306);
+
+USE mysql;
+
+LOCK TABLES `column_stats` WRITE;
+/*!40000 ALTER TABLE `column_stats` DISABLE KEYS */;
+INSERT IGNORE INTO `column_stats` VALUES ('mysql','tz','Time_zone_id','1','5',0.0000,4.0000,98.2500,254,'DOUBLE_PREC_HB','\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿');
+/*!40000 ALTER TABLE `column_stats` ENABLE KEYS */;
+UNLOCK TABLES;
+
+LOCK TABLES `index_stats` WRITE;
+/*!40000 ALTER TABLE `index_stats` DISABLE KEYS */;
+INSERT IGNORE INTO `index_stats` VALUES ('mysql','tz','PRIMARY',1,98.2500);
+/*!40000 ALTER TABLE `index_stats` ENABLE KEYS */;
+UNLOCK TABLES;
+
+LOCK TABLES `table_stats` WRITE;
+/*!40000 ALTER TABLE `table_stats` DISABLE KEYS */;
+INSERT IGNORE INTO `table_stats` VALUES ('mysql','tz',393);
+/*!40000 ALTER TABLE `table_stats` ENABLE KEYS */;
+UNLOCK TABLES;
+
+LOCK TABLES `innodb_index_stats` WRITE;
+/*!40000 ALTER TABLE `innodb_index_stats` DISABLE KEYS */;
+INSERT IGNORE INTO `innodb_index_stats` VALUES ('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_diff_pfx01',4,1,'Time_zone_id'),('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_diff_pfx02',393,1,'Time_zone_id,Transition_time'),('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_leaf_pages',1,NULL,'Number of leaf pages in the index'),('mysql','tz','PRIMARY','2019-12-31 21:00:00','size',1,NULL,'Number of pages in the index');
+/*!40000 ALTER TABLE `innodb_index_stats` ENABLE KEYS */;
+UNLOCK TABLES;
+
+LOCK TABLES `innodb_table_stats` WRITE;
+/*!40000 ALTER TABLE `innodb_table_stats` DISABLE KEYS */;
+INSERT IGNORE INTO `innodb_table_stats` VALUES ('mysql','tz','2019-12-31 21:00:00',393,1,0);
+/*!40000 ALTER TABLE `innodb_table_stats` ENABLE KEYS */;
+UNLOCK TABLES;
+
+USE mysql;
+
+LOCK TABLES `time_zone` WRITE;
+/*!40000 ALTER TABLE `time_zone` DISABLE KEYS */;
+INSERT IGNORE INTO `time_zone` VALUES (1,'N'),(2,'N'),(3,'N'),(4,'Y'),(5,'N');
+/*!40000 ALTER TABLE `time_zone` ENABLE KEYS */;
+UNLOCK TABLES;
+
+LOCK TABLES `time_zone_name` WRITE;
+/*!40000 ALTER TABLE `time_zone_name` DISABLE KEYS */;
+INSERT IGNORE INTO `time_zone_name` VALUES ('Europe/Moscow',3),('Japan',5),('leap/Europe/Moscow',4),('MET',1),('Universal',2),('UTC',2);
+/*!40000 ALTER TABLE `time_zone_name` ENABLE KEYS */;
+UNLOCK TABLES;
+
+LOCK TABLES `time_zone_leap_second` WRITE;
+/*!40000 ALTER TABLE `time_zone_leap_second` DISABLE KEYS */;
+INSERT IGNORE INTO `time_zone_leap_second` VALUES (78796800,1),(94694401,2),(126230402,3),(157766403,4),(189302404,5),(220924805,6),(252460806,7),(283996807,8),(315532808,9),(362793609,10),(394329610,11),(425865611,12),(489024012,13),(567993613,14),(631152014,15),(662688015,16),(709948816,17),(741484817,18),(773020818,19),(820454419,20),(867715220,21),(915148821,22);
+/*!40000 ALTER TABLE `time_zone_leap_second` ENABLE KEYS */;
+UNLOCK TABLES;
+
+LOCK TABLES `time_zone_transition` WRITE;
+/*!40000 ALTER TABLE `time_zone_transition` DISABLE KEYS */;
+INSERT IGNORE INTO `time_zone_transition` VALUES (1,-1693706400,0),(1,-1680483600,1),(1,-1663455600,2),(1,-1650150000,3),(1,-1632006000,2),(1,-1618700400,3),(1,-938905200,2),(1,-857257200,3),(1,-844556400,2),(1,-828226800,3),(1,-812502000,2),(1,-796777200,3),(1,228877200,2),(1,243997200,3),(1,260326800,2),(1,276051600,3),(1,291776400,2),(1,307501200,3),(1,323830800,2),(1,338950800,3),(1,354675600,2),(1,370400400,3),(1,386125200,2),(1,401850000,3),(1,417574800,2),(1,433299600,3),(1,449024400,2),(1,465354000,3),(1,481078800,2),(1,496803600,3),(1,512528400,2),(1,528253200,3),(1,543978000,2),(1,559702800,3),(1,575427600,2),(1,591152400,3),(1,606877200,2),(1,622602000,3),(1,638326800,2),(1,654656400,3),(1,670381200,2),(1,686106000,3),(1,701830800,2),(1,717555600,3),(1,733280400,2),(1,749005200,3),(1,764730000,2),(1,780454800,3),(1,796179600,2),(1,811904400,3),(1,828234000,2),(1,846378000,3),(1,859683600,2),(1,877827600,3),(1,891133200,2),(1,909277200,3),(1,922582800,2),(1,941331600,3),(1,954032400,2),(1,972781200,3),(1,985482000,2),(1,1004230800,3),(1,1017536400,2),(1,1035680400,3),(1,1048986000,2),(1,1067130000,3),(1,1080435600,2),(1,1099184400,3),(1,1111885200,2),(1,1130634000,3),(1,1143334800,2),(1,1162083600,3),(1,1174784400,2),(1,1193533200,3),(1,1206838800,2),(1,1224982800,3),(1,1238288400,2),(1,1256432400,3),(1,1269738000,2),(1,1288486800,3),(1,1301187600,2),(1,1319936400,3),(1,1332637200,2),(1,1351386000,3),(1,1364691600,2),(1,1382835600,3),(1,1396141200,2),(1,1414285200,3),(1,1427590800,2),(1,1445734800,3),(1,1459040400,2),(1,1477789200,3),(1,1490490000,2),(1,1509238800,3),(1,1521939600,2),(1,1540688400,3),(1,1553994000,2),(1,1572138000,3),(1,1585443600,2),(1,1603587600,3),(1,1616893200,2),(1,1635642000,3),(1,1648342800,2),(1,1667091600,3),(1,1679792400,2),(1,1698541200,3),(1,1711846800,2),(1,1729990800,3),(1,1743296400,2),(1,1761440400,3),(1,1774746000,2),(1,1792890000,3),(1,1806195600,2),(1,1824944400,3),(1,1837645200,2),(1,1856394000,3),(1,1869094800,2),(1,1887843600,3),(1,1901149200,2),(1,1919293200,3),(1,1932598800,2),(1,1950742800,3),(1,1964048400,2),(1,1982797200,3),(1,1995498000,2),(1,2014246800,3),(1,2026947600,2),(1,2045696400,3),(1,2058397200,2),(1,2077146000,3),(1,2090451600,2),(1,2108595600,3),(1,2121901200,2),(1,2140045200,3),(3,-1688265000,2),(3,-1656819048,1),(3,-1641353448,2),(3,-1627965048,3),(3,-1618716648,1),(3,-1596429048,3),(3,-1593829848,5),(3,-1589860800,4),(3,-1542427200,5),(3,-1539493200,6),(3,-1525323600,5),(3,-1522728000,4),(3,-1491188400,7),(3,-1247536800,4),(3,354920400,5),(3,370728000,4),(3,386456400,5),(3,402264000,4),(3,417992400,5),(3,433800000,4),(3,449614800,5),(3,465346800,8),(3,481071600,9),(3,496796400,8),(3,512521200,9),(3,528246000,8),(3,543970800,9),(3,559695600,8),(3,575420400,9),(3,591145200,8),(3,606870000,9),(3,622594800,8),(3,638319600,9),(3,654649200,8),(3,670374000,10),(3,686102400,11),(3,695779200,8),(3,701812800,5),(3,717534000,4),(3,733273200,9),(3,748998000,8),(3,764722800,9),(3,780447600,8),(3,796172400,9),(3,811897200,8),(3,828226800,9),(3,846370800,8),(3,859676400,9),(3,877820400,8),(3,891126000,9),(3,909270000,8),(3,922575600,9),(3,941324400,8),(3,954025200,9),(3,972774000,8),(3,985474800,9),(3,1004223600,8),(3,1017529200,9),(3,1035673200,8),(3,1048978800,9),(3,1067122800,8),(3,1080428400,9),(3,1099177200,8),(3,1111878000,9),(3,1130626800,8),(3,1143327600,9),(3,1162076400,8),(3,1174777200,9),(3,1193526000,8),(3,1206831600,9),(3,1224975600,8),(3,1238281200,9),(3,1256425200,8),(3,1269730800,9),(3,1288479600,8),(3,1301180400,9),(3,1319929200,8),(3,1332630000,9),(3,1351378800,8),(3,1364684400,9),(3,1382828400,8),(3,1396134000,9),(3,1414278000,8),(3,1427583600,9),(3,1445727600,8),(3,1459033200,9),(3,1477782000,8),(3,1490482800,9),(3,1509231600,8),(3,1521932400,9),(3,1540681200,8),(3,1553986800,9),(3,1572130800,8),(3,1585436400,9),(3,1603580400,8),(3,1616886000,9),(3,1635634800,8),(3,1648335600,9),(3,1667084400,8),(3,1679785200,9),(3,1698534000,8),(3,1711839600,9),(3,1729983600,8),(3,1743289200,9),(3,1761433200,8),(3,1774738800,9),(3,1792882800,8),(3,1806188400,9),(3,1824937200,8),(3,1837638000,9),(3,1856386800,8),(3,1869087600,9),(3,1887836400,8),(3,1901142000,9),(3,1919286000,8),(3,1932591600,9),(3,1950735600,8),(3,1964041200,9),(3,1982790000,8),(3,1995490800,9),(3,2014239600,8),(3,2026940400,9),(3,2045689200,8),(3,2058390000,9),(3,2077138800,8),(3,2090444400,9),(3,2108588400,8),(3,2121894000,9),(3,2140038000,8),(4,-1688265000,2),(4,-1656819048,1),(4,-1641353448,2),(4,-1627965048,3),(4,-1618716648,1),(4,-1596429048,3),(4,-1593829848,5),(4,-1589860800,4),(4,-1542427200,5),(4,-1539493200,6),(4,-1525323600,5),(4,-1522728000,4),(4,-1491188400,7),(4,-1247536800,4),(4,354920409,5),(4,370728010,4),(4,386456410,5),(4,402264011,4),(4,417992411,5),(4,433800012,4),(4,449614812,5),(4,465346812,8),(4,481071612,9),(4,496796413,8),(4,512521213,9),(4,528246013,8),(4,543970813,9),(4,559695613,8),(4,575420414,9),(4,591145214,8),(4,606870014,9),(4,622594814,8),(4,638319615,9),(4,654649215,8),(4,670374016,10),(4,686102416,11),(4,695779216,8),(4,701812816,5),(4,717534017,4),(4,733273217,9),(4,748998018,8),(4,764722818,9),(4,780447619,8),(4,796172419,9),(4,811897219,8),(4,828226820,9),(4,846370820,8),(4,859676420,9),(4,877820421,8),(4,891126021,9),(4,909270021,8),(4,922575622,9),(4,941324422,8),(4,954025222,9),(4,972774022,8),(4,985474822,9),(4,1004223622,8),(4,1017529222,9),(4,1035673222,8),(4,1048978822,9),(4,1067122822,8),(4,1080428422,9),(4,1099177222,8),(4,1111878022,9),(4,1130626822,8),(4,1143327622,9),(4,1162076422,8),(4,1174777222,9),(4,1193526022,8),(4,1206831622,9),(4,1224975622,8),(4,1238281222,9),(4,1256425222,8),(4,1269730822,9),(4,1288479622,8),(4,1301180422,9),(4,1319929222,8),(4,1332630022,9),(4,1351378822,8),(4,1364684422,9),(4,1382828422,8),(4,1396134022,9),(4,1414278022,8),(4,1427583622,9),(4,1445727622,8),(4,1459033222,9),(4,1477782022,8),(4,1490482822,9),(4,1509231622,8),(4,1521932422,9),(4,1540681222,8),(4,1553986822,9),(4,1572130822,8),(4,1585436422,9),(4,1603580422,8),(4,1616886022,9),(4,1635634822,8),(4,1648335622,9),(4,1667084422,8),(4,1679785222,9),(4,1698534022,8),(4,1711839622,9),(4,1729983622,8),(4,1743289222,9),(4,1761433222,8),(4,1774738822,9),(4,1792882822,8),(4,1806188422,9),(4,1824937222,8),(4,1837638022,9),(4,1856386822,8),(4,1869087622,9),(4,1887836422,8),(4,1901142022,9),(4,1919286022,8),(4,1932591622,9),(4,1950735622,8),(4,1964041222,9),(4,1982790022,8),(4,1995490822,9),(4,2014239622,8),(4,2026940422,9),(4,2045689222,8),(4,2058390022,9),(4,2077138822,8),(4,2090444422,9),(4,2108588422,8),(4,2121894022,9),(4,2140038022,8),(5,-1009875600,1);
+/*!40000 ALTER TABLE `time_zone_transition` ENABLE KEYS */;
+UNLOCK TABLES;
+
+LOCK TABLES `time_zone_transition_type` WRITE;
+/*!40000 ALTER TABLE `time_zone_transition_type` DISABLE KEYS */;
+INSERT IGNORE INTO `time_zone_transition_type` VALUES (1,0,7200,1,'MEST'),(1,1,3600,0,'MET'),(1,2,7200,1,'MEST'),(1,3,3600,0,'MET'),(2,0,0,0,'UTC'),(3,0,9000,0,'MMT'),(3,1,12648,1,'MST'),(3,2,9048,0,'MMT'),(3,3,16248,1,'MDST'),(3,4,10800,0,'MSK'),(3,5,14400,1,'MSD'),(3,6,18000,1,'MSD'),(3,7,7200,0,'EET'),(3,8,10800,0,'MSK'),(3,9,14400,1,'MSD'),(3,10,10800,1,'EEST'),(3,11,7200,0,'EET'),(4,0,9000,0,'MMT'),(4,1,12648,1,'MST'),(4,2,9048,0,'MMT'),(4,3,16248,1,'MDST'),(4,4,10800,0,'MSK'),(4,5,14400,1,'MSD'),(4,6,18000,1,'MSD'),(4,7,7200,0,'EET'),(4,8,10800,0,'MSK'),(4,9,14400,1,'MSD'),(4,10,10800,1,'EEST'),(4,11,7200,0,'EET'),(5,0,32400,0,'CJT'),(5,1,32400,0,'JST');
+/*!40000 ALTER TABLE `time_zone_transition_type` ENABLE KEYS */;
+UNLOCK TABLES;
+/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
+/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+
+SELECT * FROM mysql.global_priv ORDER BY User,Host;
+Host User Priv
+% USER {"access":0,"version_id":VERSION,"plugin":"mysql_native_password","authentication_string":"","password_last_changed":NOW,"default_role":"role_2"}
+localhost mariadb.sys {"access":0,"plugin":"mysql_native_password","authentication_string":"","account_locked":false,"password_last_changed":NOW,"version_id":VERSION}
+ role_1 {"access":16384,"version_id":VERSION,"is_role":true}
+ role_2 {"access":0,"version_id":VERSION,"is_role":true}
+localhost root {"access":18446744073709551615}
+CHECKSUM TABLE mysql.roles_mapping, mysql.time_zone_transition, mysql.plugin,
+mysql.servers, mysql.func, mysql.innodb_table_stats, mysql.table_stats;
+Table Checksum
+mysql.roles_mapping 3150178430
+mysql.time_zone_transition 3895294076
+mysql.plugin 0
+mysql.servers 2783974349
+mysql.func 3241572444
+mysql.innodb_table_stats 347867921
+mysql.table_stats 664320059
+# Opps....
+CREATE USER mariadb_test_restore IDENTIFIED BY 'getitback';
+GRANT ALL ON *.* TO mariadb_test_restore WITH GRANT OPTION;
+GRANT PROXY ON ''@'%' TO mariadb_test_restore WITH GRANT OPTION;
+GRANT SUPER, CREATE USER /*M!100502 ,FEDERATED ADMIN */ ON *.* TO mariadb_test_restore WITH GRANT OPTION;
+drop user USER;
+delete from mysql.table_stats;
+delete from mysql.innodb_table_stats;
+delete from mysql.time_zone_transition;
+delete from mysql.time_zone_transition_type;
+delete from mysql.time_zone;
+delete from mysql.time_zone_name;
+delete from mysql.time_zone_leap_second;
+DROP FUNCTION IF EXISTS metaphon;
+DROP SERVER s1;
+set time_zone= @@global.time_zone;
+# Restore from mysqldump
+DROP USER mariadb_test_restore;
+SELECT * FROM mysql.global_priv ORDER BY User,Host;
+Host User Priv
+% USER {"access":0,"version_id":VERSION,"plugin":"mysql_native_password","authentication_string":"","password_last_changed":NOW,"default_role":"role_2"}
+localhost mariadb.sys {"access":0,"version_id":VERSION,"plugin":"mysql_native_password","authentication_string":"","password_last_changed":NOW,"password_lifetime":-1,"default_role":""}
+ role_1 {"access":16384,"version_id":VERSION,"is_role":true}
+ role_2 {"access":0,"version_id":VERSION,"is_role":true}
+localhost root {"access":274877906943,"version_id":VERSION,"plugin":"mysql_native_password","authentication_string":"","password_last_changed":NOW,"default_role":""}
+CHECKSUM TABLE mysql.roles_mapping, mysql.time_zone_transition, mysql.plugin,
+mysql.servers, mysql.func, mysql.innodb_table_stats, mysql.table_stats;
+Table Checksum
+mysql.roles_mapping 3150178430
+mysql.time_zone_transition 3895294076
+mysql.plugin 0
+mysql.servers 2783974349
+mysql.func 3241572444
+mysql.innodb_table_stats 347867921
+mysql.table_stats 664320059
+DROP FUNCTION IF EXISTS metaphon;
+DROP SERVER s1;
+DELETE FROM mysql.column_stats WHERE db_name='mysql' and table_name in ('tz', 'gtid_slave_pos');
+DELETE FROM mysql.index_stats WHERE db_name='mysql' and table_name in ('tz', 'gtid_slave_pos');
+DELETE FROM mysql.table_stats WHERE db_name='mysql' and table_name in ('tz', 'gtid_slave_pos');
+DELETE FROM mysql.innodb_index_stats WHERE database_name='mysql' and table_name in ('tz','gtid_slave_pos');
+DELETE FROM mysql.innodb_table_stats WHERE database_name='mysql' and table_name in ('tz','gtid_slave_pos');
+drop table mysql.tz;
+DROP ROLE role_2;
+DROP ROLE role_1;
+drop user USER;
+replace into mysql.global_priv select * from backup_users;
+replace into mysql.tables_priv select * from tables_priv;
+flush privileges;
+drop table backup_users, tables_priv;
diff --git a/mysql-test/main/mysqldump-system.test b/mysql-test/main/mysqldump-system.test
new file mode 100644
index 00000000000..9aaa5fff6f9
--- /dev/null
+++ b/mysql-test/main/mysqldump-system.test
@@ -0,0 +1,155 @@
+--source include/not_embedded.inc
+--source include/have_innodb.inc
+--source include/have_udf.inc
+--source include/platform.inc
+
+--echo #
+--echo # MDEV-23630: mysqldump to logically dump system tables
+--echo #
+--echo #
+
+create table backup_users like mysql.global_priv;
+create table tables_priv like mysql.tables_priv;
+insert into backup_users select * from mysql.global_priv;
+insert into tables_priv select * from mysql.tables_priv;
+delete from mysql.global_priv where host not in ('localhost');
+flush privileges;
+
+# mariadb.sys because of MDEV-24098
+alter user 'mariadb.sys'@'localhost' ACCOUNT UNLOCK;
+create user USER;
+
+# time zone data already loaded
+
+CREATE ROLE role_1;
+CREATE ROLE role_2 WITH ADMIN role_1;
+
+GRANT SHOW DATABASES ON *.* TO role_1;
+GRANT role_1 TO USER;
+GRANT role_2 TO USER;
+SET DEFAULT ROLE role_2 FOR USER;
+
+ALTER TABLE mysql.roles_mapping ORDER BY Host, User, Role;
+
+# innodb and EITS tables statistics
+#
+set @save_innodb_stats_persistent= @@innodb_stats_persistent;
+create table mysql.tz like mysql.time_zone_transition;
+alter table mysql.tz engine=innodb;
+insert into mysql.tz select * from mysql.time_zone_transition;
+set global innodb_stats_persistent=1;
+ANALYZE TABLE mysql.tz PERSISTENT FOR ALL;
+# for predictable output in tests
+delete from mysql.index_stats where prefix_arity!=1;
+delete from mysql.column_stats where column_name!='Time_zone_id';
+set time_zone="+03:00";
+update mysql.innodb_index_stats set last_update="2020-01-01" where database_name="mysql" and table_name="tz";
+update mysql.innodb_table_stats set last_update="2020-01-01" where database_name="mysql" and table_name="tz";
+set global innodb_stats_persistent= @save_innodb_stats_persistent;
+alter table mysql.time_zone_name ORDER BY Name;
+
+CREATE SERVER s1 FOREIGN DATA WRAPPER mysql OPTIONS(Host 'localhost');
+
+--replace_result $UDF_EXAMPLE_SO UDF_EXAMPLE_LIB
+eval CREATE FUNCTION metaphon RETURNS STRING SONAME "$UDF_EXAMPLE_SO";
+
+
+#
+# Lets actually do some tests.
+#
+
+--echo #
+--echo # mysqldump of system tables with --system=all
+--echo #
+
+--replace_result $UDF_EXAMPLE_SO UDF_EXAMPLE_LIB
+--exec $MYSQL_DUMP --skip-comments --system=all
+
+
+--echo #
+--echo # mysqldump of system tables with --system=all --replace
+--echo #
+
+--replace_result $UDF_EXAMPLE_SO UDF_EXAMPLE_LIB
+--exec $MYSQL_DUMP --skip-comments --system=all --replace
+
+
+# save this for restore
+--exec $MYSQL_DUMP --system=users,servers,stats,timezones,udfs --replace > $MYSQLTEST_VARDIR/tmp/dump1.sql
+
+--echo #
+--echo # mysqldump of system tables with --system=all --insert-ignore
+--echo #
+
+--replace_result $UDF_EXAMPLE_SO UDF_EXAMPLE_LIB
+--exec $MYSQL_DUMP --skip-comments --system=all --insert-ignore
+
+
+# global_priv checksum not restored because:
+# mariadb.sys - different Priv on restore
+# password_last_changed date isn't saved/restored
+# root user's Priv $.access lower number on restore
+
+--replace_regex /"password_last_changed":[0-9]+/"password_last_changed":NOW/ /"version_id":[0-9]+/"version_id":VERSION/
+SELECT * FROM mysql.global_priv ORDER BY User,Host;
+
+CHECKSUM TABLE mysql.roles_mapping, mysql.time_zone_transition, mysql.plugin,
+ mysql.servers, mysql.func, mysql.innodb_table_stats, mysql.table_stats;
+
+--echo # Opps....
+
+CREATE USER mariadb_test_restore IDENTIFIED BY 'getitback';
+GRANT ALL ON *.* TO mariadb_test_restore WITH GRANT OPTION;
+GRANT PROXY ON ''@'%' TO mariadb_test_restore WITH GRANT OPTION;
+GRANT SUPER, CREATE USER /*M!100502 ,FEDERATED ADMIN */ ON *.* TO mariadb_test_restore WITH GRANT OPTION;
+
+drop user USER;
+delete from mysql.table_stats;
+delete from mysql.innodb_table_stats;
+delete from mysql.time_zone_transition;
+delete from mysql.time_zone_transition_type;
+delete from mysql.time_zone;
+delete from mysql.time_zone_name;
+delete from mysql.time_zone_leap_second;
+DROP FUNCTION IF EXISTS metaphon;
+DROP SERVER s1;
+set time_zone= @@global.time_zone;
+
+--echo # Restore from mysqldump
+--exec $MYSQL --user mariadb_test_restore --password=getitback --show-warnings < $MYSQLTEST_VARDIR/tmp/dump1.sql
+
+DROP USER mariadb_test_restore;
+
+# successful restore?
+
+--replace_regex /"password_last_changed":[0-9]+/"password_last_changed":NOW/ /"version_id":[0-9]+/"version_id":VERSION/
+SELECT * FROM mysql.global_priv ORDER BY User,Host;
+
+CHECKSUM TABLE mysql.roles_mapping, mysql.time_zone_transition, mysql.plugin,
+ mysql.servers, mysql.func, mysql.innodb_table_stats, mysql.table_stats;
+
+#
+# Cleanup
+#
+
+DROP FUNCTION IF EXISTS metaphon;
+
+DROP SERVER s1;
+
+# EITS && innodb stats
+DELETE FROM mysql.column_stats WHERE db_name='mysql' and table_name in ('tz', 'gtid_slave_pos');
+DELETE FROM mysql.index_stats WHERE db_name='mysql' and table_name in ('tz', 'gtid_slave_pos');
+DELETE FROM mysql.table_stats WHERE db_name='mysql' and table_name in ('tz', 'gtid_slave_pos');
+DELETE FROM mysql.innodb_index_stats WHERE database_name='mysql' and table_name in ('tz','gtid_slave_pos');
+DELETE FROM mysql.innodb_table_stats WHERE database_name='mysql' and table_name in ('tz','gtid_slave_pos');
+drop table mysql.tz;
+
+DROP ROLE role_2;
+DROP ROLE role_1;
+
+drop user USER;
+
+replace into mysql.global_priv select * from backup_users;
+replace into mysql.tables_priv select * from tables_priv;
+flush privileges;
+drop table backup_users, tables_priv;
diff --git a/mysql-test/main/mysqldump.result b/mysql-test/main/mysqldump.result
index a263b81a28c..c1528b98a7c 100644
--- a/mysql-test/main/mysqldump.result
+++ b/mysql-test/main/mysqldump.result
@@ -5421,8 +5421,9 @@ proc
one
DROP DATABASE bug25717383;
Usage: mysqldump [OPTIONS] database [tables]
-OR mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]
-OR mysqldump [OPTIONS] --all-databases [OPTIONS]
+OR mysqldump [OPTIONS] --databases DB1 [DB2 DB3...]
+OR mysqldump [OPTIONS] --all-databases
+OR mysqldump [OPTIONS] --system=[SYSTEMOPTIONS]]
For more options, use mysqldump --help
#
# MDEV-9001 - [PATCH] Fix DB name quoting in mysqldump --routine
diff --git a/mysql-test/main/set_password.result b/mysql-test/main/set_password.result
index 8a8af3b3350..6a4e0da937e 100644
--- a/mysql-test/main/set_password.result
+++ b/mysql-test/main/set_password.result
@@ -1,14 +1,21 @@
set global secure_auth=0;
create user natauth@localhost identified via 'mysql_native_password' using '*94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29';
+create user invalidauth@localhost identified via 'mysql_native_password' using 'invalid';
create user newpass@localhost identified by password '*94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29';
+create user invalidpass@localhost identified by password 'invalid';
create user newpassnat@localhost identified via 'mysql_native_password';
set password for newpassnat@localhost = '*94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29';
+create user invalidpassnat@localhost identified by password 'invalid';
+set password for invalidpassnat@localhost = 'invalid';
create user oldauth@localhost identified with 'mysql_old_password' using '378b243e220ca493';
create user oldpass@localhost identified by password '378b243e220ca493';
create user oldpassold@localhost identified with 'mysql_old_password';
set password for oldpassold@localhost = '378b243e220ca493';
select user, host, password, plugin, authentication_string from mysql.user where user != 'root';
User Host Password plugin authentication_string
+invalidauth localhost invalid mysql_native_password invalid
+invalidpass localhost invalid mysql_native_password invalid
+invalidpassnat localhost invalid mysql_native_password invalid
mariadb.sys localhost mysql_native_password
natauth localhost *94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29 mysql_native_password *94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29
newpass localhost *94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29 mysql_native_password *94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29
@@ -87,6 +94,9 @@ set password for oldpass@localhost = PASSWORD('test2');
set password for oldpassold@localhost = PASSWORD('test2');
select user, host, password, plugin, authentication_string from mysql.user where user != 'root';
User Host Password plugin authentication_string
+invalidauth localhost invalid mysql_native_password invalid
+invalidpass localhost invalid mysql_native_password invalid
+invalidpassnat localhost invalid mysql_native_password invalid
mariadb.sys localhost mysql_native_password
natauth localhost *7CEB3FDE5F7A9C4CE5FBE610D7D8EDA62EBE5F4E mysql_native_password *7CEB3FDE5F7A9C4CE5FBE610D7D8EDA62EBE5F4E
newpass localhost *7CEB3FDE5F7A9C4CE5FBE610D7D8EDA62EBE5F4E mysql_native_password *7CEB3FDE5F7A9C4CE5FBE610D7D8EDA62EBE5F4E
@@ -141,6 +151,15 @@ select current_user();
current_user()
newpassnat@localhost
disconnect con;
+connect(localhost,invalidauth,invalid,test,MASTER_PORT,MASTER_SOCKET);
+connect con,localhost,invalidauth,invalid,;
+ERROR 28000: Access denied for user 'invalidauth'@'localhost' (using password: YES)
+connect(localhost,invalidpass,invalid,test,MASTER_PORT,MASTER_SOCKET);
+connect con,localhost,invalidpass,invalid,;
+ERROR 28000: Access denied for user 'invalidpass'@'localhost' (using password: YES)
+connect(localhost,invalidpassnat,invalid,test,MASTER_PORT,MASTER_SOCKET);
+connect con,localhost,invalidpassnat,invalid,;
+ERROR 28000: Access denied for user 'invalidpassnat'@'localhost' (using password: YES)
connect con,localhost,oldauth,test2,;
select current_user();
current_user()
@@ -158,6 +177,7 @@ oldpassold@localhost
disconnect con;
connection default;
drop user natauth@localhost, newpass@localhost, newpassnat@localhost;
+drop user invalidauth@localhost, invalidpass@localhost, invalidpassnat@localhost;
drop user oldauth@localhost, oldpass@localhost, oldpassold@localhost;
set global secure_auth=default;
# switching from mysql.global_priv to mysql.user
diff --git a/mysql-test/main/set_password.test b/mysql-test/main/set_password.test
index c67dc22dc81..dd5e261346b 100644
--- a/mysql-test/main/set_password.test
+++ b/mysql-test/main/set_password.test
@@ -12,11 +12,18 @@ set global secure_auth=0;
# The hash (old and new) is for 'test'
create user natauth@localhost identified via 'mysql_native_password' using '*94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29';
+create user invalidauth@localhost identified via 'mysql_native_password' using 'invalid';
+
create user newpass@localhost identified by password '*94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29';
+create user invalidpass@localhost identified by password 'invalid';
+
create user newpassnat@localhost identified via 'mysql_native_password';
set password for newpassnat@localhost = '*94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29';
+create user invalidpassnat@localhost identified by password 'invalid';
+set password for invalidpassnat@localhost = 'invalid';
+
create user oldauth@localhost identified with 'mysql_old_password' using '378b243e220ca493';
create user oldpass@localhost identified by password '378b243e220ca493';
@@ -114,6 +121,17 @@ select current_user();
--connect(con,localhost,newpassnat,test2,)
select current_user();
--disconnect con
+
+--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
+--error ER_ACCESS_DENIED_ERROR
+--connect(con,localhost,invalidauth,invalid,)
+--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
+--error ER_ACCESS_DENIED_ERROR
+--connect(con,localhost,invalidpass,invalid,)
+--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
+--error ER_ACCESS_DENIED_ERROR
+--connect(con,localhost,invalidpassnat,invalid,)
+
--connect(con,localhost,oldauth,test2,)
select current_user();
--disconnect con
@@ -126,6 +144,7 @@ select current_user();
--connection default
drop user natauth@localhost, newpass@localhost, newpassnat@localhost;
+drop user invalidauth@localhost, invalidpass@localhost, invalidpassnat@localhost;
drop user oldauth@localhost, oldpass@localhost, oldpassold@localhost;
set global secure_auth=default;
diff --git a/mysql-test/suite/innodb/r/instant_alter_bugs.result b/mysql-test/suite/innodb/r/instant_alter_bugs.result
index 02376a3cc79..79f1b0eb068 100644
--- a/mysql-test/suite/innodb/r/instant_alter_bugs.result
+++ b/mysql-test/suite/innodb/r/instant_alter_bugs.result
@@ -439,4 +439,16 @@ check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
drop table t1;
+#
+# MDEV-24072 Assertion 'ib_table.n_v_cols' failed
+# in instant_alter_column_possible()
+#
+CREATE TABLE t (a BLOB) ENGINE=InnoDB;
+INSERT INTO t VALUES ('a');
+ALTER TABLE t ADD c INT GENERATED ALWAYS AS (a+1) VIRTUAL, ADD KEY(c);
+ERROR 22007: Truncated incorrect DOUBLE value: 'a'
+ALTER TABLE t ADD d INT;
+affected rows: 0
+info: Records: 0 Duplicates: 0 Warnings: 0
+DROP TABLE t;
SET GLOBAL innodb_purge_rseg_truncate_frequency=@save_frequency;
diff --git a/mysql-test/suite/innodb/t/instant_alter_bugs.test b/mysql-test/suite/innodb/t/instant_alter_bugs.test
index ad4343a056d..ec9f609138c 100644
--- a/mysql-test/suite/innodb/t/instant_alter_bugs.test
+++ b/mysql-test/suite/innodb/t/instant_alter_bugs.test
@@ -454,4 +454,17 @@ select * from t1;
check table t1;
drop table t1;
+--echo #
+--echo # MDEV-24072 Assertion 'ib_table.n_v_cols' failed
+--echo # in instant_alter_column_possible()
+--echo #
+CREATE TABLE t (a BLOB) ENGINE=InnoDB;
+INSERT INTO t VALUES ('a');
+--error ER_TRUNCATED_WRONG_VALUE
+ALTER TABLE t ADD c INT GENERATED ALWAYS AS (a+1) VIRTUAL, ADD KEY(c);
+--enable_info
+ALTER TABLE t ADD d INT;
+--disable_info
+DROP TABLE t;
+
SET GLOBAL innodb_purge_rseg_truncate_frequency=@save_frequency;
diff --git a/mysql-test/suite/wsrep/r/variables.result b/mysql-test/suite/wsrep/r/variables.result
index a9988fd1628..1c427b34d2b 100644
--- a/mysql-test/suite/wsrep/r/variables.result
+++ b/mysql-test/suite/wsrep/r/variables.result
@@ -20,131 +20,6 @@ SET GLOBAL wsrep_provider=none;
# variables when using "_"
#
CALL mtr.add_suppression("WSREP: Could not open saved state file for reading.*");
-SHOW GLOBAL STATUS LIKE 'wsrep%';
-Variable_name Value
-wsrep_local_state_uuid #
-wsrep_protocol_version #
-wsrep_last_committed #
-wsrep_replicated #
-wsrep_replicated_bytes #
-wsrep_repl_keys #
-wsrep_repl_keys_bytes #
-wsrep_repl_data_bytes #
-wsrep_repl_other_bytes #
-wsrep_received #
-wsrep_received_bytes #
-wsrep_local_commits #
-wsrep_local_cert_failures #
-wsrep_local_replays #
-wsrep_local_send_queue #
-wsrep_local_send_queue_max #
-wsrep_local_send_queue_min #
-wsrep_local_send_queue_avg #
-wsrep_local_recv_queue #
-wsrep_local_recv_queue_max #
-wsrep_local_recv_queue_min #
-wsrep_local_recv_queue_avg #
-wsrep_local_cached_downto #
-wsrep_flow_control_paused_ns #
-wsrep_flow_control_paused #
-wsrep_flow_control_sent #
-wsrep_flow_control_recv #
-wsrep_flow_control_active #
-wsrep_flow_control_requested #
-wsrep_cert_deps_distance #
-wsrep_apply_oooe #
-wsrep_apply_oool #
-wsrep_apply_window #
-wsrep_commit_oooe #
-wsrep_commit_oool #
-wsrep_commit_window #
-wsrep_local_state #
-wsrep_local_state_comment #
-wsrep_cert_index_size #
-wsrep_causal_reads #
-wsrep_cert_interval #
-wsrep_open_transactions #
-wsrep_open_connections #
-wsrep_incoming_addresses #
-wsrep_applier_thread_count #
-wsrep_cluster_capabilities #
-wsrep_cluster_conf_id #
-wsrep_cluster_size #
-wsrep_cluster_state_uuid #
-wsrep_cluster_status #
-wsrep_connected #
-wsrep_local_bf_aborts #
-wsrep_local_index #
-wsrep_provider_capabilities #
-wsrep_provider_name #
-wsrep_provider_vendor #
-wsrep_provider_version #
-wsrep_ready #
-wsrep_rollbacker_thread_count #
-wsrep_thread_count #
-
-SHOW GLOBAL STATUS LIKE 'wsrep_%';
-Variable_name Value
-wsrep_local_state_uuid #
-wsrep_protocol_version #
-wsrep_last_committed #
-wsrep_replicated #
-wsrep_replicated_bytes #
-wsrep_repl_keys #
-wsrep_repl_keys_bytes #
-wsrep_repl_data_bytes #
-wsrep_repl_other_bytes #
-wsrep_received #
-wsrep_received_bytes #
-wsrep_local_commits #
-wsrep_local_cert_failures #
-wsrep_local_replays #
-wsrep_local_send_queue #
-wsrep_local_send_queue_max #
-wsrep_local_send_queue_min #
-wsrep_local_send_queue_avg #
-wsrep_local_recv_queue #
-wsrep_local_recv_queue_max #
-wsrep_local_recv_queue_min #
-wsrep_local_recv_queue_avg #
-wsrep_local_cached_downto #
-wsrep_flow_control_paused_ns #
-wsrep_flow_control_paused #
-wsrep_flow_control_sent #
-wsrep_flow_control_recv #
-wsrep_flow_control_active #
-wsrep_flow_control_requested #
-wsrep_cert_deps_distance #
-wsrep_apply_oooe #
-wsrep_apply_oool #
-wsrep_apply_window #
-wsrep_commit_oooe #
-wsrep_commit_oool #
-wsrep_commit_window #
-wsrep_local_state #
-wsrep_local_state_comment #
-wsrep_cert_index_size #
-wsrep_causal_reads #
-wsrep_cert_interval #
-wsrep_open_transactions #
-wsrep_open_connections #
-wsrep_incoming_addresses #
-wsrep_applier_thread_count #
-wsrep_cluster_capabilities #
-wsrep_cluster_conf_id #
-wsrep_cluster_size #
-wsrep_cluster_state_uuid #
-wsrep_cluster_status #
-wsrep_connected #
-wsrep_local_bf_aborts #
-wsrep_local_index #
-wsrep_provider_capabilities #
-wsrep_provider_name #
-wsrep_provider_vendor #
-wsrep_provider_version #
-wsrep_ready #
-wsrep_rollbacker_thread_count #
-wsrep_thread_count #
SHOW GLOBAL STATUS LIKE 'wsrep_local_state_comment';
Variable_name Value
wsrep_local_state_comment #
diff --git a/mysql-test/suite/wsrep/t/variables.test b/mysql-test/suite/wsrep/t/variables.test
index f2c3a0a3b78..cae2fe5d6db 100644
--- a/mysql-test/suite/wsrep/t/variables.test
+++ b/mysql-test/suite/wsrep/t/variables.test
@@ -1,7 +1,6 @@
--source include/have_wsrep.inc
--source include/force_restart.inc
--source include/have_innodb.inc
---source include/galera_have_debug_sync.inc
call mtr.add_suppression("WSREP: Initial position was provided by configuration or SST, avoiding override");
@@ -37,13 +36,6 @@ eval SET GLOBAL wsrep_provider= '$WSREP_PROVIDER';
--enable_query_log
--replace_column 2 #
-SHOW GLOBAL STATUS LIKE 'wsrep%';
-
---echo
---replace_column 2 #
-SHOW GLOBAL STATUS LIKE 'wsrep_%';
-
---replace_column 2 #
SHOW GLOBAL STATUS LIKE 'wsrep_local_state_comment';
--echo # Should show nothing.
@@ -78,7 +70,7 @@ call mtr.add_suppression("WSREP: Failed to get provider options");
eval SET GLOBAL wsrep_provider= '$WSREP_PROVIDER';
--enable_query_log
---replace_regex /.*libgalera_smm.*/libgalera_smm.so/
+--replace_regex /.*libgalera.*smm.*/libgalera_smm.so/
SELECT @@global.wsrep_provider;
SELECT @@global.wsrep_slave_threads;
SELECT @@global.wsrep_cluster_address;
@@ -91,7 +83,7 @@ SHOW STATUS LIKE 'wsrep_thread_count';
eval SET GLOBAL wsrep_provider= '$WSREP_PROVIDER';
--enable_query_log
---replace_regex /.*libgalera_smm.*/libgalera_smm.so/
+--replace_regex /.*libgalera.*smm.*/libgalera_smm.so/
SELECT @@global.wsrep_provider;
SELECT @@global.wsrep_cluster_address;
SELECT @@global.wsrep_on;
@@ -114,7 +106,7 @@ SELECT VARIABLE_VALUE AS EXPECT_1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VA
SELECT VARIABLE_VALUE AS EXPECT_1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_rollbacker_thread_count';
SELECT VARIABLE_VALUE AS EXPECT_2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_thread_count';
---replace_regex /.*libgalera_smm.*/libgalera_smm.so/
+--replace_regex /.*libgalera.*smm.*/libgalera_smm.so/
SELECT @@global.wsrep_provider;
SELECT @@global.wsrep_cluster_address;
SELECT @@global.wsrep_on;
diff --git a/mysys/array.c b/mysys/array.c
index 1d1d9dd1c64..59698a4cc7c 100644
--- a/mysys/array.c
+++ b/mysys/array.c
@@ -140,8 +140,9 @@ void *alloc_dynamic(DYNAMIC_ARRAY *array)
array->size_of_element,
MYF(array->malloc_flags | MY_WME))))
DBUG_RETURN(0);
- memcpy(new_ptr, array->buffer,
- array->elements * array->size_of_element);
+ if (array->elements)
+ memcpy(new_ptr, array->buffer,
+ array->elements * array->size_of_element);
array->malloc_flags&= ~MY_INIT_BUFFER_USED;
}
else if (!(new_ptr=(char*)
diff --git a/mysys/my_alloc.c b/mysys/my_alloc.c
index d7e62726b22..edcb4ce7483 100644
--- a/mysys/my_alloc.c
+++ b/mysys/my_alloc.c
@@ -477,7 +477,7 @@ char *strmake_root(MEM_ROOT *root, const char *str, size_t len)
void *memdup_root(MEM_ROOT *root, const void *str, size_t len)
{
char *pos;
- if ((pos=alloc_root(root,len)))
+ if ((pos=alloc_root(root,len)) && len)
memcpy(pos,str,len);
return pos;
}
diff --git a/plugin/server_audit/server_audit.c b/plugin/server_audit/server_audit.c
index bd630a16eb7..87f53b1db87 100644
--- a/plugin/server_audit/server_audit.c
+++ b/plugin/server_audit/server_audit.c
@@ -709,6 +709,8 @@ static char *coll_search(struct user_coll *c, const char *n, size_t len)
{
struct user_name un;
struct user_name *found;
+ if (!c->n_users)
+ return 0;
un.name_len= len;
un.name= (char *) n;
found= (struct user_name*) bsearch(&un, c->users, c->n_users,
@@ -739,7 +741,8 @@ static int coll_insert(struct user_coll *c, char *n, size_t len)
static void coll_sort(struct user_coll *c)
{
- qsort(c->users, c->n_users, sizeof(c->users[0]), cmp_users);
+ if (c->n_users)
+ qsort(c->users, c->n_users, sizeof(c->users[0]), cmp_users);
}
@@ -970,7 +973,8 @@ static void get_str_n(char *dest, int *dest_len, size_t dest_size,
if (src_len >= dest_size)
src_len= dest_size - 1;
- memcpy(dest, src, src_len);
+ if (src_len)
+ memcpy(dest, src, src_len);
dest[src_len]= 0;
*dest_len= (int)src_len;
}
diff --git a/sql/field.cc b/sql/field.cc
index f8d9cbf93ce..fe3aebce05d 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -8724,7 +8724,10 @@ int Field_blob::cmp_binary(const uchar *a_ptr, const uchar *b_ptr,
b_length=get_length(b_ptr);
if (b_length > max_length)
b_length=max_length;
- diff=memcmp(a,b,MY_MIN(a_length,b_length));
+ if (uint32 len= MY_MIN(a_length,b_length))
+ diff= memcmp(a,b,len);
+ else
+ diff= 0;
return diff ? diff : (int) (a_length - b_length);
}
@@ -8751,7 +8754,8 @@ uint Field_blob::get_key_image_itRAW(const uchar *ptr_arg, uchar *buff,
length=(uint) blob_length;
}
int2store(buff,length);
- memcpy(buff+HA_KEY_BLOB_LENGTH, blob, length);
+ if (length)
+ memcpy(buff+HA_KEY_BLOB_LENGTH, blob, length);
return HA_KEY_BLOB_LENGTH+length;
}
diff --git a/sql/handler.h b/sql/handler.h
index e06b6a7aa43..41da458aa2a 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -866,8 +866,10 @@ struct xid_t {
void set(long f, const char *g, long gl, const char *b, long bl)
{
formatID= f;
- memcpy(data, g, gtrid_length= gl);
- memcpy(data+gl, b, bqual_length= bl);
+ if ((gtrid_length= gl))
+ memcpy(data, g, gl);
+ if ((bqual_length= bl))
+ memcpy(data+gl, b, bl);
}
void set(ulonglong xid)
{
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 027488e0279..e133fead665 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -4894,7 +4894,8 @@ update_hash(user_var_entry *entry, bool set_null, void *ptr, size_t length,
length--; // Fix length change above
entry->value[length]= 0; // Store end \0
}
- memmove(entry->value, ptr, length);
+ if (length)
+ memmove(entry->value, ptr, length);
if (type == DECIMAL_RESULT)
((my_decimal*)entry->value)->fix_buffer_pointer();
entry->length= length;
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 4a94169c6f8..5d0578df4ac 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2015, Oracle and/or its affiliates.
- Copyright (c) 2008, 2015, MariaDB
+ Copyright (c) 2008, 2020, MariaDB
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
@@ -473,7 +473,8 @@ Item_sum::Item_sum(THD *thd, Item_sum *item):
if (!(orig_args= (Item**) thd->alloc(sizeof(Item*)*arg_count)))
return;
}
- memcpy(orig_args, item->orig_args, sizeof(Item*)*arg_count);
+ if (arg_count)
+ memcpy(orig_args, item->orig_args, sizeof(Item*)*arg_count);
init_aggregator();
with_distinct= item->with_distinct;
if (item->aggr)
@@ -1132,7 +1133,8 @@ Item_sum_num::fix_fields(THD *thd, Item **ref)
check_sum_func(thd, ref))
return TRUE;
- memcpy (orig_args, args, sizeof (Item *) * arg_count);
+ if (arg_count)
+ memcpy (orig_args, args, sizeof (Item *) * arg_count);
fixed= 1;
return FALSE;
}
@@ -1365,7 +1367,8 @@ Item_sum_sp::fix_fields(THD *thd, Item **ref)
if (check_sum_func(thd, ref))
return TRUE;
- memcpy(orig_args, args, sizeof(Item *) * arg_count);
+ if (arg_count)
+ memcpy(orig_args, args, sizeof(Item *) * arg_count);
fixed= 1;
return FALSE;
}
@@ -3928,7 +3931,8 @@ Item_func_group_concat(THD *thd, Name_resolution_context *context_arg,
/* orig_args is only used for print() */
orig_args= (Item**) (order + arg_count_order);
- memcpy(orig_args, args, sizeof(Item*) * arg_count);
+ if (arg_count)
+ memcpy(orig_args, args, sizeof(Item*) * arg_count);
if (limit_clause)
{
row_limit= row_limit_arg;
diff --git a/sql/lex_string.h b/sql/lex_string.h
index 008e5f75812..e7a732346c4 100644
--- a/sql/lex_string.h
+++ b/sql/lex_string.h
@@ -76,12 +76,12 @@ static inline bool lex_string_cmp(CHARSET_INFO *charset, const LEX_CSTRING *a,
static inline bool cmp(const LEX_CSTRING *a, const LEX_CSTRING *b)
{
- return (a->length != b->length ||
- memcmp(a->str, b->str, a->length));
+ return a->length != b->length ||
+ (a->length && memcmp(a->str, b->str, a->length));
}
static inline bool cmp(const LEX_CSTRING a, const LEX_CSTRING b)
{
- return a.length != b.length || memcmp(a.str, b.str, a.length);
+ return a.length != b.length || (a.length && memcmp(a.str, b.str, a.length));
}
/*
diff --git a/sql/mf_iocache_encr.cc b/sql/mf_iocache_encr.cc
index 072c0a48269..63830ec620a 100644
--- a/sql/mf_iocache_encr.cc
+++ b/sql/mf_iocache_encr.cc
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2015, MariaDB
+ Copyright (c) 2015, 2020, MariaDB
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
@@ -85,7 +85,6 @@ static int my_b_encr_read(IO_CACHE *info, uchar *Buffer, size_t Count)
do
{
- size_t copied;
uint elength, wlength, length;
uchar iv[MY_AES_BLOCK_SIZE]= {0};
@@ -116,11 +115,13 @@ static int my_b_encr_read(IO_CACHE *info, uchar *Buffer, size_t Count)
DBUG_ASSERT(length <= info->buffer_length);
- copied= MY_MIN(Count, (size_t)(length - pos_offset));
-
- memcpy(Buffer, info->buffer + pos_offset, copied);
- Count-= copied;
- Buffer+= copied;
+ size_t copied= MY_MIN(Count, (size_t)(length - pos_offset));
+ if (copied)
+ {
+ memcpy(Buffer, info->buffer + pos_offset, copied);
+ Count-= copied;
+ Buffer+= copied;
+ }
info->read_pos= info->buffer + pos_offset + copied;
info->read_end= info->buffer + length;
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index c13563f9263..adc0572cb1c 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -15643,6 +15643,113 @@ static void print_ror_scans_arr(TABLE *table, const char *msg,
DBUG_VOID_RETURN;
}
+static String dbug_print_sel_arg_buf;
+
+static void
+print_sel_arg_key(Field *field, const uchar *key, String *out)
+{
+ TABLE *table= field->table;
+ my_bitmap_map *old_sets[2];
+ dbug_tmp_use_all_columns(table, old_sets, table->read_set, table->write_set);
+
+ if (field->real_maybe_null())
+ {
+ if (*key)
+ {
+ out->append("NULL");
+ goto end;
+ }
+ key++; // Skip null byte
+ }
+
+ field->set_key_image(key, field->pack_length());
+
+ if (field->type() == MYSQL_TYPE_BIT)
+ (void) field->val_int_as_str(out, 1);
+ else
+ field->val_str(out);
+
+end:
+ dbug_tmp_restore_column_maps(table->read_set, table->write_set, old_sets);
+}
+
+
+/*
+ @brief
+ Produce a string representation of an individual SEL_ARG and return pointer
+ to it
+
+ @detail
+ Intended usage:
+
+ (gdb) p dbug_print_sel_arg(ptr)
+*/
+
+const char *dbug_print_sel_arg(SEL_ARG *sel_arg)
+{
+ StringBuffer<64> buf;
+ String &out= dbug_print_sel_arg_buf;
+ out.length(0);
+
+ if (!sel_arg)
+ {
+ out.append("NULL");
+ goto end;
+ }
+
+ out.append("SEL_ARG(");
+
+ const char *stype;
+ switch(sel_arg->type) {
+ case SEL_ARG::IMPOSSIBLE:
+ stype="IMPOSSIBLE";
+ break;
+ case SEL_ARG::MAYBE:
+ stype="MAYBE";
+ break;
+ case SEL_ARG::MAYBE_KEY:
+ stype="MAYBE_KEY";
+ break;
+ case SEL_ARG::KEY_RANGE:
+ default:
+ stype= NULL;
+ }
+
+ if (stype)
+ {
+ out.append("type=");
+ out.append(stype);
+ goto end;
+ }
+
+ if (sel_arg->min_flag & NO_MIN_RANGE)
+ out.append("-inf");
+ else
+ {
+ print_sel_arg_key(sel_arg->field, sel_arg->min_value, &buf);
+ out.append(buf);
+ }
+
+ out.append((sel_arg->min_flag & NEAR_MIN)? "<" : "<=");
+
+ out.append(sel_arg->field->field_name);
+
+ out.append((sel_arg->max_flag & NEAR_MAX)? "<" : "<=");
+
+ if (sel_arg->max_flag & NO_MAX_RANGE)
+ out.append("+inf");
+ else
+ {
+ print_sel_arg_key(sel_arg->field, sel_arg->max_value, &buf);
+ out.append(buf);
+ }
+
+ out.append(")");
+
+end:
+ return dbug_print_sel_arg_buf.c_ptr_safe();
+}
+
/*****************************************************************************
** Print a quick range for debugging
diff --git a/sql/opt_split.cc b/sql/opt_split.cc
index a6031f75a5b..3a086aef04c 100644
--- a/sql/opt_split.cc
+++ b/sql/opt_split.cc
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2017 MariaDB
+ Copyright (c) 2017, 2020, MariaDB
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
@@ -749,13 +749,13 @@ void JOIN::add_keyuses_for_splitting()
if (allocate_dynamic(&keyuse, save_qep->keyuse.elements + added_keyuse_count))
goto err;
- memcpy(keyuse.buffer,
- save_qep->keyuse.buffer,
- (size_t) save_qep->keyuse.elements * keyuse.size_of_element);
- keyuse.elements= save_qep->keyuse.elements;
+ idx= keyuse.elements= save_qep->keyuse.elements;
+ if (keyuse.elements)
+ memcpy(keyuse.buffer,
+ save_qep->keyuse.buffer,
+ (size_t) keyuse.elements * keyuse.size_of_element);
keyuse_ext= &ext_keyuses_for_splitting->at(0);
- idx= save_qep->keyuse.elements;
for (i=0; i < added_keyuse_count; i++, keyuse_ext++, idx++)
{
set_dynamic(&keyuse, (KEYUSE *) keyuse_ext, idx);
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 2c96e0e9ff2..ef96e8f2484 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -14536,7 +14536,7 @@ static int native_password_authenticate(MYSQL_PLUGIN_VIO *vio,
info->password_used= PASSWORD_USED_YES;
if (pkt_len == SCRAMBLE_LENGTH)
{
- if (!info->auth_string_length)
+ if (info->auth_string_length != SCRAMBLE_LENGTH)
DBUG_RETURN(CR_AUTH_USER_CREDENTIALS);
if (check_scramble(pkt, thd->scramble, (uchar*)info->auth_string))
@@ -14563,9 +14563,13 @@ static int native_password_make_scramble(const char *password,
return 0;
}
+/* As this contains is a string of not a valid SCRAMBLE_LENGTH */
+static const char invalid_password[] = "*THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE";
+
static int native_password_get_salt(const char *hash, size_t hash_length,
unsigned char *out, size_t *out_length)
{
+ DBUG_ASSERT(sizeof(invalid_password) > SCRAMBLE_LENGTH);
DBUG_ASSERT(*out_length >= SCRAMBLE_LENGTH);
if (hash_length == 0)
{
@@ -14575,6 +14579,12 @@ static int native_password_get_salt(const char *hash, size_t hash_length,
if (hash_length != SCRAMBLED_PASSWORD_CHAR_LENGTH)
{
+ if (hash_length == 7 && strcmp(hash, "invalid") == 0)
+ {
+ memcpy(out, invalid_password, SCRAMBLED_PASSWORD_CHAR_LENGTH);
+ *out_length= SCRAMBLED_PASSWORD_CHAR_LENGTH;
+ return 0;
+ }
my_error(ER_PASSWD_LENGTH, MYF(0), SCRAMBLED_PASSWORD_CHAR_LENGTH);
return 1;
}
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 6011dbbc6dd..a4fd26cf7d8 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -4982,7 +4982,8 @@ extern "C" size_t thd_query_safe(MYSQL_THD thd, char *buf, size_t buflen)
if (!mysql_mutex_trylock(&thd->LOCK_thd_data))
{
len= MY_MIN(buflen - 1, thd->query_length());
- memcpy(buf, thd->query(), len);
+ if (len)
+ memcpy(buf, thd->query(), len);
mysql_mutex_unlock(&thd->LOCK_thd_data);
}
buf[len]= '\0';
diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc
index 5a243cd0a6d..4b879293fdb 100644
--- a/sql/sql_join_cache.cc
+++ b/sql/sql_join_cache.cc
@@ -1397,7 +1397,8 @@ uint JOIN_CACHE::write_record_data(uchar * link, bool *is_full)
blob_field->get_image(cp, copy->length,
blob_field->charset());
DBUG_ASSERT(cp + copy->length + copy->blob_length <= buff + buff_size);
- memcpy(cp+copy->length, copy->str, copy->blob_length);
+ if (copy->blob_length)
+ memcpy(cp+copy->length, copy->str, copy->blob_length);
cp+= copy->length+copy->blob_length;
}
break;
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 61e3b89c9a3..60a7a4f6ce0 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -10209,7 +10209,8 @@ bool LEX::new_sp_instr_stmt(THD *thd,
qbuff.length= prefix.length + suffix.length;
if (!(qbuff.str= (char*) alloc_root(thd->mem_root, qbuff.length + 1)))
return true;
- memcpy(qbuff.str, prefix.str, prefix.length);
+ if (prefix.length)
+ memcpy(qbuff.str, prefix.str, prefix.length);
strmake(qbuff.str + prefix.length, suffix.str, suffix.length);
i->m_query= qbuff;
return sphead->add_instr(i);
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 531d639d6f4..184540b7aa9 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -1,5 +1,5 @@
/* Copyright (c) 2002, 2015, Oracle and/or its affiliates.
- Copyright (c) 2008, 2019, MariaDB
+ Copyright (c) 2008, 2020, MariaDB
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
@@ -122,7 +122,10 @@ When one supplies long data for a placeholder:
#include "sql_handler.h"
#include "transaction.h" // trans_rollback_implicit
#include "mysql/psi/mysql_ps.h" // MYSQL_EXECUTE_PS
+#ifdef WITH_WSREP
#include "wsrep_mysqld.h"
+#include "wsrep_trans_observer.h"
+#endif /* WITH_WSREP */
/* Constants defining bits in parameter type flags. Flags are read from high byte of short value */
static const uint PARAMETER_FLAG_UNSIGNED = 128U << 8;
@@ -4607,6 +4610,23 @@ reexecute:
thd->m_reprepare_observer= NULL;
+#ifdef WITH_WSREP
+ if (!(sql_command_flags[lex->sql_command] & CF_PS_ARRAY_BINDING_OPTIMIZED) &&
+ WSREP(thd))
+ {
+ if (wsrep_after_statement(thd))
+ {
+ /*
+ Re-execution success is unlikely after an error from
+ wsrep_after_statement(), so retrun error immediately.
+ */
+ thd->get_stmt_da()->reset_diagnostics_area();
+ wsrep_override_error(thd, thd->wsrep_cs().current_error(),
+ thd->wsrep_cs().current_error_status());
+ }
+ }
+ else
+#endif /* WITH_WSREP */
if (unlikely(error) &&
(sql_command_flags[lex->sql_command] & CF_REEXECUTION_FRAGILE) &&
!thd->is_fatal_error && !thd->killed &&
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 2a856a0d51f..6071fe10929 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -27984,10 +27984,10 @@ JOIN::reoptimize(Item *added_where, table_map join_tables,
if (save_to)
{
DBUG_ASSERT(!keyuse.elements);
- memcpy(keyuse.buffer,
- save_to->keyuse.buffer,
- (size_t) save_to->keyuse.elements * keyuse.size_of_element);
keyuse.elements= save_to->keyuse.elements;
+ if (size_t e= keyuse.elements)
+ memcpy(keyuse.buffer,
+ save_to->keyuse.buffer, e * keyuse.size_of_element);
}
/* Add the new access methods to the keyuse array. */
diff --git a/sql/sql_string.cc b/sql/sql_string.cc
index 94f2e6fc8c6..f2a0f55aec8 100644
--- a/sql/sql_string.cc
+++ b/sql/sql_string.cc
@@ -237,8 +237,8 @@ bool Binary_string::copy(const Binary_string &str)
{
if (alloc(str.str_length))
return TRUE;
- str_length=str.str_length;
- bmove(Ptr,str.Ptr,str_length); // May be overlapping
+ if ((str_length=str.str_length))
+ bmove(Ptr,str.Ptr,str_length); // May be overlapping
Ptr[str_length]=0;
return FALSE;
}
@@ -574,8 +574,11 @@ bool Binary_string::append_ulonglong(ulonglong val)
bool String::append(const char *s, size_t arg_length, CHARSET_INFO *cs)
{
+ if (!arg_length)
+ return false;
+
uint32 offset;
-
+
if (needs_conversion((uint32)arg_length, cs, charset(), &offset))
{
size_t add_length;
diff --git a/sql/table.h b/sql/table.h
index ec865f2e3ce..83e8b69b5e3 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -3194,7 +3194,8 @@ inline void mark_as_null_row(TABLE *table)
{
table->null_row=1;
table->status|=STATUS_NULL_ROW;
- bfill(table->null_flags,table->s->null_bytes,255);
+ if (table->s->null_bytes)
+ bfill(table->null_flags,table->s->null_bytes,255);
}
bool is_simple_order(ORDER *order);
diff --git a/sql/unireg.cc b/sql/unireg.cc
index c299549843f..ecd5bb8d430 100644
--- a/sql/unireg.cc
+++ b/sql/unireg.cc
@@ -1104,8 +1104,11 @@ static bool pack_fields(uchar **buff_arg, List<Create_field> &create_fields,
it.rewind();
while ((field=it++))
{
- memcpy(buff, field->comment.str, field->comment.length);
- buff+= field->comment.length;
+ if (size_t l= field->comment.length)
+ {
+ memcpy(buff, field->comment.str, l);
+ buff+= l;
+ }
}
}
*buff_arg= buff;
diff --git a/sql/unireg.h b/sql/unireg.h
index 873d6f681fc..dbff9ff77f8 100644
--- a/sql/unireg.h
+++ b/sql/unireg.h
@@ -76,7 +76,8 @@
#define cmp_record(A,B) memcmp((A)->record[0],(A)->B,(size_t) (A)->s->reclength)
#define empty_record(A) { \
restore_record((A),s->default_values); \
- bfill((A)->null_flags,(A)->s->null_bytes,255);\
+ if ((A)->s->null_bytes) \
+ bfill((A)->null_flags,(A)->s->null_bytes,255); \
}
/* Defines for use with openfrm, openprt and openfrd */
diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
index 7d20796b646..710a3787e09 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -1467,7 +1467,8 @@ instant_alter_column_possible(
for (const dict_index_t* index = ib_table.indexes.start;
index; index = index->indexes.next) {
if (index->has_virtual()) {
- ut_ad(ib_table.n_v_cols);
+ ut_ad(ib_table.n_v_cols
+ || index->is_corrupted());
return false;
}
}
diff --git a/storage/myisam/mi_key.c b/storage/myisam/mi_key.c
index ed72acf627e..087eb59c7c0 100644
--- a/storage/myisam/mi_key.c
+++ b/storage/myisam/mi_key.c
@@ -147,8 +147,11 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key,
set_if_smaller(length,tmp_length);
FIX_LENGTH(cs, pos, length, char_length);
store_key_length_inc(key,char_length);
- memcpy(key, pos, char_length);
- key+= char_length;
+ if (char_length)
+ {
+ memcpy(key, pos, char_length);
+ key+= char_length;
+ }
continue;
}
else if (keyseg->flag & HA_SWAP_KEY)
diff --git a/storage/perfschema/pfs_setup_object.cc b/storage/perfschema/pfs_setup_object.cc
index 9325b84997f..47afd130761 100644
--- a/storage/perfschema/pfs_setup_object.cc
+++ b/storage/perfschema/pfs_setup_object.cc
@@ -126,12 +126,18 @@ static void set_setup_object_key(PFS_setup_object_key *key,
char *ptr= &key->m_hash_key[0];
ptr[0]= (char) object_type;
ptr++;
- memcpy(ptr, schema, schema_length);
- ptr+= schema_length;
+ if (schema_length)
+ {
+ memcpy(ptr, schema, schema_length);
+ ptr+= schema_length;
+ }
ptr[0]= 0;
ptr++;
- memcpy(ptr, object, object_length);
- ptr+= object_length;
+ if (object_length)
+ {
+ memcpy(ptr, object, object_length);
+ ptr+= object_length;
+ }
ptr[0]= 0;
ptr++;
key->m_key_length= (uint)(ptr - &key->m_hash_key[0]);
diff --git a/strings/ctype-bin.c b/strings/ctype-bin.c
index 84e5c85697b..c11be2e5926 100644
--- a/strings/ctype-bin.c
+++ b/strings/ctype-bin.c
@@ -1,6 +1,6 @@
/* Copyright (c) 2002-2007 MySQL AB & tommy@valley.ne.jp
Copyright (c) 2002, 2014, Oracle and/or its affiliates.
- Copyright (c) 2009, 2014, SkySQL Ab.
+ Copyright (c) 2009, 2020, MariaDB Corporation.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -401,7 +401,7 @@ my_strnxfrm_8bit_bin(CHARSET_INFO *cs,
{
set_if_smaller(srclen, dstlen);
set_if_smaller(srclen, nweights);
- if (dst != src)
+ if (srclen && dst != src)
memcpy(dst, src, srclen);
return my_strxfrm_pad_desc_and_reverse(cs, dst, dst + srclen, dst + dstlen,
(uint)(nweights - srclen), flags, 0);
diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c
index 90773a0dabc..1a5dd6dbfde 100644
--- a/strings/ctype-tis620.c
+++ b/strings/ctype-tis620.c
@@ -555,9 +555,11 @@ int my_strnncollsp_tis620(CHARSET_INFO * cs __attribute__((unused)),
alloced= a= (uchar*) my_malloc(PSI_INSTRUMENT_ME, a_length+b_length+2, MYF(MY_FAE));
b= a + a_length+1;
- memcpy((char*) a, (char*) a0, a_length);
+ if (a_length)
+ memcpy((char*) a, (char*) a0, a_length);
a[a_length]= 0; /* if length(a0)> len1, need to put 'end of string' */
- memcpy((char *)b, (char *)b0, b_length);
+ if (b_length)
+ memcpy((char *)b, (char *)b0, b_length);
b[b_length]= 0; /* put end of string */
a_length= thai2sortable(a, a_length);
b_length= thai2sortable(b, b_length);