diff options
author | Magne Mahre <magne.mahre@sun.com> | 2009-10-09 14:30:54 +0200 |
---|---|---|
committer | Magne Mahre <magne.mahre@sun.com> | 2009-10-09 14:30:54 +0200 |
commit | c9248c642453b827c6631c5b76340db72f2f7236 (patch) | |
tree | 8f8dd0cfacbee48a877f1bfaf64adf44dab3767a /tests | |
parent | f0195faf88830fce9515fb148a3bc970fd39c52b (diff) | |
download | mariadb-git-c9248c642453b827c6631c5b76340db72f2f7236.tar.gz |
Bug #33831 mysql_real_connect() connects again if
given an already connected MYSQL handle
mysql_real_connect() did not check whether the MYSQL connection
handler was already connected and connected again even if so.
Now a CR_ALREADY_CONNECTED error is returned.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/mysql_client_test.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 9394b0df40b..4ee73a2d888 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -18026,6 +18026,49 @@ static void test_bug44495() DBUG_VOID_RETURN; } + +/** + Bug# 33831 mysql_real_connect() should fail if + given an already connected MYSQL handle. +*/ + +static void test_bug33831(void) +{ + MYSQL *l_mysql; + my_bool error; + + DBUG_ENTER("test_bug33831"); + + error= 0; + + if (!(l_mysql= mysql_init(NULL))) + { + myerror("mysql_init() failed"); + DIE_UNLESS(0); + } + if (!(mysql_real_connect(l_mysql, opt_host, opt_user, + opt_password, current_db, opt_port, + opt_unix_socket, 0))) + { + myerror("connection failed"); + DIE_UNLESS(0); + } + + if (mysql_real_connect(l_mysql, opt_host, opt_user, + opt_password, current_db, opt_port, + opt_unix_socket, 0)) + { + myerror("connection should have failed"); + DIE_UNLESS(0); + } + + + mysql_close(l_mysql); + + DBUG_VOID_RETURN; +} + + /* Read and parse arguments and MySQL options from my.cnf */ @@ -18336,6 +18379,7 @@ static struct my_tests_st my_tests[]= { { "test_wl4166_1", test_wl4166_1 }, { "test_wl4166_2", test_wl4166_2 }, { "test_bug38486", test_bug38486 }, + { "test_bug33831", test_bug33831 }, { "test_bug40365", test_bug40365 }, { "test_bug43560", test_bug43560 }, #ifdef HAVE_QUERY_CACHE |