summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorunknown <brian@zim.(none)>2005-05-20 06:56:02 -0700
committerunknown <brian@zim.(none)>2005-05-20 06:56:02 -0700
commitec00a4558c966d0f2b591a8acb365d69211607ef (patch)
tree3fd6a6fc9a9e00c2a8013d1274991982bdde6eb7 /client
parentf4a584f5013373f3c939df7cd7ef7ab444b18168 (diff)
downloadmariadb-git-ec00a4558c966d0f2b591a8acb365d69211607ef.tar.gz
Additions for --add-drop-database
client/client_priv.h: Adding option for drop database client/mysqldump.c: Work for adding of --add-drop-database mysql-test/r/mysqldump.result: New test results for --add-drop-databases mysql-test/t/mysqldump.test: Tests for --add-drop-databases
Diffstat (limited to 'client')
-rw-r--r--client/client_priv.h2
-rw-r--r--client/mysqldump.c19
2 files changed, 16 insertions, 5 deletions
diff --git a/client/client_priv.h b/client/client_priv.h
index 45806349d7d..5085c03e84f 100644
--- a/client/client_priv.h
+++ b/client/client_priv.h
@@ -49,5 +49,5 @@ enum options_client
#ifdef HAVE_NDBCLUSTER_DB
,OPT_NDBCLUSTER,OPT_NDB_CONNECTSTRING
#endif
- ,OPT_IGNORE_TABLE,OPT_INSERT_IGNORE
+ ,OPT_IGNORE_TABLE,OPT_INSERT_IGNORE,OPT_DROP_DATABASE
};
diff --git a/client/mysqldump.c b/client/mysqldump.c
index 493ef57a73b..7b18b1d92da 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -85,7 +85,7 @@ static my_bool verbose=0,tFlag=0,dFlag=0,quick= 1, extended_insert= 1,
opt_delete_master_logs=0, tty_password=0,
opt_single_transaction=0, opt_comments= 0, opt_compact= 0,
opt_hex_blob=0, opt_order_by_primary=0, opt_ignore=0,
- opt_complete_insert= 0;
+ opt_complete_insert= 0, opt_drop_database= 0;
static ulong opt_max_allowed_packet, opt_net_buffer_length;
static MYSQL mysql_connection,*sock=0;
static my_bool insert_pat_inited=0;
@@ -159,6 +159,9 @@ static struct my_option my_long_options[] =
"Dump all the databases. This will be same as --databases with all databases selected.",
(gptr*) &opt_alldbs, (gptr*) &opt_alldbs, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
0, 0},
+ {"add-drop-database", OPT_DROP_DATABASE, "Add a 'DROP DATABASE' before each create.",
+ (gptr*) &opt_drop_database, (gptr*) &opt_drop_database, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
+ 0},
{"add-drop-table", OPT_DROP, "Add a 'drop table' before each create.",
(gptr*) &opt_drop, (gptr*) &opt_drop, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0,
0},
@@ -1119,9 +1122,9 @@ static uint getTableStructure(char *table, char* db)
else
dynstr_set(&insert_pat, "");
- insert_option= (opt_delayed && opt_ignore) ? " DELAYED IGNORE " :
- opt_delayed ? " DELAYED " :
- opt_ignore ? " IGNORE " : "";
+ insert_option= ((opt_delayed && opt_ignore) ? " DELAYED IGNORE " :
+ opt_delayed ? " DELAYED " :
+ opt_ignore ? " IGNORE " : "");
if (verbose)
fprintf(stderr, "-- Retrieving table structure for table %s...\n", table);
@@ -2043,12 +2046,20 @@ static int init_dumping(char *database)
if (mysql_query(sock, qbuf) || !(dbinfo = mysql_store_result(sock)))
{
/* Old server version, dump generic CREATE DATABASE */
+ if (opt_drop_database)
+ fprintf(md_result_file,
+ "\n/*!40000 DROP DATABASE IF EXISTS %s;*/\n",
+ qdatabase);
fprintf(md_result_file,
"\nCREATE DATABASE /*!32312 IF NOT EXISTS*/ %s;\n",
qdatabase);
}
else
{
+ if (opt_drop_database)
+ fprintf(md_result_file,
+ "\n/*!40000 DROP DATABASE IF EXISTS %s*/;\n",
+ qdatabase);
row = mysql_fetch_row(dbinfo);
if (row[1])
{