summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authormsvensson@neptunus.(none) <>2006-01-26 11:20:59 +0100
committermsvensson@neptunus.(none) <>2006-01-26 11:20:59 +0100
commit41c6fee874ac63e450ce22b00162f9e21d507e11 (patch)
tree81b9e2b523c99ade49fbe0165149e9b84839d962 /tests
parent5da306b57eea0bc41db438ea2bf4544421544cc6 (diff)
downloadmariadb-git-41c6fee874ac63e450ce22b00162f9e21d507e11.tar.gz
Bug #15719 MYSQL_OPT_RECONNECT option is modified by mysql_real_connect
- Move init of "reconnect" variable to mysql_init - Add test case to mysql_client_test.
Diffstat (limited to 'tests')
-rw-r--r--tests/mysql_client_test.c80
1 files changed, 78 insertions, 2 deletions
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c
index 216961b3a80..d33654d8810 100644
--- a/tests/mysql_client_test.c
+++ b/tests/mysql_client_test.c
@@ -14598,7 +14598,6 @@ static void test_bug14845()
static void test_bug15510()
{
MYSQL_STMT *stmt;
- MYSQL_RES *res;
int rc;
const char *query= "select 1 from dual where 1/0";
@@ -14624,6 +14623,81 @@ static void test_bug15510()
myquery(rc);
}
+
+/* Test MYSQL_OPT_RECONNECT, Bug#15719 */
+
+static void test_opt_reconnect()
+{
+ MYSQL *lmysql;
+ my_bool my_true= TRUE;
+
+ myheader("test_opt_reconnect");
+
+ if (!(lmysql= mysql_init(NULL)))
+ {
+ myerror("mysql_init() failed");
+ exit(1);
+ }
+
+ if (!opt_silent)
+ fprintf(stdout, "reconnect before mysql_options: %d\n", lmysql->reconnect);
+ DIE_UNLESS(lmysql->reconnect == 0);
+
+ if (mysql_options(lmysql, MYSQL_OPT_RECONNECT, &my_true))
+ {
+ myerror("mysql_options failed: unknown option MYSQL_OPT_RECONNECT\n");
+ exit(1);
+ }
+
+ /* reconnect should be 1 */
+ if (!opt_silent)
+ fprintf(stdout, "reconnect after mysql_options: %d\n", lmysql->reconnect);
+ DIE_UNLESS(lmysql->reconnect == 1);
+
+ if (!(mysql_real_connect(lmysql, opt_host, opt_user,
+ opt_password, current_db, opt_port,
+ opt_unix_socket, 0)))
+ {
+ myerror("connection failed");
+ exit(1);
+ }
+
+ /* reconnect should still be 1 */
+ if (!opt_silent)
+ fprintf(stdout, "reconnect after mysql_real_connect: %d\n",
+ lmysql->reconnect);
+ DIE_UNLESS(lmysql->reconnect == 1);
+
+ mysql_close(lmysql);
+
+ if (!(lmysql= mysql_init(NULL)))
+ {
+ myerror("mysql_init() failed");
+ exit(1);
+ }
+
+ if (!opt_silent)
+ fprintf(stdout, "reconnect before mysql_real_connect: %d\n", lmysql->reconnect);
+ DIE_UNLESS(lmysql->reconnect == 0);
+
+ if (!(mysql_real_connect(lmysql, opt_host, opt_user,
+ opt_password, current_db, opt_port,
+ opt_unix_socket, 0)))
+ {
+ myerror("connection failed");
+ exit(1);
+ }
+
+ /* reconnect should still be 0 */
+ if (!opt_silent)
+ fprintf(stdout, "reconnect after mysql_real_connect: %d\n",
+ lmysql->reconnect);
+ DIE_UNLESS(lmysql->reconnect == 0);
+
+ mysql_close(lmysql);
+}
+
+
/*
Read and parse arguments and MySQL options from my.cnf
*/
@@ -14883,7 +14957,9 @@ static struct my_tests_st my_tests[]= {
{ "test_bug13488", test_bug13488 },
{ "test_bug13524", test_bug13524 },
{ "test_bug14845", test_bug14845 },
- { "test_bug15510", test_bug15510},
+ { "test_bug15510", test_bug15510 },
+ { "test_opt_reconnect", test_opt_reconnect },
+
{ 0, 0 }
};