diff options
author | Nirbhay Choubey <nirbhay.choubey@oracle.com> | 2011-04-08 12:22:44 +0530 |
---|---|---|
committer | Nirbhay Choubey <nirbhay.choubey@oracle.com> | 2011-04-08 12:22:44 +0530 |
commit | cb0e49c000b65db94cb40c6331572440b4bc4c3e (patch) | |
tree | a2568ca508a47bda56b021dc385d56d3484c056c | |
parent | 9e255716f0b9289f8adf01736ad5dab14c967e80 (diff) | |
download | mariadb-git-cb0e49c000b65db94cb40c6331572440b4bc4c3e.tar.gz |
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 --no-drop, which, if used,
will prevent the dropping of schema at the end of the test.
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.
Introduced an option 'no-drop' to forbid the removal of schema
even if 'create' or 'auto-generate-sql' options are used.
mysql-test/r/mysqlslap.result:
Added a testcase for Bug#11765157.
mysql-test/t/mysqlslap.test:
Added a testcase for Bug#11765157.
-rw-r--r-- | client/client_priv.h | 1 | ||||
-rw-r--r-- | client/mysqlslap.c | 11 | ||||
-rw-r--r-- | mysql-test/r/mysqlslap.result | 20 | ||||
-rw-r--r-- | mysql-test/t/mysqlslap.test | 15 |
4 files changed, 44 insertions, 3 deletions
diff --git a/client/client_priv.h b/client/client_priv.h index 689f7277c2e..92f495864bb 100644 --- a/client/client_priv.h +++ b/client/client_priv.h @@ -85,6 +85,7 @@ enum options_client OPT_SLAP_POST_SYSTEM, OPT_SLAP_COMMIT, OPT_SLAP_DETACH, + OPT_SLAP_NO_DROP, OPT_MYSQL_REPLACE_INTO, OPT_BASE64_OUTPUT_MODE, OPT_SERVER_ID, OPT_FIX_TABLE_NAMES, OPT_FIX_DB_NAMES, OPT_SSL_VERIFY_SERVER_CERT, OPT_DEBUG_INFO, OPT_DEBUG_CHECK, OPT_COLUMN_TYPES, OPT_ERROR_LOG_FILE, diff --git a/client/mysqlslap.c b/client/mysqlslap.c index 3b5c14dd74b..851407a108f 100644 --- a/client/mysqlslap.c +++ b/client/mysqlslap.c @@ -131,7 +131,7 @@ const char *delimiter= "\n"; const char *create_schema_string= "mysqlslap"; -static my_bool opt_preserve= TRUE; +static my_bool opt_preserve= TRUE, opt_no_drop= FALSE; static my_bool debug_info_flag= 0, debug_check_flag= 0; static my_bool opt_only_print= FALSE; static my_bool opt_compress= FALSE, tty_password= FALSE, @@ -599,6 +599,8 @@ static struct my_option my_long_options[] = REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"iterations", 'i', "Number of times to run the tests.", &iterations, &iterations, 0, GET_UINT, REQUIRED_ARG, 1, 0, 0, 0, 0, 0}, + {"no-drop", OPT_SLAP_NO_DROP, "Do not drop the schema after the test.", + &opt_no_drop, &opt_no_drop, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"number-char-cols", 'x', "Number of VARCHAR columns to create in table if specifying --auto-generate-sql.", &num_char_cols_opt, &num_char_cols_opt, 0, GET_STR, REQUIRED_ARG, @@ -1147,8 +1149,11 @@ get_options(int *argc,char ***argv) if (!user) user= (char *)"root"; - /* If something is created we clean it up, otherwise we leave schemas alone */ - if (create_string || auto_generate_sql) + /* + If something is created and --no-drop is not specified, we drop the + schema. + */ + if (!opt_no_drop && (create_string || auto_generate_sql)) opt_preserve= FALSE; if (auto_generate_sql && (create_string || user_supplied_query)) diff --git a/mysql-test/r/mysqlslap.result b/mysql-test/r/mysqlslap.result index 4cb01490407..a94d9156462 100644 --- a/mysql-test/r/mysqlslap.result +++ b/mysql-test/r/mysqlslap.result @@ -225,3 +225,23 @@ 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; diff --git a/mysql-test/t/mysqlslap.test b/mysql-test/t/mysqlslap.test index 28042f62fe6..757d2813483 100644 --- a/mysql-test/t/mysqlslap.test +++ b/mysql-test/t/mysqlslap.test @@ -53,3 +53,18 @@ 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-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 --no-drop --auto-generate-sql +--echo # 'bug58090' database should be present. +SHOW DATABASES; +DROP DATABASE bug58090; + |