summaryrefslogtreecommitdiff
path: root/libmysqld/libmysqld.c
diff options
context:
space:
mode:
authorMagne Mahre <magne.mahre@sun.com>2009-10-09 14:30:54 +0200
committerMagne Mahre <magne.mahre@sun.com>2009-10-09 14:30:54 +0200
commitc9248c642453b827c6631c5b76340db72f2f7236 (patch)
tree8f8dd0cfacbee48a877f1bfaf64adf44dab3767a /libmysqld/libmysqld.c
parentf0195faf88830fce9515fb148a3bc970fd39c52b (diff)
downloadmariadb-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 'libmysqld/libmysqld.c')
-rw-r--r--libmysqld/libmysqld.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/libmysqld/libmysqld.c b/libmysqld/libmysqld.c
index 31ad8844650..bcb72041961 100644
--- a/libmysqld/libmysqld.c
+++ b/libmysqld/libmysqld.c
@@ -28,6 +28,7 @@
#include <sys/stat.h>
#include <signal.h>
#include <time.h>
+#include <sql_common.h>
#include "client_settings.h"
#ifdef HAVE_PWD_H
#include <pwd.h>
@@ -77,17 +78,6 @@ static my_bool is_NT(void)
}
#endif
-/**************************************************************************
-** Shut down connection
-**************************************************************************/
-
-static void end_server(MYSQL *mysql)
-{
- DBUG_ENTER("end_server");
- free_old_query(mysql);
- DBUG_VOID_RETURN;
-}
-
int mysql_init_character_set(MYSQL *mysql);
@@ -104,6 +94,13 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
db ? db : "(Null)",
user ? user : "(Null)"));
+ /* Test whether we're already connected */
+ if (mysql->server_version)
+ {
+ set_mysql_error(mysql, CR_ALREADY_CONNECTED, unknown_sqlstate);
+ DBUG_RETURN(0);
+ }
+
if (!host || !host[0])
host= mysql->options.host;
@@ -215,7 +212,7 @@ error:
{
/* Free alloced memory */
my_bool free_me=mysql->free_me;
- end_server(mysql);
+ free_old_query(mysql);
mysql->free_me=0;
mysql_close(mysql);
mysql->free_me=free_me;