Bug#14236170 MYSQLDUMP 5.5.25 CLIENT FAILS TO DUMP
MYSQL DB FROM REMOTE 5.0.96 SERVER Problem: mysqldump tool assumes the existence of general_log and slow_log tables in the server. If mysqldump tool executes on a old server where there are no log tables like these, mysqldump tool fails. Analysis: general_log and slow_log tables are added in the ignore-table list as part of bug-26121 fix causes bug-45740 (MYSQLDUMP DOESN'T DUMP GENERAL_LOG AND SLOW_QUERY CAUSES RESTORE PROBLEM). As part of the bug-45740 fix, mysqldump tool adds create table queries for these two tables. But the fix assumes that on all the servers, general_log and slow_log will be there. If the new mysqldump tool is executed against a old server where there are no general_log and slow_log, the mysqldump tool fails with an error that 'there is no general_log table'. Fix: When mysqldump tool is trying to retrieve general_log and slow_log table structures, first the tool should check their existence of these tables in the server instead of trying to dump it blindly.
This commit is contained in:
parent
53f57ab221
commit
7397aa913d
@ -83,14 +83,6 @@
|
||||
#define IGNORE_DATA 0x01 /* don't dump data for this table */
|
||||
#define IGNORE_INSERT_DELAYED 0x02 /* table doesn't support INSERT DELAYED */
|
||||
|
||||
/* general_log or slow_log tables under mysql database */
|
||||
static inline my_bool general_log_or_slow_log_tables(const char *db,
|
||||
const char *table)
|
||||
{
|
||||
return (strcmp(db, "mysql") == 0) &&
|
||||
((strcmp(table, "general_log") == 0) ||
|
||||
(strcmp(table, "slow_log") == 0));
|
||||
}
|
||||
|
||||
static void add_load_option(DYNAMIC_STRING *str, const char *option,
|
||||
const char *option_value);
|
||||
@ -2410,6 +2402,15 @@ static uint dump_routines_for_db(char *db)
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
/* general_log or slow_log tables under mysql database */
|
||||
static inline my_bool general_log_or_slow_log_tables(const char *db,
|
||||
const char *table)
|
||||
{
|
||||
return (!my_strcasecmp(charset_info, db, "mysql")) &&
|
||||
(!my_strcasecmp(charset_info, table, "general_log") ||
|
||||
!my_strcasecmp(charset_info, table, "slow_log"));
|
||||
}
|
||||
|
||||
/*
|
||||
get_table_structure -- retrievs database structure, prints out corresponding
|
||||
CREATE statement and fills out insert_pat if the table is the type we will
|
||||
@ -4285,7 +4286,8 @@ 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;
|
||||
int using_mysql_db= my_strcasecmp(&my_charset_latin1, database, "mysql");
|
||||
my_bool general_log_table_exists= 0, slow_log_table_exists=0;
|
||||
int using_mysql_db= !my_strcasecmp(charset_info, database, "mysql");
|
||||
DBUG_ENTER("dump_all_tables_in_db");
|
||||
|
||||
afterdot= strmov(hash_key, database);
|
||||
@ -4296,22 +4298,6 @@ static int dump_all_tables_in_db(char *database)
|
||||
if (opt_xml)
|
||||
print_xml_tag(md_result_file, "", "\n", "database", "name=", database, NullS);
|
||||
|
||||
if (strcmp(database, "mysql") == 0)
|
||||
{
|
||||
char table_type[NAME_LEN];
|
||||
char ignore_flag;
|
||||
uint num_fields;
|
||||
num_fields= get_table_structure((char *) "general_log",
|
||||
database, table_type, &ignore_flag);
|
||||
if (num_fields == 0)
|
||||
verbose_msg("-- Warning: get_table_structure() failed with some internal "
|
||||
"error for 'general_log' table\n");
|
||||
num_fields= get_table_structure((char *) "slow_log",
|
||||
database, table_type, &ignore_flag);
|
||||
if (num_fields == 0)
|
||||
verbose_msg("-- Warning: get_table_structure() failed with some internal "
|
||||
"error for 'slow_log' table\n");
|
||||
}
|
||||
if (lock_tables)
|
||||
{
|
||||
DYNAMIC_STRING query;
|
||||
@ -4357,6 +4343,26 @@ static int dump_all_tables_in_db(char *database)
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
If general_log and slow_log 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
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (opt_events && mysql_get_server_version(mysql) >= 50106)
|
||||
{
|
||||
@ -4375,7 +4381,26 @@ static int dump_all_tables_in_db(char *database)
|
||||
}
|
||||
if (lock_tables)
|
||||
(void) mysql_query_with_error_report(mysql, 0, "UNLOCK TABLES");
|
||||
if (flush_privileges && using_mysql_db == 0)
|
||||
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 (flush_privileges && using_mysql_db)
|
||||
{
|
||||
fprintf(md_result_file,"\n--\n-- Flush Grant Tables \n--\n");
|
||||
fprintf(md_result_file,"\n/*! FLUSH PRIVILEGES */;\n");
|
||||
|
Loading…
x
Reference in New Issue
Block a user