Bug #52301 Add --protocol to mysqltest
Submitted: 23 Mar 2010 11:49 Modified: 14 Oct 2010 14:28
Reporter: Jørgen Austvik Email Updates:
Status: Closed Impact on me:
None 
Category:Tools: MTR / mysql-test-run Severity:S4 (Feature request)
Version:5.1+ OS:Any
Assigned to: Bjørn Munch CPU Architecture:Any

[23 Mar 2010 11:49] Jørgen Austvik
Description:
Many of the client applications (mysqlcheck, mysqlimport, mysqladmin, mysqlshow, mysql, etc.) supports the --protocol command line option, which is documented like this:

  --protocol={TCP|SOCKET|PIPE|MEMORY}

  The connection protocol to use for connecting to the server. It is useful when
  the other connection parameters normally would cause a protocol to be used
  other than the one you want. For details on the allowable values, see Section
  4.2.2, “Connecting to the MySQL Server”. 

http://dev.mysql.com/doc/refman/5.1/en/mysql-command-options.html#option_mysql_protocol

When we start mysqltest from ATRT, the [client] part of my.cnf set this option (to TCP since this is a distributed test), when mysqltest does not support the protocol option, it gives an error message, and refuses to run.

This feature request is for adding the protocol option to mysqltest, and a patch that utilizes standard mysql client library methods for doing this is attached in the suggested fix.

How to repeat:
./mysqltest --protocol => get error message :)

Suggested fix:
=== modified file 'client/mysqltest.cc'                                                                                                                                                                                   
--- client/mysqltest.cc 2010-03-12 06:06:23 +0000                                                                                                                                                                         
+++ client/mysqltest.cc 2010-03-19 10:41:22 +0000                                                                                                                                                                         
@@ -189,6 +189,8 @@                                                                                                                                                                                                       
 static int match_re(my_regex_t *, char *);                                                                                                                                                                               
 static void free_re(void);                                                                                                                                                                                               
                                                                                                                                                                                                                          
+static uint opt_protocol=0;                                                                                                                                                                                              
+                                                                                                                                                                                                                         
 DYNAMIC_ARRAY q_lines;                                                                                                                                                                                                   
                                                                                                                                                                                                                          
 #include "sslopt-vars.h"                                                                                                                                                                                                 
@@ -5108,11 +5110,13 @@                                                                                                                                                                                                   
 #ifdef __WIN__                                                                                                                                                                                                           
   if (con_pipe)                                                                                                                                                                                                          
   {                                                                                                                                                                                                                      
-    uint protocol= MYSQL_PROTOCOL_PIPE;                                                                                                                                                                                  
-    mysql_options(&con_slot->mysql, MYSQL_OPT_PROTOCOL, &protocol);
+    opt_protocol= MYSQL_PROTOCOL_PIPE;
   }
 #endif

+  if (opt_protocol)
+    mysql_options(&con_slot->mysql,MYSQL_OPT_PROTOCOL,(char*)&opt_protocol);
+
 #ifdef HAVE_SMEM
   if (con_shm)
   {
@@ -5826,6 +5830,8 @@
    GET_INT, REQUIRED_ARG, 500, 1, 10000, 0, 0, 0},
   {"password", 'p', "Password to use when connecting to server.",
    0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
+  {"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).",
+   0, 0, 0, GET_STR,  REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"port", 'P', "Port number to use for connection or 0 for default to, in "
    "order of preference, my.cnf, $MYSQL_TCP_PORT, "
 #if MYSQL_PORT_DEFAULT == 0
@@ -5967,7 +5973,7 @@

 static my_bool
-get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
+get_one_option(int optid, const struct my_option *opt,
               char *argument)
 {
   switch(optid) {
@@ -6059,6 +6065,10 @@
   case 'V':
     print_version();
     exit(0);
+  case OPT_MYSQL_PROTOCOL:
+    opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib,
+                                    opt->name);
+    break;
   case '?':
     usage();
     exit(0);
@@ -7797,6 +7807,9 @@
     mysql_options(&con->mysql, MYSQL_SET_CHARSET_DIR,
                   opt_charsets_dir);

+  if (opt_protocol)
+    mysql_options(&con->mysql,MYSQL_OPT_PROTOCOL,(char*)&opt_protocol);
+
 #ifdef HAVE_OPENSSL

   if (opt_use_ssl)
[23 Mar 2010 11:50] Jørgen Austvik
Patch

Attachment: mysqltest_protocol.patch (application/octet-stream, text), 1.89 KiB.

[23 Mar 2010 14:02] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/104088

2907 Bjorn Munch	2010-03-23
      Bug #52301 Add --protocol to mysqltest
      Implement as for other clients
[31 Mar 2010 11:37] Bjørn Munch
Pushed to *-mtr trees
[12 May 2010 13:57] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/108139

3196 Jorgen Austvik	2010-05-12
      bug#52301 cherry picked
[14 May 2010 8:22] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/108290

3197 Jorgen Austvik	2010-05-14
      Revert bug#52301, as the fix that has been in the three since march doesn't work on windows and does funny things to PB2, sigh
[16 Aug 2010 6:30] Bugs System
Pushed into mysql-trunk 5.6.1-m4 (revid:alik@sun.com-20100816062701-qo9dpnk5tkt1pksb) (version source revid:alik@sun.com-20100816062603-xc16eftmv7rmktyq) (merge vers: 5.6.1-m4) (pib:20)
[16 Aug 2010 6:35] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100816062819-bluwgdq8q4xysmlg) (version source revid:alik@sun.com-20100816062612-enatdwnv809iw3s9) (pib:20)
[16 Aug 2010 17:06] Paul DuBois
Test suite changes. No changelog entry needed.
[25 Aug 2010 8:33] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/116716

2924 Bjorn Munch	2010-08-25
      Bug #52301 Add --protocol to mysqltest
      Added code resulted in strange linking problem for embedded on Windows
      Avoided by not doing this for embedded mode
      It's irrelevant for embedded server anyway, --protocol will be ignored
[1 Sep 2010 13:13] Bugs System
Pushed into mysql-trunk 5.6.1-m4 (revid:alik@sun.com-20100901130501-4g2k86dub29auj8y) (version source revid:alik@sun.com-20100901130012-9bmmvzcnnw6n5rw6) (merge vers: 5.6.1-m4) (pib:21)
[1 Sep 2010 13:14] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100901130614-pgop3m80rmutewxn) (version source revid:alik@sun.com-20100901130033-8k19cjn6n2blm3py) (pib:21)
[1 Sep 2010 13:15] Bugs System
Pushed into mysql-5.5 5.5.7-m3 (revid:alik@sun.com-20100901125952-4hsrosoa0xreionr) (version source revid:alik@sun.com-20100901125952-4hsrosoa0xreionr) (merge vers: 5.5.7-m3) (pib:21)
[2 Sep 2010 0:34] Paul DuBois
Changes to test suite. No changelog entry needed.
[28 Sep 2010 8:47] Bugs System
Pushed into mysql-5.1 5.1.52 (revid:sunanda.menon@sun.com-20100928083322-wangbv97uobu7g66) (version source revid:sunanda.menon@sun.com-20100928083322-wangbv97uobu7g66) (merge vers: 5.1.52) (pib:21)
[14 Oct 2010 8:26] Bugs System
Pushed into mysql-5.1-telco-7.0 5.1.51-ndb-7.0.20 (revid:martin.skold@mysql.com-20101014082627-jrmy9xbfbtrebw3c) (version source revid:martin.skold@mysql.com-20101014082627-jrmy9xbfbtrebw3c) (merge vers: 5.1.51-ndb-7.0.20) (pib:21)
[14 Oct 2010 8:41] Bugs System
Pushed into mysql-5.1-telco-6.3 5.1.51-ndb-6.3.39 (revid:martin.skold@mysql.com-20101014083757-5qo48b86d69zjvzj) (version source revid:martin.skold@mysql.com-20101014083757-5qo48b86d69zjvzj) (merge vers: 5.1.51-ndb-6.3.39) (pib:21)
[14 Oct 2010 8:56] Bugs System
Pushed into mysql-5.1-telco-6.2 5.1.51-ndb-6.2.19 (revid:martin.skold@mysql.com-20101014084420-y54ecj85j5we27oa) (version source revid:martin.skold@mysql.com-20101014084420-y54ecj85j5we27oa) (merge vers: 5.1.51-ndb-6.2.19) (pib:21)
[14 Oct 2010 14:28] Jon Stephens
Closed; see comment from Paul.