Commit 221ced92 authored by Daniel Black's avatar Daniel Black

MDEV-4875 Can't restore a mysqldump if --add-drop-database meets general_log

or slow query log when the log_output=TABLE.

When this happens, we temporary disable by changing log_output until
we've created the general_log and slow_log tables again.

Move </database> in xml mode until after the transaction_registry.

General_log and slow_log tables where moved to be first to be dumped so
that the disabling of the general/slow queries is minimal.
parent 9fe3bc2a
......@@ -5229,6 +5229,55 @@ int init_dumping_views(char *qdatabase __attribute__((unused)))
} /* init_dumping_views */
/*
mysql specific database initialization.
SYNOPSIS
init_dumping_mysql_tables
protections around dumping general/slow query log
qdatabase quoted name of the "mysql" database
RETURN VALUES
0 Success.
1 Failure.
*/
static int init_dumping_mysql_tables(char *qdatabase)
{
DBUG_ENTER("init_dumping_mysql_tables");
if (opt_drop_database)
fprintf(md_result_file,
"\n/*!50106 SET @save_log_output=@@LOG_OUTPUT*/;\n"
"/*M!100203 EXECUTE IMMEDIATE IF(@@LOG_OUTPUT='TABLE' AND (@@SLOW_QUERY_LOG=1 OR @@GENERAL_LOG=1),"
"\"SET GLOBAL LOG_OUTPUT='NONE'\", \"DO 0\") */;\n");
DBUG_RETURN(init_dumping_tables(qdatabase));
}
static void dump_first_mysql_tables(char *database)
{
char table_type[NAME_LEN];
char ignore_flag;
DBUG_ENTER("dump_first_mysql_tables");
if (!get_table_structure((char *) "general_log",
database, table_type, &ignore_flag) )
verbose_msg("-- Warning: get_table_structure() failed with some internal "
"error for 'general_log' table\n");
if (!get_table_structure((char *) "slow_log",
database, table_type, &ignore_flag) )
verbose_msg("-- Warning: get_table_structure() failed with some internal "
"error for 'slow_log' table\n");
/* general and slow query logs exist now */
if (opt_drop_database)
fprintf(md_result_file,
"\n/*!50106 SET GLOBAL LOG_OUTPUT=@save_log_output*/;\n\n");
DBUG_VOID_RETURN;
}
/*
Table Specific database initialization.
......@@ -5335,7 +5384,6 @@ static int dump_all_tables_in_db(char *database)
char table_buff[NAME_LEN*2+3];
char hash_key[2*NAME_LEN+2]; /* "db.tablename" */
char *afterdot;
my_bool general_log_table_exists= 0, slow_log_table_exists=0;
my_bool transaction_registry_table_exists= 0;
int using_mysql_db= !my_strcasecmp(charset_info, database, "mysql");
DBUG_ENTER("dump_all_tables_in_db");
......@@ -5343,11 +5391,15 @@ static int dump_all_tables_in_db(char *database)
afterdot= strmov(hash_key, database);
*afterdot++= '.';
if (init_dumping(database, init_dumping_tables))
if (init_dumping(database, using_mysql_db ? init_dumping_mysql_tables
: init_dumping_tables))
DBUG_RETURN(1);
if (opt_xml)
print_xml_tag(md_result_file, "", "\n", "database", "name=", database, NullS);
if (using_mysql_db)
dump_first_mysql_tables(database);
if (lock_tables)
{
DYNAMIC_STRING query;
......@@ -5436,26 +5488,18 @@ static int dump_all_tables_in_db(char *database)
else
{
/*
If general_log and slow_log exists in the 'mysql' database,
If transaction_registry exists in the 'mysql' database,
we should dump the table structure. But we cannot
call get_table_structure() here as 'LOCK TABLES' query got executed
above on the session and that 'LOCK TABLES' query does not contain
'general_log' and 'slow_log' tables. (you cannot acquire lock
on log tables). Hence mark the existence of these log tables here and
'transaction_registry'. Hence mark the existence of the table here and
after 'UNLOCK TABLES' query is executed on the session, get the table
structure from server and dump it in the file.
*/
if (using_mysql_db)
{
if (!my_strcasecmp(charset_info, table, "general_log"))
general_log_table_exists= 1;
else if (!my_strcasecmp(charset_info, table, "slow_log"))
slow_log_table_exists= 1;
else if (!my_strcasecmp(charset_info, table, "transaction_registry"))
if (using_mysql_db && !my_strcasecmp(charset_info, table, "transaction_registry"))
transaction_registry_table_exists= 1;
}
}
}
if (opt_single_transaction && mysql_get_server_version(mysql) >= 50500)
{
......@@ -5474,39 +5518,25 @@ static int dump_all_tables_in_db(char *database)
DBUG_PRINT("info", ("Dumping routines for database %s", database));
dump_routines_for_db(database);
}
if (opt_xml)
{
fputs("</database>\n", md_result_file);
check_io(md_result_file);
}
if (lock_tables)
(void) mysql_query_with_error_report(mysql, 0, "UNLOCK TABLES");
if (using_mysql_db)
{
char table_type[NAME_LEN];
char ignore_flag;
if (general_log_table_exists)
{
if (!get_table_structure((char *) "general_log",
database, table_type, &ignore_flag) )
verbose_msg("-- Warning: get_table_structure() failed with some internal "
"error for 'general_log' table\n");
}
if (slow_log_table_exists)
{
if (!get_table_structure((char *) "slow_log",
database, table_type, &ignore_flag) )
verbose_msg("-- Warning: get_table_structure() failed with some internal "
"error for 'slow_log' table\n");
}
if (transaction_registry_table_exists)
{
char table_type[NAME_LEN];
char ignore_flag;
if (!get_table_structure((char *) "transaction_registry",
database, table_type, &ignore_flag) )
verbose_msg("-- Warning: get_table_structure() failed with some internal "
"error for 'transaction_registry' table\n");
}
}
if (opt_xml)
{
fputs("</database>\n", md_result_file);
check_io(md_result_file);
}
if (flush_privileges && using_mysql_db)
{
fprintf(md_result_file,"\n--\n-- Flush Grant Tables \n--\n");
......
......@@ -5738,34 +5738,6 @@ DROP TABLE t1;
/*!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 */;
DROP TABLE IF EXISTS `innodb_index_stats`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `innodb_index_stats` (
`database_name` varchar(64) COLLATE utf8_bin NOT NULL,
`table_name` varchar(199) COLLATE utf8_bin NOT NULL,
`index_name` varchar(64) COLLATE utf8_bin NOT NULL,
`last_update` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
`stat_name` varchar(64) COLLATE utf8_bin NOT NULL,
`stat_value` bigint(20) unsigned NOT NULL,
`sample_size` bigint(20) unsigned DEFAULT NULL,
`stat_description` varchar(1024) COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`database_name`,`table_name`,`index_name`,`stat_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin STATS_PERSISTENT=0;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `innodb_table_stats`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `innodb_table_stats` (
`database_name` varchar(64) COLLATE utf8_bin NOT NULL,
`table_name` varchar(199) COLLATE utf8_bin NOT NULL,
`last_update` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
`n_rows` bigint(20) unsigned NOT NULL,
`clustered_index_size` bigint(20) unsigned NOT NULL,
`sum_of_other_index_sizes` bigint(20) unsigned NOT NULL,
PRIMARY KEY (`database_name`,`table_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin STATS_PERSISTENT=0;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE IF NOT EXISTS `general_log` (
......@@ -5795,6 +5767,34 @@ CREATE TABLE IF NOT EXISTS `slow_log` (
`rows_affected` int(11) NOT NULL
) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log';
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `innodb_index_stats`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `innodb_index_stats` (
`database_name` varchar(64) COLLATE utf8_bin NOT NULL,
`table_name` varchar(199) COLLATE utf8_bin NOT NULL,
`index_name` varchar(64) COLLATE utf8_bin NOT NULL,
`last_update` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
`stat_name` varchar(64) COLLATE utf8_bin NOT NULL,
`stat_value` bigint(20) unsigned NOT NULL,
`sample_size` bigint(20) unsigned DEFAULT NULL,
`stat_description` varchar(1024) COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`database_name`,`table_name`,`index_name`,`stat_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin STATS_PERSISTENT=0;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `innodb_table_stats`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `innodb_table_stats` (
`database_name` varchar(64) COLLATE utf8_bin NOT NULL,
`table_name` varchar(199) COLLATE utf8_bin NOT NULL,
`last_update` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
`n_rows` bigint(20) unsigned NOT NULL,
`clustered_index_size` bigint(20) unsigned NOT NULL,
`sum_of_other_index_sizes` bigint(20) unsigned NOT NULL,
PRIMARY KEY (`database_name`,`table_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin STATS_PERSISTENT=0;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE IF NOT EXISTS `transaction_registry` (
......@@ -5833,6 +5833,35 @@ CREATE TABLE IF NOT EXISTS `transaction_registry` (
/*!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 */;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE IF NOT EXISTS `general_log` (
`event_time` timestamp(6) NOT NULL DEFAULT current_timestamp(6) ON UPDATE current_timestamp(6),
`user_host` mediumtext NOT NULL,
`thread_id` bigint(21) unsigned NOT NULL,
`server_id` int(10) unsigned NOT NULL,
`command_type` varchar(64) NOT NULL,
`argument` mediumtext NOT NULL
) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='General log';
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE IF NOT EXISTS `slow_log` (
`start_time` timestamp(6) NOT NULL DEFAULT current_timestamp(6) ON UPDATE current_timestamp(6),
`user_host` mediumtext NOT NULL,
`query_time` time(6) NOT NULL,
`lock_time` time(6) NOT NULL,
`rows_sent` int(11) NOT NULL,
`rows_examined` int(11) NOT NULL,
`db` varchar(512) NOT NULL,
`last_insert_id` int(11) NOT NULL,
`insert_id` int(11) NOT NULL,
`server_id` int(10) unsigned NOT NULL,
`sql_text` mediumtext NOT NULL,
`thread_id` bigint(21) unsigned NOT NULL,
`rows_affected` int(11) NOT NULL
) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log';
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `innodb_index_stats`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
......@@ -5873,35 +5902,6 @@ LOCK TABLES `innodb_table_stats` WRITE;
UNLOCK TABLES;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE IF NOT EXISTS `general_log` (
`event_time` timestamp(6) NOT NULL DEFAULT current_timestamp(6) ON UPDATE current_timestamp(6),
`user_host` mediumtext NOT NULL,
`thread_id` bigint(21) unsigned NOT NULL,
`server_id` int(10) unsigned NOT NULL,
`command_type` varchar(64) NOT NULL,
`argument` mediumtext NOT NULL
) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='General log';
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE IF NOT EXISTS `slow_log` (
`start_time` timestamp(6) NOT NULL DEFAULT current_timestamp(6) ON UPDATE current_timestamp(6),
`user_host` mediumtext NOT NULL,
`query_time` time(6) NOT NULL,
`lock_time` time(6) NOT NULL,
`rows_sent` int(11) NOT NULL,
`rows_examined` int(11) NOT NULL,
`db` varchar(512) NOT NULL,
`last_insert_id` int(11) NOT NULL,
`insert_id` int(11) NOT NULL,
`server_id` int(10) unsigned NOT NULL,
`sql_text` mediumtext NOT NULL,
`thread_id` bigint(21) unsigned NOT NULL,
`rows_affected` int(11) NOT NULL
) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log';
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE IF NOT EXISTS `transaction_registry` (
`transaction_id` bigint(20) unsigned NOT NULL,
`commit_id` bigint(20) unsigned NOT NULL,
......@@ -5938,6 +5938,35 @@ CREATE TABLE IF NOT EXISTS `transaction_registry` (
/*!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 */;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE IF NOT EXISTS `general_log` (
`event_time` timestamp(6) NOT NULL DEFAULT current_timestamp(6) ON UPDATE current_timestamp(6),
`user_host` mediumtext NOT NULL,
`thread_id` bigint(21) unsigned NOT NULL,
`server_id` int(10) unsigned NOT NULL,
`command_type` varchar(64) NOT NULL,
`argument` mediumtext NOT NULL
) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='General log';
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE IF NOT EXISTS `slow_log` (
`start_time` timestamp(6) NOT NULL DEFAULT current_timestamp(6) ON UPDATE current_timestamp(6),
`user_host` mediumtext NOT NULL,
`query_time` time(6) NOT NULL,
`lock_time` time(6) NOT NULL,
`rows_sent` int(11) NOT NULL,
`rows_examined` int(11) NOT NULL,
`db` varchar(512) NOT NULL,
`last_insert_id` int(11) NOT NULL,
`insert_id` int(11) NOT NULL,
`server_id` int(10) unsigned NOT NULL,
`sql_text` mediumtext NOT NULL,
`thread_id` bigint(21) unsigned NOT NULL,
`rows_affected` int(11) NOT NULL
) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log';
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `innodb_index_stats`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
......@@ -5978,35 +6007,6 @@ LOCK TABLES `innodb_table_stats` WRITE;
UNLOCK TABLES;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE IF NOT EXISTS `general_log` (
`event_time` timestamp(6) NOT NULL DEFAULT current_timestamp(6) ON UPDATE current_timestamp(6),
`user_host` mediumtext NOT NULL,
`thread_id` bigint(21) unsigned NOT NULL,
`server_id` int(10) unsigned NOT NULL,
`command_type` varchar(64) NOT NULL,
`argument` mediumtext NOT NULL
) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='General log';
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE IF NOT EXISTS `slow_log` (
`start_time` timestamp(6) NOT NULL DEFAULT current_timestamp(6) ON UPDATE current_timestamp(6),
`user_host` mediumtext NOT NULL,
`query_time` time(6) NOT NULL,
`lock_time` time(6) NOT NULL,
`rows_sent` int(11) NOT NULL,
`rows_examined` int(11) NOT NULL,
`db` varchar(512) NOT NULL,
`last_insert_id` int(11) NOT NULL,
`insert_id` int(11) NOT NULL,
`server_id` int(10) unsigned NOT NULL,
`sql_text` mediumtext NOT NULL,
`thread_id` bigint(21) unsigned NOT NULL,
`rows_affected` int(11) NOT NULL
) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log';
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE IF NOT EXISTS `transaction_registry` (
`transaction_id` bigint(20) unsigned NOT NULL,
`commit_id` bigint(20) unsigned NOT NULL,
......@@ -6350,4 +6350,98 @@ END utf8 utf8_general_ci latin1_swedish_ci
DROP DATABASE test1;
DROP DATABASE test2;
SET sql_mode=@save_sql_mode;
#
# MDEV-4875 Can't restore a mysqldump if --add-drop-database meets general_log
#
CREATE DATABASE test1;
# Dump mysql database
DROP VIEW IF EXISTS mysql.user;
DROP TABLE IF EXISTS mysql.global_priv;
DROP TABLE IF EXISTS mysql.user;
DROP TABLE IF EXISTS mysql.time_zone_transition_type;
DROP TABLE IF EXISTS mysql.time_zone_transition;
DROP TABLE IF EXISTS mysql.time_zone_name;
DROP TABLE IF EXISTS mysql.time_zone_leap_second;
DROP TABLE IF EXISTS mysql.time_zone;
DROP TABLE IF EXISTS mysql.tables_priv;
DROP TABLE IF EXISTS mysql.table_stats;
DROP TABLE IF EXISTS mysql.servers;
DROP TABLE IF EXISTS mysql.roles_mapping;
DROP TABLE IF EXISTS mysql.proxies_priv;
DROP TABLE IF EXISTS mysql.procs_priv;
DROP TABLE IF EXISTS mysql.proc;
DROP TABLE IF EXISTS mysql.plugin;
DROP TABLE IF EXISTS mysql.innodb_table_stats;
DROP TABLE IF EXISTS mysql.innodb_index_stats;
DROP TABLE IF EXISTS mysql.index_stats;
DROP TABLE IF EXISTS mysql.host;
DROP TABLE IF EXISTS mysql.help_topic;
DROP TABLE IF EXISTS mysql.help_relation;
DROP TABLE IF EXISTS mysql.help_keyword;
DROP TABLE IF EXISTS mysql.help_category;
DROP TABLE IF EXISTS mysql.gtid_slave_pos;
DROP TABLE IF EXISTS mysql.func;
DROP TABLE IF EXISTS mysql.event;
DROP TABLE IF EXISTS mysql.db;
DROP TABLE IF EXISTS mysql.columns_priv;
DROP TABLE IF EXISTS mysql.column_stats;
# Abbreviated contents
<?xml version="1.0"?>
<mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<database name="mysql">
<table_structure name="general_log">
<field Field="event_time" Type="timestamp(6)" Null="NO" Key="" Default="current_timestamp(6)" Extra="on update current_timestamp(6)" Comment="" />
<field Field="user_host" Type="mediumtext" Null="NO" Key="" Extra="" Comment="" />
<field Field="thread_id" Type="bigint(21) unsigned" Null="NO" Key="" Extra="" Comment="" />
<field Field="server_id" Type="int(10) unsigned" Null="NO" Key="" Extra="" Comment="" />
<field Field="command_type" Type="varchar(64)" Null="NO" Key="" Extra="" Comment="" />
<field Field="argument" Type="mediumtext" Null="NO" Key="" Extra="" Comment="" />
<options Name="general_log" Engine="CSV" Version="10" Row_format="Dynamic" Rows="2" Avg_row_length="0" Data_length="0" Max_data_length="0" Index_length="0" Data_free="0" Collation="utf8_general_ci" Create_options="" Comment="General log" Max_index_length="0" Temporary="N" />
</table_structure>
<table_structure name="slow_log">
<field Field="start_time" Type="timestamp(6)" Null="NO" Key="" Default="current_timestamp(6)" Extra="on update current_timestamp(6)" Comment="" />
<field Field="user_host" Type="mediumtext" Null="NO" Key="" Extra="" Comment="" />
<field Field="query_time" Type="time(6)" Null="NO" Key="" Extra="" Comment="" />
<field Field="lock_time" Type="time(6)" Null="NO" Key="" Extra="" Comment="" />
<field Field="rows_sent" Type="int(11)" Null="NO" Key="" Extra="" Comment="" />
<field Field="rows_examined" Type="int(11)" Null="NO" Key="" Extra="" Comment="" />
<field Field="db" Type="varchar(512)" Null="NO" Key="" Extra="" Comment="" />
<field Field="last_insert_id" Type="int(11)" Null="NO" Key="" Extra="" Comment="" />
<field Field="insert_id" Type="int(11)" Null="NO" Key="" Extra="" Comment="" />
<field Field="server_id" Type="int(10) unsigned" Null="NO" Key="" Extra="" Comment="" />
<field Field="sql_text" Type="mediumtext" Null="NO" Key="" Extra="" Comment="" />
<field Field="thread_id" Type="bigint(21) unsigned" Null="NO" Key="" Extra="" Comment="" />
<field Field="rows_affected" Type="int(11)" Null="NO" Key="" Extra="" Comment="" />
<options Name="slow_log" Engine="CSV" Version="10" Row_format="Dynamic" Rows="2" Avg_row_length="0" Data_length="0" Max_data_length="0" Index_length="0" Data_free="0" Collation="utf8_general_ci" Create_options="" Comment="Slow log" Max_index_length="0" Temporary="N" />
</table_structure>
/*!50106 SET GLOBAL LOG_OUTPUT=@save_log_output*/;
<table_structure name="transaction_registry">
<field Field="transaction_id" Type="bigint(20) unsigned" Null="NO" Key="PRI" Extra="" Comment="" />
<field Field="commit_id" Type="bigint(20) unsigned" Null="NO" Key="UNI" Extra="" Comment="" />
<field Field="begin_timestamp" Type="timestamp(6)" Null="NO" Key="MUL" Default="'0000-00-00 00:00:00.000000'" Extra="" Comment="" />
<field Field="commit_timestamp" Type="timestamp(6)" Null="NO" Key="MUL" Default="'0000-00-00 00:00:00.000000'" Extra="" Comment="" />
<field Field="isolation_level" Type="enum('READ-UNCOMMITTED','READ-COMMITTED','REPEATABLE-READ','SERIALIZABLE')" Null="NO" Key="" Extra="" Comment="" />
<key Table="transaction_registry" Non_unique="0" Key_name="PRIMARY" Seq_in_index="1" Column_name="transaction_id" Collation="A" Cardinality="0" Null="" Index_type="BTREE" Comment="" Index_comment="" />
<key Table="transaction_registry" Non_unique="0" Key_name="commit_id" Seq_in_index="1" Column_name="commit_id" Collation="A" Cardinality="0" Null="" Index_type="BTREE" Comment="" Index_comment="" />
<key Table="transaction_registry" Non_unique="1" Key_name="begin_timestamp" Seq_in_index="1" Column_name="begin_timestamp" Collation="A" Cardinality="0" Null="" Index_type="BTREE" Comment="" Index_comment="" />
<key Table="transaction_registry" Non_unique="1" Key_name="commit_timestamp" Seq_in_index="1" Column_name="commit_timestamp" Collation="A" Cardinality="0" Null="" Index_type="BTREE" Comment="" Index_comment="" />
<key Table="transaction_registry" Non_unique="1" Key_name="commit_timestamp" Seq_in_index="2" Column_name="transaction_id" Collation="A" Cardinality="0" Null="" Index_type="BTREE" Comment="" Index_comment="" />
<options Name="transaction_registry" Engine="InnoDB" Version="10" Row_format="Dynamic" Rows="0" Avg_row_length="0" Data_length="16384" Max_data_length="0" Index_length="49152" Data_free="0" Create_time="TIMESTAMP" Collation="utf8_bin" Create_options="stats_persistent=0" Comment="" Max_index_length="0" Temporary="N" />
</table_structure>
</database>
<database name="test1">
</database>
</mysqldump>
SET @save_general_log=@@GENERAL_LOG;
SET GLOBAL LOG_OUTPUT='TABLE', GLOBAL GENERAL_LOG=1;
# Restore mysql database while general log is active
# No failure at this stage is the object of the test
SELECT @@GLOBAL.LOG_OUTPUT, @@GLOBAL.GENERAL_LOG;
@@GLOBAL.LOG_OUTPUT @@GLOBAL.GENERAL_LOG
TABLE 1
SET GLOBAL LOG_OUTPUT=DEFAULT, GLOBAL GENERAL_LOG=@save_general_log;
TRUNCATE TABLE mysql.general_log;
DROP DATABASE test1;
# End of 10.3 tests
......@@ -2916,4 +2916,64 @@ DROP DATABASE test2;
SET sql_mode=@save_sql_mode;
--remove_file $MYSQLTEST_VARDIR/tmp/dumptest1.sql
--echo #
--echo # MDEV-4875 Can't restore a mysqldump if --add-drop-database meets general_log
--echo #
CREATE DATABASE test1;
--echo # Dump mysql database
--exec $MYSQL_DUMP --add-drop-database --databases mysql test1 > $MYSQLTEST_VARDIR/tmp/dumptest1.sql
--disable_warnings
DROP VIEW IF EXISTS mysql.user;
DROP TABLE IF EXISTS mysql.global_priv;
DROP TABLE IF EXISTS mysql.user;
--enable_warnings
#DROP TABLE IF EXISTS mysql.transaction_registry;
#DROP TABLE IF EXISTS mysql.slow_log;
#DROP TABLE IF EXISTS mysql.general_log;
DROP TABLE IF EXISTS mysql.time_zone_transition_type;
DROP TABLE IF EXISTS mysql.time_zone_transition;
DROP TABLE IF EXISTS mysql.time_zone_name;
DROP TABLE IF EXISTS mysql.time_zone_leap_second;
DROP TABLE IF EXISTS mysql.time_zone;
DROP TABLE IF EXISTS mysql.tables_priv;
DROP TABLE IF EXISTS mysql.table_stats;
DROP TABLE IF EXISTS mysql.servers;
DROP TABLE IF EXISTS mysql.roles_mapping;
DROP TABLE IF EXISTS mysql.proxies_priv;
DROP TABLE IF EXISTS mysql.procs_priv;
DROP TABLE IF EXISTS mysql.proc;
DROP TABLE IF EXISTS mysql.plugin;
DROP TABLE IF EXISTS mysql.innodb_table_stats;
DROP TABLE IF EXISTS mysql.innodb_index_stats;
DROP TABLE IF EXISTS mysql.index_stats;
DROP TABLE IF EXISTS mysql.host;
DROP TABLE IF EXISTS mysql.help_topic;
DROP TABLE IF EXISTS mysql.help_relation;
DROP TABLE IF EXISTS mysql.help_keyword;
DROP TABLE IF EXISTS mysql.help_category;
DROP TABLE IF EXISTS mysql.gtid_slave_pos;
DROP TABLE IF EXISTS mysql.func;
DROP TABLE IF EXISTS mysql.event;
DROP TABLE IF EXISTS mysql.db;
DROP TABLE IF EXISTS mysql.columns_priv;
DROP TABLE IF EXISTS mysql.column_stats;
--echo # Abbreviated contents
--replace_regex /Create_time="[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}"/Create_time="TIMESTAMP"/
--exec $MYSQL_DUMP --xml --skip-comments --no-data --add-drop-database --databases mysql test1
SET @save_general_log=@@GENERAL_LOG;
SET GLOBAL LOG_OUTPUT='TABLE', GLOBAL GENERAL_LOG=1;
--echo # Restore mysql database while general log is active
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/dumptest1.sql
--echo # No failure at this stage is the object of the test
SELECT @@GLOBAL.LOG_OUTPUT, @@GLOBAL.GENERAL_LOG;
SET GLOBAL LOG_OUTPUT=DEFAULT, GLOBAL GENERAL_LOG=@save_general_log;
TRUNCATE TABLE mysql.general_log;
DROP DATABASE test1;
--remove_file $MYSQLTEST_VARDIR/tmp/dumptest1.sql
--echo # End of 10.3 tests
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment