List:Commits« Previous MessageNext Message »
From:Vladislav Vaintroub Date:September 27 2009 4:01pm
Subject:bzr commit into mysql-5.1-mtr branch (vvaintroub:2837) Bug#47423
View as plain text  
#At file:///H:/bzr/mysql-5.1-mtr/ based on revid:bjorn.munch@stripped

 2837 Vladislav Vaintroub	2009-09-27
      Bug #47423 mysqltest attaches to wrong database
      
      The reason for the bug is that mysqtest will try to connect via 
      shared memory, with default shared memory base name "MySQL". 
      If mysql is installed, and shared memory is enabled, mysqltest 
      will attach to it instead of its own instance.
      
      The fix is to use TCP connections, as port numbers used by mtr 
      are unique. In mtr scripts,connection protocol can be overwritten 
      with connect(<something>,,,PIPE) or connect(<something>,,,SHM).  
      This functionality (optional parameters for connect command was manually
      backported from 6.0(original patch  http://lists.mysql.com/commits/74749)

    modified:
      client/mysqltest.cc
      mysql-test/t/named_pipe.test
=== modified file 'client/mysqltest.cc'
--- a/client/mysqltest.cc	2009-09-02 21:29:11 +0000
+++ b/client/mysqltest.cc	2009-09-27 16:01:09 +0000
@@ -4895,6 +4895,8 @@ do_handle_error:
   <opts> - options to use for the connection
    * SSL - use SSL if available
    * COMPRESS - use compression if available
+   * SHM - use shared memory if available
+   * PIPE - use named pipe if available
 
 */
 
@@ -4903,6 +4905,7 @@ void do_connect(struct st_command *comma
   int con_port= opt_port;
   char *con_options;
   my_bool con_ssl= 0, con_compress= 0;
+  my_bool con_pipe= 0, con_shm= 0;
   struct st_connection* con_slot;
 
   static DYNAMIC_STRING ds_connection_name;
@@ -4913,6 +4916,9 @@ void do_connect(struct st_command *comma
   static DYNAMIC_STRING ds_port;
   static DYNAMIC_STRING ds_sock;
   static DYNAMIC_STRING ds_options;
+#ifdef HAVE_SMEM
+  static DYNAMIC_STRING ds_shm;
+#endif
   const struct command_arg connect_args[] = {
     { "connection name", ARG_STRING, TRUE, &ds_connection_name, "Name of the connection" },
     { "host", ARG_STRING, TRUE, &ds_host, "Host to connect to" },
@@ -4940,6 +4946,11 @@ void do_connect(struct st_command *comma
       die("Illegal argument for port: '%s'", ds_port.str);
   }
 
+#ifdef HAVE_SMEM
+  /* Shared memory */
+  init_dynamic_string(&ds_shm, ds_sock.str, 0, 0);
+#endif
+
   /* Sock */
   if (ds_sock.length)
   {
@@ -4978,6 +4989,10 @@ void do_connect(struct st_command *comma
       con_ssl= 1;
     else if (!strncmp(con_options, "COMPRESS", 8))
       con_compress= 1;
+    else if (!strncmp(con_options, "PIPE", 4))
+      con_pipe= 1;
+    else if (!strncmp(con_options, "SHM", 3))
+      con_shm= 1;
     else
       die("Illegal option to connect: %.*s", 
           (int) (end - con_options), con_options);
@@ -5025,6 +5040,26 @@ void do_connect(struct st_command *comma
   }
 #endif
 
+#ifdef __WIN__
+  if (con_pipe)
+  {
+    uint protocol= MYSQL_PROTOCOL_PIPE;
+    mysql_options(&con_slot->mysql, MYSQL_OPT_PROTOCOL, &protocol);
+  }
+#endif
+
+#ifdef HAVE_SMEM
+  if (con_shm)
+  {
+    uint protocol= MYSQL_PROTOCOL_MEMORY;
+    if (!ds_shm.length)
+      die("Missing shared memory base name");
+    mysql_options(&con_slot->mysql, MYSQL_OPT_PROTOCOL, &protocol);
+    mysql_options(&con_slot->mysql, MYSQL_SHARED_MEMORY_BASE_NAME, ds_shm.str);
+  }
+#endif
+
+
   /* Use default db name */
   if (ds_database.length == 0)
     dynstr_set(&ds_database, opt_db);
@@ -5057,6 +5092,9 @@ void do_connect(struct st_command *comma
   dynstr_free(&ds_port);
   dynstr_free(&ds_sock);
   dynstr_free(&ds_options);
+#ifdef HAVE_SMEM
+  dynstr_free(&ds_shm);
+#endif
   DBUG_VOID_RETURN;
 }
 
@@ -7661,6 +7699,15 @@ int main(int argc, char **argv)
   }
 #endif
 
+#ifdef _WIN32
+   /*
+     Prevent connecting to installed instances via shared memory.
+     Use TCP ports instead, they are unique.
+   */
+   uint protocol= MYSQL_PROTOCOL_TCP;
+   mysql_options(&con->mysql, MYSQL_OPT_PROTOCOL, &protocol);
+#endif
+
   if (!(con->name = my_strdup("default", MYF(MY_WME))))
     die("Out of memory");
 

=== modified file 'mysql-test/t/named_pipe.test'
--- a/mysql-test/t/named_pipe.test	2007-09-24 10:42:44 +0000
+++ b/mysql-test/t/named_pipe.test	2009-09-27 16:01:09 +0000
@@ -9,6 +9,11 @@ if (`SELECT '$nmp' != 'ON'`){
   skip No named pipe support;
 }
 
+# Connect using named pipe for testing
+connect(pipe_con,localhost,root,,,,,PIPE);
+
 # Source select test case
 -- source include/common-tests.inc
 
+connection default;
+disconnect pipe_con;


Attachment: [text/bzr-bundle] bzr/vvaintroub@mysql.com-20090927160109-aku4qvlagbw25lsj.bundle
Thread
bzr commit into mysql-5.1-mtr branch (vvaintroub:2837) Bug#47423Vladislav Vaintroub27 Sep