Bug#26121 mysqldump includes LOCK TABLES general_log WRITE

- Giving the directive '--all-databases' to mysqldump caused 
  an attempt to lock and dump log tables which don't support this
  operation.
- With this patch the log tables are excluded from the set of
  databases tables to dump.
parent 6ca1e16e
...@@ -818,11 +818,15 @@ static int get_options(int *argc, char ***argv) ...@@ -818,11 +818,15 @@ static int get_options(int *argc, char ***argv)
(hash_get_key) get_table_key, (hash_get_key) get_table_key,
(hash_free_key) free_table_ent, 0)) (hash_free_key) free_table_ent, 0))
return(EX_EOM); return(EX_EOM);
/* Don't copy cluster internal log tables */ /* Don't copy internal log tables */
if (my_hash_insert(&ignore_table, if (my_hash_insert(&ignore_table,
(byte*) my_strdup("mysql.apply_status", MYF(MY_WME))) || (byte*) my_strdup("mysql.apply_status", MYF(MY_WME))) ||
my_hash_insert(&ignore_table, my_hash_insert(&ignore_table,
(byte*) my_strdup("mysql.schema", MYF(MY_WME)))) (byte*) my_strdup("mysql.schema", MYF(MY_WME))) ||
my_hash_insert(&ignore_table,
(byte*) my_strdup("mysql.general_log", MYF(MY_WME))) ||
my_hash_insert(&ignore_table,
(byte*) my_strdup("mysql.slow_log", MYF(MY_WME))))
return(EX_EOM); return(EX_EOM);
if ((ho_error= handle_options(argc, argv, my_long_options, get_one_option))) if ((ho_error= handle_options(argc, argv, my_long_options, get_one_option)))
...@@ -3291,8 +3295,12 @@ static int dump_all_tables_in_db(char *database) ...@@ -3291,8 +3295,12 @@ static int dump_all_tables_in_db(char *database)
init_dynamic_string(&query, "LOCK TABLES ", 256, 1024); init_dynamic_string(&query, "LOCK TABLES ", 256, 1024);
for (numrows= 0 ; (table= getTableName(1)) ; numrows++) for (numrows= 0 ; (table= getTableName(1)) ; numrows++)
{ {
dynstr_append(&query, quote_name(table, table_buff, 1)); char *end= strmov(afterdot, table);
dynstr_append(&query, " READ /*!32311 LOCAL */,"); if (include_table(hash_key,end - hash_key))
{
dynstr_append(&query, quote_name(table, table_buff, 1));
dynstr_append(&query, " READ /*!32311 LOCAL */,");
}
} }
if (numrows && mysql_real_query(mysql, query.str, query.length-1)) if (numrows && mysql_real_query(mysql, query.str, query.length-1))
DB_error(mysql, "when using LOCK TABLES"); DB_error(mysql, "when using LOCK TABLES");
......
...@@ -1546,6 +1546,13 @@ drop view v1; ...@@ -1546,6 +1546,13 @@ drop view v1;
drop table t1; drop table t1;
drop database mysqldump_test_db; drop database mysqldump_test_db;
#
# BUG#26121 mysqldump includes LOCK TABLES general_log WRITE
#
--exec $MYSQL_DUMP --all-databases > $MYSQLTEST_VARDIR/tmp/bug26121.sql
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug26121.sql
--remove_file $MYSQLTEST_VARDIR/tmp/bug26121.sql
--echo # --echo #
--echo # End of 5.1 tests --echo # End of 5.1 tests
--echo # --echo #
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