summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMagnus Svensson <msvensson@mysql.com>2009-01-15 09:05:51 +0100
committerMagnus Svensson <msvensson@mysql.com>2009-01-15 09:05:51 +0100
commitbb42e1ab05f9ebe166524d7d8a25c55a69e65dfa (patch)
tree15233f6fb7d4aebb9bc4e084ab8116c465b9616a
parentd20aba9409a5cbd7b27df8ac9da31858b1bc5a84 (diff)
downloadmariadb-git-bb42e1ab05f9ebe166524d7d8a25c55a69e65dfa.tar.gz
Bug#35701 please allow test language variables in connection and
sync_slave_with_master - Additional patch for "disconnect $variable"
-rw-r--r--client/mysqltest.cc34
-rw-r--r--mysql-test/r/mysqltest.result10
-rw-r--r--mysql-test/t/mysqltest.test8
3 files changed, 36 insertions, 16 deletions
diff --git a/client/mysqltest.cc b/client/mysqltest.cc
index 52953ba4618..adc7a9be161 100644
--- a/client/mysqltest.cc
+++ b/client/mysqltest.cc
@@ -4507,24 +4507,23 @@ void select_connection(struct st_command *command)
void do_close_connection(struct st_command *command)
{
- char *p= command->first_argument, *name;
- struct st_connection *con;
-
DBUG_ENTER("close_connection");
- DBUG_PRINT("enter",("name: '%s'",p));
- if (!*p)
- die("Missing connection name in disconnect");
- name= p;
- while (*p && !my_isspace(charset_info,*p))
- p++;
+ struct st_connection *con;
+ static DYNAMIC_STRING ds_connection;
+ const struct command_arg close_connection_args[] = {
+ { "connection_name", ARG_STRING, TRUE, &ds_connection,
+ "Name of the connection to close." }
+ };
+ check_command_args(command, command->first_argument,
+ close_connection_args,
+ sizeof(close_connection_args)/sizeof(struct command_arg),
+ ' ');
- if (*p)
- *p++= 0;
- command->last_argument= p;
+ DBUG_PRINT("enter",("connection name: '%s'", ds_connection.str));
- if (!(con= find_connection_by_name(name)))
- die("connection '%s' not found in connection pool", name);
+ if (!(con= find_connection_by_name(ds_connection.str)))
+ die("connection '%s' not found in connection pool", ds_connection.str);
DBUG_PRINT("info", ("Closing connection %s", con->name));
#ifndef EMBEDDED_LIBRARY
@@ -4563,6 +4562,13 @@ void do_close_connection(struct st_command *command)
if (!(con->name = my_strdup("-closed_connection-", MYF(MY_WME))))
die("Out of memory");
+ if (con == cur_con)
+ {
+ /* Current connection was closed */
+ var_set_int("$mysql_get_server_version", 0xFFFFFFFF);
+ var_set_string("$CURRENT_CONNECTION", con->name);
+ }
+
DBUG_VOID_RETURN;
}
diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result
index 567dd33f0fc..1a65f90bd65 100644
--- a/mysql-test/r/mysqltest.result
+++ b/mysql-test/r/mysqltest.result
@@ -153,8 +153,12 @@ mysqltest: At line 1: Missing delimiter
mysqltest: At line 1: End of line junk detected: "sleep 7
# Another comment
"
-mysqltest: At line 1: Missing delimiter
-mysqltest: At line 1: Missing delimiter
+mysqltest: At line 1: Extra argument 'comment
+# comment 3
+disable_query_log' passed to 'disconnect'
+mysqltest: At line 1: Extra argument 'comment
+# comment 3
+disable_query_log' passed to 'disconnect'
mysqltest: At line 1: End of line junk detected: "disconnect default
#
@@ -745,4 +749,6 @@ default
con1
default
con1
+con1
+-closed_connection-
End of tests
diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test
index ba3f2f5da5e..6c5efba8b5b 100644
--- a/mysql-test/t/mysqltest.test
+++ b/mysql-test/t/mysqltest.test
@@ -2206,6 +2206,14 @@ connection $x;
connection $y;
--echo $CURRENT_CONNECTION
+# Disconnect the not selected connection
+disconnect $x;
+--echo $CURRENT_CONNECTION
+
+# Disconnect the selected connection
+disconnect $y;
+--echo $CURRENT_CONNECTION
+
--echo End of tests