mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 02:05:57 +01:00
MDEV-13336: mysqldump --ignore-database address review comments
This commit is contained in:
parent
784e9391c9
commit
c9839cb0b3
3 changed files with 30 additions and 12 deletions
|
@ -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"
|
#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[] =
|
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;
|
opt_databases=0;
|
||||||
break;
|
break;
|
||||||
case (int) OPT_IGNORE_DATABASE:
|
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);
|
exit(EX_EOM);
|
||||||
break;
|
break;
|
||||||
case (int) OPT_IGNORE_TABLE:
|
case (int) OPT_IGNORE_TABLE:
|
||||||
|
@ -1070,9 +1070,10 @@ static int get_options(int *argc, char ***argv)
|
||||||
my_progname_short);
|
my_progname_short);
|
||||||
return(EX_USAGE);
|
return(EX_USAGE);
|
||||||
}
|
}
|
||||||
if (ignore_database.records && !opt_alldbs) {
|
if (ignore_database.records && !opt_alldbs)
|
||||||
|
{
|
||||||
fprintf(stderr,
|
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);
|
my_progname_short);
|
||||||
return(EX_USAGE);
|
return(EX_USAGE);
|
||||||
}
|
}
|
||||||
|
@ -4236,6 +4237,7 @@ static int dump_tablespaces_for_tables(char *db, char **table_names, int tables)
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int dump_tablespaces_for_databases(char** databases)
|
static int dump_tablespaces_for_databases(char** databases)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
|
@ -4265,6 +4267,7 @@ static int dump_tablespaces_for_databases(char** databases)
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int dump_tablespaces(char* ts_where)
|
static int dump_tablespaces(char* ts_where)
|
||||||
{
|
{
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
@ -4451,11 +4454,11 @@ static int dump_tablespaces(char* ts_where)
|
||||||
DBUG_RETURN(0);
|
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))
|
!my_strcasecmp(&my_charset_latin1, row[0], PERFORMANCE_SCHEMA_DB_NAME))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (include_database(row[0], strlen(row[0])))
|
if (include_database(row[0]))
|
||||||
if (dump_all_tables_in_db(row[0]))
|
if (dump_all_tables_in_db(row[0]))
|
||||||
result=1;
|
result=1;
|
||||||
}
|
}
|
||||||
|
@ -4501,7 +4504,7 @@ static int dump_all_databases()
|
||||||
!my_strcasecmp(&my_charset_latin1, row[0], PERFORMANCE_SCHEMA_DB_NAME))
|
!my_strcasecmp(&my_charset_latin1, row[0], PERFORMANCE_SCHEMA_DB_NAME))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (include_database(row[0], strlen(row[0])))
|
if (include_database(row[0]))
|
||||||
if (dump_all_views_in_db(row[0]))
|
if (dump_all_views_in_db(row[0]))
|
||||||
result=1;
|
result=1;
|
||||||
}
|
}
|
||||||
|
@ -6087,8 +6090,6 @@ int main(int argc, char **argv)
|
||||||
sf_leaking_memory=1; /* don't report memory leaks on early exits */
|
sf_leaking_memory=1; /* don't report memory leaks on early exits */
|
||||||
compatible_mode_normal_str[0]= 0;
|
compatible_mode_normal_str[0]= 0;
|
||||||
default_charset= (char *)mysql_universal_client_charset;
|
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);
|
exit_code= get_options(&argc, &argv);
|
||||||
if (exit_code)
|
if (exit_code)
|
||||||
|
|
|
@ -4478,6 +4478,14 @@ TRUNCATE mysql.event;
|
||||||
SHOW EVENTS;
|
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
|
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
|
# Bug#31113 mysqldump 5.1 can't handle a dash ("-") in database names
|
||||||
#
|
#
|
||||||
create database `test-database`;
|
create database `test-database`;
|
||||||
|
|
|
@ -1926,6 +1926,15 @@ TRUNCATE mysql.event;
|
||||||
SHOW EVENTS;
|
SHOW EVENTS;
|
||||||
--remove_file $MYSQLTEST_VARDIR/tmp/bug29938.sql
|
--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 #
|
||||||
--echo # Bug#31113 mysqldump 5.1 can't handle a dash ("-") in database names
|
--echo # Bug#31113 mysqldump 5.1 can't handle a dash ("-") in database names
|
||||||
|
|
Loading…
Add table
Reference in a new issue