diff options
author | Sergei Golubchik <sergii@pisem.net> | 2012-10-16 13:04:42 +0200 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2012-10-16 13:04:42 +0200 |
commit | ee9afef27141f55165009fdbd58e54942f3a6867 (patch) | |
tree | b5e15e62e10daa40aef3e6d33eeabf9205d1be0f /tests | |
parent | d9a8799205d160688f81362356dd2323eb8a91ea (diff) | |
parent | a619bfad30c13207fb0453a85af5740846186900 (diff) | |
download | mariadb-git-ee9afef27141f55165009fdbd58e54942f3a6867.tar.gz |
mysql-5.5.28
Diffstat (limited to 'tests')
-rw-r--r-- | tests/mysql_client_fw.c | 65 | ||||
-rw-r--r-- | tests/mysql_client_test.c | 9 |
2 files changed, 42 insertions, 32 deletions
diff --git a/tests/mysql_client_fw.c b/tests/mysql_client_fw.c index 979d47cb0b8..207eaead135 100644 --- a/tests/mysql_client_fw.c +++ b/tests/mysql_client_fw.c @@ -61,6 +61,7 @@ static unsigned int opt_count= 0; static unsigned int iter_count= 0; static my_bool have_innodb= FALSE; static char *opt_plugin_dir= 0, *opt_default_auth= 0; +static unsigned int opt_drop_db= 1; static const char *opt_basedir= "./"; static const char *opt_vardir= "mysql-test/var"; @@ -109,7 +110,7 @@ DBUG_PRINT("test", ("name: %s", str)); \ static void print_error(const char *msg); static void print_st_error(MYSQL_STMT *stmt, const char *msg); -static void client_disconnect(MYSQL* mysql, my_bool drop_db); +static void client_disconnect(MYSQL* mysql); /* @@ -134,6 +135,7 @@ static void die(const char *file, int line, const char *expr) { fflush(stdout); fprintf(stderr, "%s:%d: check failed: '%s'\n", file, line, expr); + fprintf(stderr, "MySQL error %d: %s\n", mysql_errno(0), mysql_error(0)); fflush(stderr); exit(1); } @@ -385,31 +387,31 @@ static MYSQL* client_connect(ulong flag, uint protocol, my_bool auto_reconnect) /* Close the connection */ -static void client_disconnect(MYSQL* mysql, my_bool drop_db) +static void client_disconnect(MYSQL* mysql) { - static char query[MAX_TEST_QUERY_LENGTH]; + static char query[MAX_TEST_QUERY_LENGTH]; - myheader_r("client_disconnect"); + myheader_r("client_disconnect"); - if (mysql) - { - if (drop_db) - { - if (!opt_silent) - fprintf(stdout, "\n dropping the test database '%s' ...", current_db); - strxmov(query, "DROP DATABASE IF EXISTS ", current_db, NullS); + if (mysql) + { + if (opt_drop_db) + { + if (!opt_silent) + fprintf(stdout, "\n dropping the test database '%s' ...", current_db); + strxmov(query, "DROP DATABASE IF EXISTS ", current_db, NullS); - mysql_query(mysql, query); - if (!opt_silent) - fprintf(stdout, "OK"); - } + mysql_query(mysql, query); + if (!opt_silent) + fprintf(stdout, "OK"); + } - if (!opt_silent) - fprintf(stdout, "\n closing the connection ..."); - mysql_close(mysql); - if (!opt_silent) - fprintf(stdout, "OK\n"); - } + if (!opt_silent) + fprintf(stdout, "\n closing the connection ..."); + mysql_close(mysql); + if (!opt_silent) + fprintf(stdout, "OK\n"); + } } @@ -1174,14 +1176,16 @@ static char **defaults_argv; static struct my_option client_test_long_options[] = { - {"basedir", 'b', "Basedir for tests.", (char**) &opt_basedir, - (char**) &opt_basedir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"basedir", 'b', "Basedir for tests.", &opt_basedir, + &opt_basedir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"count", 't', "Number of times test to be executed", &opt_count, &opt_count, 0, GET_UINT, REQUIRED_ARG, 1, 0, 0, 0, 0, 0}, {"database", 'D', "Database to use", &opt_db, &opt_db, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"debug", '#', "Output debug log", (char**) &default_dbug_option, - (char**) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, + {"do-not-drop-database", 'd', "Do not drop database while disconnecting", + 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"debug", '#', "Output debug log", &default_dbug_option, + &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"help", '?', "Display this help and exit", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"host", 'h', "Connect to host", &opt_host, &opt_host, @@ -1217,8 +1221,8 @@ static struct my_option client_test_long_options[] = {"user", 'u', "User for login if not current user", &opt_user, &opt_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"vardir", 'v', "Data dir for tests.", (char**) &opt_vardir, - (char**) &opt_vardir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"vardir", 'v', "Data dir for tests.", &opt_vardir, + &opt_vardir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"non-blocking-api", 'n', "Use the non-blocking client API for communication.", &non_blocking_api_enabled, &non_blocking_api_enabled, 0, @@ -1287,6 +1291,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), else opt_silent++; break; + case 'd': + opt_drop_db= 0; + break; case 'A': /* When the embedded server is being tested, the test suite needs to be @@ -1411,7 +1418,7 @@ int main(int argc, char **argv) fprintf(stderr, "\n\nGiven test not found: '%s'\n", *argv); fprintf(stderr, "See legal test names with %s -T\n\nAborting!\n", my_progname); - client_disconnect(mysql, 1); + client_disconnect(mysql); free_defaults(defaults_argv); exit(1); } @@ -1424,7 +1431,7 @@ int main(int argc, char **argv) /* End of tests */ } - client_disconnect(mysql, 1); /* disconnect from server */ + client_disconnect(mysql); /* disconnect from server */ free_defaults(defaults_argv); print_test_output(); diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index a0b18f1f717..95fc61f2b72 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -17691,7 +17691,8 @@ static void test_bug43560(void) const char* values[] = {"eins", "zwei", "drei", "viele", NULL}; const char insert_str[] = "INSERT INTO t1 (c2) VALUES (?)"; unsigned long length; - + const unsigned int drop_db= opt_drop_db; + DBUG_ENTER("test_bug43560"); myheader("test_bug43560"); @@ -17756,9 +17757,11 @@ static void test_bug43560(void) rc= mysql_stmt_execute(stmt); DIE_UNLESS(rc && mysql_stmt_errno(stmt) == CR_SERVER_LOST); - client_disconnect(conn, 0); + opt_drop_db= 0; + client_disconnect(conn); rc= mysql_query(mysql, "DROP TABLE t1"); myquery(rc); + opt_drop_db= drop_db; DBUG_VOID_RETURN; } @@ -18548,7 +18551,7 @@ static void test_progress_reporting() myquery(rc); rc= mysql_query(conn, "set @@global.progress_report_time=@save"); myquery(rc); - client_disconnect(conn, 0); + mysql_close(conn); } |