#At file:///home/mm136784/z/mysql-6.0-runtime-fix33831/
2728 Magne Mahre 2008-10-10
Fix for bug# 33831
Added a new error message to indicate that the session is already connected.
modified:
include/errmsg.h
libmysql/errmsg.c
sql-common/client.c
tests/mysql_client_test.c
=== modified file 'include/errmsg.h'
=== modified file 'include/errmsg.h'
--- a/include/errmsg.h 2008-05-20 16:36:26 +0000
+++ b/include/errmsg.h 2008-10-10 11:10:20 +0000
@@ -97,6 +97,7 @@
#define CR_SERVER_LOST_EXTENDED 2055
#define CR_STMT_CLOSED 2056
#define CR_NEW_STMT_METADATA 2057
-#define CR_ERROR_LAST /*Copy last error nr:*/ 2057
+#define CR_ALREADY_CONNECTED 2058
+#define CR_ERROR_LAST /*Copy last error nr:*/ 2058
/* Add error numbers before CR_ERROR_LAST and change it accordingly. */
=== modified file 'libmysql/errmsg.c'
--- a/libmysql/errmsg.c 2008-05-20 16:36:26 +0000
+++ b/libmysql/errmsg.c 2008-10-10 11:10:20 +0000
@@ -85,6 +85,7 @@
"Lost connection to MySQL server at '%s', system error: %d",
"Statement closed indirectly because of a preceeding %s() call",
"The number of columns in the result set differs from the number of bound buffers. You must reset the statement, rebind the result set columns, and execute the statement again",
+ "Already connected",
""
};
@@ -151,6 +152,7 @@
"Lost connection to MySQL server at '%s', system error: %d",
"Statement closed indirectly because of a preceeding %s() call",
"The number of columns in the result set differs from the number of bound buffers. You must reset the statement, rebind the result set columns, and execute the statement again",
+ "Already connected",
""
};
@@ -215,6 +217,7 @@
"Lost connection to MySQL server at '%s', system error: %d",
"Statement closed indirectly because of a preceeding %s() call",
"The number of columns in the result set differs from the number of bound buffers. You must reset the statement, rebind the result set columns, and execute the statement again",
+ "Already connected",
""
};
#endif
=== modified file 'sql-common/client.c'
--- a/sql-common/client.c 2008-05-08 16:01:15 +0000
+++ b/sql-common/client.c 2008-10-10 11:10:20 +0000
@@ -1836,6 +1836,13 @@
db ? db : "(Null)",
user ? user : "(Null)"));
+ /* Test whether we're already connected */
+ if (net->vio)
+ {
+ set_mysql_error(mysql, CR_ALREADY_CONNECTED, unknown_sqlstate);
+ DBUG_RETURN(0);
+ }
+
/* Don't give sigpipe errors if the client doesn't want them */
set_sigpipe(mysql);
mysql->methods= &client_methods;
=== modified file 'tests/mysql_client_test.c'
--- a/tests/mysql_client_test.c 2008-09-15 20:37:25 +0000
+++ b/tests/mysql_client_test.c 2008-10-10 11:10:20 +0000
@@ -18456,6 +18456,48 @@
DBUG_VOID_RETURN;
}
+
+/**
+ Bug# 33831 mysql_real_connect() connects again 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
*/
@@ -18770,6 +18812,7 @@
{ "test_wl4284_1", test_wl4284_1 },
{ "test_wl4435", test_wl4435 },
{ "test_bug38486", test_bug38486 },
+ { "test_bug33831", test_bug33831 },
{ 0, 0 }
};