MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Magne Mahre Date:October 17 2008 12:45pm
Subject:bzr push into mysql-6.0 branch (magne.mahre:2732 to 2733) Bug#33831
View as plain text  
 2733 Magne Mahre	2008-10-17
      Fixed Bug#33831 mysql_real_connect() connects again if given an
      already connected MYSQL handle.
modified:
  include/errmsg.h
  libmysql/errmsg.c
  libmysqld/libmysqld.c
  sql-common/client.c
  tests/mysql_client_test.c

 2732 Alexander Nozdrin	2008-10-17 [merge]
      pull from 6.0-rt

=== 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-17 12:39:34 +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-17 12:39:34 +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",
+  "This handle is already connected. Use a separate handle for each connection."
   ""
 };
 
@@ -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",
+  "This handle is already connected. Use a separate handle for each connection."
   ""
 };
 
@@ -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",
+  "This handle is already connected. Use a separate handle for each connection."
   ""
 };
 #endif

=== modified file 'libmysqld/libmysqld.c'
--- a/libmysqld/libmysqld.c	2008-03-27 18:40:00 +0000
+++ b/libmysqld/libmysqld.c	2008-10-17 12:39:34 +0000
@@ -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>
@@ -104,6 +105,13 @@
 		      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;
 

=== 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-17 12:39:34 +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-17 12:39:34 +0000
@@ -18456,6 +18456,49 @@
   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
 */
@@ -18770,6 +18813,7 @@
   { "test_wl4284_1", test_wl4284_1 },
   { "test_wl4435",   test_wl4435 },
   { "test_bug38486", test_bug38486 },
+  { "test_bug33831", test_bug33831 },
   { 0, 0 }
 };
 

Thread
bzr push into mysql-6.0 branch (magne.mahre:2732 to 2733) Bug#33831Magne Mahre17 Oct