diff --git a/client/mysqldump.c b/client/mysqldump.c
index 6db47e71c6a..db3a7dd980f 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -1595,6 +1595,26 @@ static void dump_table(uint numFields, char *table)
const char *table_type;
int error= 0;
+ /* Check --no-data flag */
+ if (dFlag)
+ {
+ if (verbose)
+ fprintf(stderr,
+ "-- Skipping dump data for table '%s', --no-data was used\n",
+ table);
+ return;
+ }
+
+ /* Check that there are any fields in the table */
+ if(numFields == 0)
+ {
+ if (verbose)
+ fprintf(stderr,
+ "-- Skipping dump data for table '%s', it has no fields\n",
+ table);
+ return;
+ }
+
result_table= quote_name(table,table_buff, 1);
opt_quoted_table= quote_name(table, table_buff2, 0);
@@ -2204,8 +2224,7 @@ static int dump_all_tables_in_db(char *database)
if (include_table(hash_key, end - hash_key))
{
numrows = get_table_structure(table, database);
- if (!dFlag && numrows > 0)
- dump_table(numrows,table);
+ dump_table(numrows,table);
my_free(order_by, MYF(MY_ALLOW_ZERO_PTR));
order_by= 0;
}
@@ -2392,6 +2411,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
}
if (opt_xml)
print_xml_tag1(md_result_file, "", "database name=", db, "\n");
+
/* Dump each selected table */
const char *table_name;
for (i= 0; i < dump_tables.records; i++)
@@ -2401,6 +2421,8 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
numrows = get_table_structure(table_name, db);
dump_table(numrows, table_name);
}
+
+ /* Dump each selected view */
if (was_views)
{
for(i=0; i < dump_tables.records; i++)
diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result
index ec1c60ac0d8..54568d8b466 100644
--- a/mysql-test/r/mysqldump.result
+++ b/mysql-test/r/mysqldump.result
@@ -1529,6 +1529,28 @@ CREATE TABLE `t2` (
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
DROP TABLE t1, t2;
DROP DATABASE mysqldump_test_db;
create database mysqldump_test_db;
diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test
index 45815d207c7..a73f163f1ef 100644
--- a/mysql-test/t/mysqldump.test
+++ b/mysql-test/t/mysqldump.test
@@ -600,6 +600,8 @@ INSERT INTO t1 VALUES (1), (2);
INSERT INTO t2 VALUES (1), (2);
--exec $MYSQL_DUMP --skip-comments --no-data mysqldump_test_db
--exec $MYSQL_DUMP --skip-comments --no-data mysqldump_test_db t1 t2
+--exec $MYSQL_DUMP --skip-comments --skip-create --xml --no-data mysqldump_test_db
+--exec $MYSQL_DUMP --skip-comments --skip-create --xml --no-data mysqldump_test_db t1 t2
DROP TABLE t1, t2;
DROP DATABASE mysqldump_test_db;