#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, mysql-test will attach to it.
The fix is to use TCP connections, as port number for mtr is unique. In mtr scripts,
this setting can be overwritten with connect(<something>,,,NAMEDPIPE) or
connect(<something>,,,SHM)
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 14:50:58 +0000
@@ -4903,6 +4903,10 @@ void do_connect(struct st_command *comma
int con_port= opt_port;
char *con_options;
my_bool con_ssl= 0, con_compress= 0;
+#ifdef _WIN32
+ my_bool con_namedpipe= 0, con_shm= 0;
+#endif
+
struct st_connection* con_slot;
static DYNAMIC_STRING ds_connection_name;
@@ -4978,6 +4982,12 @@ void do_connect(struct st_command *comma
con_ssl= 1;
else if (!strncmp(con_options, "COMPRESS", 8))
con_compress= 1;
+#ifdef _WIN32
+ else if (!strncmp(con_options, "NAMEDPIPE", 9))
+ con_namedpipe= 1;
+ else if (!strncmp(con_options, "SHM", 3))
+ con_shm= 1;
+#endif
else
die("Illegal option to connect: %.*s",
(int) (end - con_options), con_options);
@@ -5011,6 +5021,18 @@ void do_connect(struct st_command *comma
mysql_options(&con_slot->mysql, MYSQL_SET_CHARSET_DIR,
opt_charsets_dir);
+#ifdef _WIN32
+ uint proto;
+ if (con_namedpipe)
+ proto= MYSQL_PROTOCOL_PIPE;
+ else if (con_shm)
+ proto= MYSQL_PROTOCOL_MEMORY;
+ else
+ proto= MYSQL_PROTOCOL_TCP;
+
+ mysql_options(&con_slot->mysql, MYSQL_OPT_PROTOCOL, (char *)&proto);
+#endif
+
#ifdef HAVE_OPENSSL
if (opt_use_ssl || con_ssl)
{
@@ -7661,6 +7683,16 @@ int main(int argc, char **argv)
}
#endif
+#ifdef _WIN32
+ /*
+ Prevent connecting to installed instances via shared memory
+ */
+ {
+ uint protocol= MYSQL_PROTOCOL_TCP;
+ mysql_options(&con->mysql,MYSQL_OPT_PROTOCOL,(char*)&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 14:50:58 +0000
@@ -10,5 +10,8 @@ if (`SELECT '$nmp' != 'ON'`){
}
# Source select test case
+connect (con1,localhost,root,,,,,NAMEDPIPE);
+connection con1;
-- source include/common-tests.inc
+disconnect con1;
Attachment: [text/bzr-bundle] bzr/vvaintroub@mysql.com-20090927145058-whbsdn51simroyo0.bundle