List:Commits« Previous MessageNext Message »
From:Nirbhay Choubey Date:March 30 2011 4:58pm
Subject:bzr commit into mysql-5.1 branch (nirbhay.choubey:3645) Bug#11765157
View as plain text  
#At file:///home/nirbhay/Project/mysql/repo/bugs/mysql-5.1.58090/ based on revid:magne.mahre@stripped

 3645 Nirbhay Choubey	2011-03-30
      Bug#11765157 - 58090: mysqlslap drops schema specified in
                     create_schema if auto-generate-sql also set.
      
      mysqlslap uses a schema to run its tests on and later
      drops it if auto-generate-sql is used. This can be a
      problem, if the schema is an already existing one.
      
      If create-schema is used with auto-generate-sql option,
      mysqlslap while performing the cleanup, drops the specified
      database.
      
      Fixed by introducing an option create-and-drop-schema
      which will create and later drop the database. However,
      create-schema (as its name says) now will not drop
      the database at the end of the test anymore.
     @ client/client_priv.h
        Bug#11765157 - 58090: mysqlslap drops schema specified in
                       create_schema if auto-generate-sql also set.
        
        Added an option.
     @ client/mysqlslap.c
        Bug#11765157 - 58090: mysqlslap drops schema specified in
                       create_schema if auto-generate-sql also set.
        
        Added the logic to control opt_preserve based on the values
        of create-schema and create-and-drop-schema, as provided by
        the user.
     @ mysql-test/r/mysqlslap.result
        Added a testcase for Bug#11765157.
     @ mysql-test/t/mysqlslap.test
        Added a testcase for Bug#11765157.

    modified:
      client/client_priv.h
      client/mysqlslap.c
      mysql-test/r/mysqlslap.result
      mysql-test/t/mysqlslap.test
=== modified file 'client/client_priv.h'
--- a/client/client_priv.h	2010-01-27 12:23:28 +0000
+++ b/client/client_priv.h	2011-03-30 16:58:00 +0000
@@ -71,6 +71,7 @@ enum options_client
   OPT_MYSQL_NUMBER_OF_QUERY,
   OPT_IGNORE_TABLE,OPT_INSERT_IGNORE,OPT_SHOW_WARNINGS,OPT_DROP_DATABASE,
   OPT_TZ_UTC, OPT_AUTO_CLOSE, OPT_CREATE_SLAP_SCHEMA,
+  OPT_CREATE_DROP_SLAP_SCHEMA,
   OPT_SLAP_CSV, OPT_SLAP_CREATE_STRING,
   OPT_SLAP_AUTO_GENERATE_SQL_LOAD_TYPE, OPT_SLAP_AUTO_GENERATE_WRITE_NUM,
   OPT_SLAP_AUTO_GENERATE_ADD_AUTO,

=== modified file 'client/mysqlslap.c'
--- a/client/mysqlslap.c	2011-01-13 10:26:42 +0000
+++ b/client/mysqlslap.c	2011-03-30 16:58:00 +0000
@@ -129,7 +129,8 @@ static char *host= NULL, *opt_password= 
 
 const char *delimiter= "\n";
 
-const char *create_schema_string= "mysqlslap";
+const char *create_schema_string= NULL;
+const char *create_drop_schema_string= NULL;
 
 static my_bool opt_preserve= TRUE;
 static my_bool debug_info_flag= 0, debug_check_flag= 0;
@@ -565,9 +566,15 @@ static struct my_option my_long_options[
   {"create", OPT_SLAP_CREATE_STRING, "File or string to use create tables.",
     &create_string, &create_string, 0, GET_STR, REQUIRED_ARG,
     0, 0, 0, 0, 0, 0},
-  {"create-schema", OPT_CREATE_SLAP_SCHEMA, "Schema to run tests in.",
-    &create_schema_string, &create_schema_string, 0, GET_STR, 
-    REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+  {"create-schema", OPT_CREATE_SLAP_SCHEMA,
+   "Create a schema, if not already present, to run the tests on and "
+   "preserve it afterwards.", &create_schema_string, &create_schema_string,
+   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+  {"create-and-drop-schema", OPT_CREATE_DROP_SLAP_SCHEMA,
+   "Create a schema to run the tests and drop it afterwards. The effect of "
+   "this option will be negligible if used along with create-schema option.",
+   &create_drop_schema_string, &create_drop_schema_string, 0, GET_STR,
+   REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"csv", OPT_SLAP_CSV,
 	"Generate CSV output to named file or to stdout if no file is named.",
     NULL, NULL, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
@@ -1470,6 +1477,20 @@ get_options(int *argc,char ***argv)
 
   if (tty_password)
     opt_password= get_tty_password(NullS);
+
+  if (!create_schema_string)
+  {
+    opt_preserve= FALSE;
+    if (!create_drop_schema_string)
+      create_schema_string= "mysqlslap";
+    else
+      create_schema_string= my_strdup(create_drop_schema_string,
+                                      MYF(MY_FAE));
+  }
+  else
+    /* Do not drop the database. */
+    opt_preserve= TRUE;
+
   DBUG_RETURN(0);
 }
 

=== modified file 'mysql-test/r/mysqlslap.result'
--- a/mysql-test/r/mysqlslap.result	2007-12-20 20:32:16 +0000
+++ b/mysql-test/r/mysqlslap.result	2011-03-30 16:58:00 +0000
@@ -225,3 +225,30 @@ DROP SCHEMA IF EXISTS `mysqlslap`;
 DROP PROCEDURE IF EXISTS p1;
 CREATE PROCEDURE p1() SELECT 1;
 DROP PROCEDURE p1;
+#
+# Bug #11765157 - 58090: mysqlslap drops schema specified in
+#                 create_schema if auto-generate-sql also set.
+#
+# 'bug58090' database should not be present.
+SHOW DATABASES;
+Database
+information_schema
+mtr
+mysql
+test
+# 'bug58090' database should be present.
+SHOW DATABASES;
+Database
+information_schema
+bug58090
+mtr
+mysql
+test
+DROP DATABASE bug58090;
+# Creates 'mysqlslap' database and drops it after the test.
+SHOW DATABASES;
+Database
+information_schema
+mtr
+mysql
+test

=== modified file 'mysql-test/t/mysqlslap.test'
--- a/mysql-test/t/mysqlslap.test	2007-09-27 08:15:15 +0000
+++ b/mysql-test/t/mysqlslap.test	2011-03-30 16:58:00 +0000
@@ -13,9 +13,9 @@
 
 --exec $MYSQL_SLAP --silent --concurrency=5 --iterations=20 --delimiter=";" --query="select * from t1;select * from t2" --create="CREATE TABLE t1 (id int, name varchar(64)); create table t2(foo1 varchar(32), foo2 varchar(32)); INSERT INTO t1 VALUES (1, 'This is a test'); insert into t2 values ('test', 'test2')"
 
---exec $MYSQL_SLAP --silent --concurrency=5 --iterations=20 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql --create-schema=test_env
+--exec $MYSQL_SLAP --silent --concurrency=5 --iterations=20 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql --create-and-drop-schema=test_env
 
---exec $MYSQL_SLAP --silent --concurrency=5 --iterations=20 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql --create-schema=test_env --auto-generate-sql-add-autoincrement 
+--exec $MYSQL_SLAP --silent --concurrency=5 --iterations=20 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql --create-and-drop-schema=test_env --auto-generate-sql-add-autoincrement 
 
 --exec $MYSQL_SLAP --silent --concurrency=5 --iterations=1 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql --auto-generate-sql-add-autoincrement 
 
@@ -53,3 +53,20 @@ CREATE PROCEDURE p1() SELECT 1;
 --exec $MYSQL_SLAP --create-schema=test --delimiter=";" --query="CALL p1; SELECT 1;" --silent 2>&1 
 
 DROP PROCEDURE p1;
+
+--echo #
+--echo # Bug #11765157 - 58090: mysqlslap drops schema specified in
+--echo #                 create_schema if auto-generate-sql also set.
+--echo #
+
+--exec $MYSQL_SLAP --silent --create-and-drop-schema=bug58090 --concurrency=5 --iterations=20 --auto-generate-sql
+--echo # 'bug58090' database should not be present.
+SHOW DATABASES;
+--exec $MYSQL_SLAP --silent --create-schema=bug58090 --auto-generate-sql
+--echo # 'bug58090' database should be present.
+SHOW DATABASES;
+DROP DATABASE bug58090;
+--echo # Creates 'mysqlslap' database and drops it after the test.
+--exec $MYSQL_SLAP --silent --concurrency=5 --iterations=20 --auto-generate-sql 
+SHOW DATABASES;
+


Attachment: [text/bzr-bundle] bzr/nirbhay.choubey@oracle.com-20110330165800-5e1joamt3sht307h.bundle
Thread
bzr commit into mysql-5.1 branch (nirbhay.choubey:3645) Bug#11765157Nirbhay Choubey30 Mar