Commit c9839cb0 authored by Daniel Black's avatar Daniel Black Committed by Sergey Vojtovich

MDEV-13336: mysqldump --ignore-database address review comments

parent 784e9391
......@@ -212,9 +212,9 @@ TYPELIB compatible_mode_typelib= {array_elements(compatible_mode_names) - 1,
#define MED_ENGINES "MRG_MyISAM, MRG_ISAM, CONNECT, OQGRAPH, SPIDER, VP, FEDERATED"
HASH ignore_table;
static HASH ignore_table;
HASH ignore_database;
static HASH ignore_database;
static struct my_option my_long_options[] =
{
......@@ -908,7 +908,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
opt_databases=0;
break;
case (int) OPT_IGNORE_DATABASE:
if (my_hash_insert(&ignore_database, (uchar*)my_strdup(argument, MYF(0))))
if (my_hash_insert(&ignore_database, (uchar*) my_strdup(argument, MYF(0))))
exit(EX_EOM);
break;
case (int) OPT_IGNORE_TABLE:
......@@ -1070,9 +1070,10 @@ static int get_options(int *argc, char ***argv)
my_progname_short);
return(EX_USAGE);
}
if (ignore_database.records && !opt_alldbs) {
if (ignore_database.records && !opt_alldbs)
{
fprintf(stderr,
"%s: --ignore-database can only be used toghether with --all-databases.\n",
"%s: --ignore-database can only be used together with --all-databases.\n",
my_progname_short);
return(EX_USAGE);
}
......@@ -4236,6 +4237,7 @@ static int dump_tablespaces_for_tables(char *db, char **table_names, int tables)
return r;
}
static int dump_tablespaces_for_databases(char** databases)
{
int r;
......@@ -4265,6 +4267,7 @@ static int dump_tablespaces_for_databases(char** databases)
return r;
}
static int dump_tablespaces(char* ts_where)
{
MYSQL_ROW row;
......@@ -4451,11 +4454,11 @@ static int dump_tablespaces(char* ts_where)
DBUG_RETURN(0);
}
/* Return 1 if we should copy the database */
my_bool include_database(const uchar *hash_key, size_t len)
/* Return 1 if we should copy the database */
static my_bool include_database(const char *hash_key)
{
return ! my_hash_search(&ignore_database, hash_key, len);
return !my_hash_search(&ignore_database, (uchar*) hash_key, strlen(hash_key));
}
......@@ -4477,7 +4480,7 @@ static int dump_all_databases()
!my_strcasecmp(&my_charset_latin1, row[0], PERFORMANCE_SCHEMA_DB_NAME))
continue;
if (include_database(row[0], strlen(row[0])))
if (include_database(row[0]))
if (dump_all_tables_in_db(row[0]))
result=1;
}
......@@ -4501,7 +4504,7 @@ static int dump_all_databases()
!my_strcasecmp(&my_charset_latin1, row[0], PERFORMANCE_SCHEMA_DB_NAME))
continue;
if (include_database(row[0], strlen(row[0])))
if (include_database(row[0]))
if (dump_all_views_in_db(row[0]))
result=1;
}
......@@ -6087,8 +6090,6 @@ int main(int argc, char **argv)
sf_leaking_memory=1; /* don't report memory leaks on early exits */
compatible_mode_normal_str[0]= 0;
default_charset= (char *)mysql_universal_client_charset;
bzero((char*) &ignore_database, sizeof(ignore_database));
bzero((char*) &ignore_table, sizeof(ignore_table));
exit_code= get_options(&argc, &argv);
if (exit_code)
......
......@@ -4478,6 +4478,14 @@ TRUNCATE mysql.event;
SHOW EVENTS;
Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
#
# MDEV-13336: add ignore-database option
# with --all-databases
#
DROP DATABASE test;
SHOW DATABASES LIKE 'test';
Database (test)
CREATE DATABASE test;
#
# Bug#31113 mysqldump 5.1 can't handle a dash ("-") in database names
#
create database `test-database`;
......
......@@ -1926,6 +1926,15 @@ TRUNCATE mysql.event;
SHOW EVENTS;
--remove_file $MYSQLTEST_VARDIR/tmp/bug29938.sql
--echo #
--echo # MDEV-13336: add ignore-database option
--echo # with --all-databases
--echo #
--exec $MYSQL_DUMP --ignore-database test --all-databases > $MYSQLTEST_VARDIR/tmp/mysqldump-MDEV-13336.sql
DROP DATABASE test;
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/mysqldump-MDEV-13336.sql
SHOW DATABASES LIKE 'test';
CREATE DATABASE test;
--echo #
--echo # Bug#31113 mysqldump 5.1 can't handle a dash ("-") in database names
......
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