Below is the list of changes that have just been committed into a local
5.1 repository of davi. When davi does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-10-15 11:46:55-03:00, davi@stripped +3 -0
Bug#31608 missing mysqltest change_user command
The problem is that currently there is no way to test the behavior
of the mysql_change_user() function using the mysqltest suite because
there is no internal command for it.
The solution is to introduce a change_user command that can be used
to test aspects of the MySQL client function mysql_change_user().
client/mysqltest.c@stripped, 2007-10-15 11:46:52-03:00, davi@stripped +60 -1
Add change_user command to mysqltest.
mysql-test/r/change_user.result@stripped, 2007-10-15 11:46:52-03:00, davi@stripped +46 -0
Add new file with test case results for bugs 20023 and 31418.
mysql-test/r/change_user.result@stripped, 2007-10-15 11:46:52-03:00, davi@stripped +0 -0
mysql-test/t/change_user.test@stripped, 2007-10-15 11:46:53-03:00, davi@stripped +35 -0
Add new file with test cases for bugs 20023 and 31418.
mysql-test/t/change_user.test@stripped, 2007-10-15 11:46:53-03:00, davi@stripped +0 -0
diff -Nrup a/client/mysqltest.c b/client/mysqltest.c
--- a/client/mysqltest.c 2007-09-30 17:16:47 -03:00
+++ b/client/mysqltest.c 2007-10-15 11:46:52 -03:00
@@ -263,7 +263,7 @@ enum enum_commands {
Q_REPLACE_REGEX, Q_REMOVE_FILE, Q_FILE_EXIST,
Q_WRITE_FILE, Q_COPY_FILE, Q_PERL, Q_DIE, Q_EXIT, Q_SKIP,
Q_CHMOD_FILE, Q_APPEND_FILE, Q_CAT_FILE, Q_DIFF_FILES,
- Q_SEND_QUIT,
+ Q_SEND_QUIT, Q_CHANGE_USER,
Q_UNKNOWN, /* Unknown command. */
Q_COMMENT, /* Comments, ignored. */
@@ -352,6 +352,7 @@ const char *command_names[]=
"cat_file",
"diff_files",
"send_quit",
+ "change_user",
0
};
@@ -3030,6 +3031,63 @@ void do_send_quit(struct st_command *com
/*
SYNOPSIS
+ do_change_user
+ command called command
+
+ DESCRIPTION
+ Changes the user and causes the database specified by db to become
+ the default (current) database for the named connection.
+
+*/
+
+void do_change_user(struct st_command *command)
+{
+ struct st_connection *con;
+ DYNAMIC_STRING ds_conn, ds_user, ds_passwd, ds_db;
+ const struct command_arg change_user_args[] = {
+ { "connection name", ARG_STRING, TRUE, &ds_conn, "Name of the connection" },
+ { "user", ARG_STRING, FALSE, &ds_user, "User to connect as" },
+ { "password", ARG_STRING, FALSE, &ds_passwd, "Password used when connecting" },
+ { "database", ARG_STRING, FALSE, &ds_db, "Database to select after connect" },
+ };
+
+ DBUG_ENTER("do_change_user");
+
+ check_command_args(command, command->first_argument,
+ change_user_args,
+ sizeof(change_user_args)/sizeof(struct command_arg),
+ ',');
+
+ if (!(con= find_connection_by_name(ds_conn.str)))
+ die("connection '%s' not found in connection pool", ds_conn.str);
+
+ if (!ds_user.length)
+ dynstr_append(&ds_user, con->mysql.user);
+
+ if (!ds_passwd.length)
+ dynstr_append(&ds_passwd, con->mysql.passwd);
+
+ if (!ds_db.length)
+ dynstr_append(&ds_db, con->mysql.db);
+
+ DBUG_PRINT("info",("connection: '%s' user: '%s' password: '%s' "
+ "database: '%s'", ds_conn.str, ds_user.str,
+ ds_passwd.str, ds_db.str));
+
+ if (mysql_change_user(&con->mysql, ds_user.str, ds_passwd.str, ds_db.str))
+ die("change user failed: %s", mysql_error(&con->mysql));
+
+ dynstr_free(&ds_conn);
+ dynstr_free(&ds_user);
+ dynstr_free(&ds_passwd);
+ dynstr_free(&ds_db);
+
+ DBUG_VOID_RETURN;
+}
+
+
+/*
+ SYNOPSIS
do_perl
command command handle
@@ -6836,6 +6894,7 @@ int main(int argc, char **argv)
case Q_APPEND_FILE: do_append_file(command); break;
case Q_DIFF_FILES: do_diff_files(command); break;
case Q_SEND_QUIT: do_send_quit(command); break;
+ case Q_CHANGE_USER: do_change_user(command); break;
case Q_CAT_FILE: do_cat_file(command); break;
case Q_COPY_FILE: do_copy_file(command); break;
case Q_CHMOD_FILE: do_chmod_file(command); break;
diff -Nrup a/mysql-test/r/change_user.result b/mysql-test/r/change_user.result
--- /dev/null Wed Dec 31 16:00:00 196900
+++ b/mysql-test/r/change_user.result 2007-10-15 11:46:52 -03:00
@@ -0,0 +1,46 @@
+Bug#20023
+SELECT @@session.sql_big_selects;
+@@session.sql_big_selects
+1
+SELECT @@global.max_join_size;
+@@global.max_join_size
+-1
+change_user
+SELECT @@session.sql_big_selects;
+@@session.sql_big_selects
+1
+SELECT @@global.max_join_size;
+@@global.max_join_size
+-1
+SET @@global.max_join_size = 10000;
+SET @@session.max_join_size = default;
+change_user
+SELECT @@session.sql_big_selects;
+@@session.sql_big_selects
+0
+SET @@global.max_join_size = -1;
+SET @@session.max_join_size = default;
+change_user
+SELECT @@session.sql_big_selects;
+@@session.sql_big_selects
+1
+Bug#31418
+SELECT IS_FREE_LOCK('bug31418');
+IS_FREE_LOCK('bug31418')
+1
+SELECT IS_USED_LOCK('bug31418');
+IS_USED_LOCK('bug31418')
+NULL
+SELECT GET_LOCK('bug31418', 1);
+GET_LOCK('bug31418', 1)
+1
+SELECT IS_USED_LOCK('bug31418');
+IS_USED_LOCK('bug31418')
+1
+change_user
+SELECT IS_FREE_LOCK('bug31418');
+IS_FREE_LOCK('bug31418')
+1
+SELECT IS_USED_LOCK('bug31418');
+IS_USED_LOCK('bug31418')
+NULL
diff -Nrup a/mysql-test/t/change_user.test b/mysql-test/t/change_user.test
--- /dev/null Wed Dec 31 16:00:00 196900
+++ b/mysql-test/t/change_user.test 2007-10-15 11:46:53 -03:00
@@ -0,0 +1,35 @@
+#
+# Bug#20023 mysql_change_user() resets the value of SQL_BIG_SELECTS
+#
+
+--echo Bug#20023
+SELECT @@session.sql_big_selects;
+SELECT @@global.max_join_size;
+--echo change_user
+--change_user default
+SELECT @@session.sql_big_selects;
+SELECT @@global.max_join_size;
+SET @@global.max_join_size = 10000;
+SET @@session.max_join_size = default;
+--echo change_user
+--change_user default
+SELECT @@session.sql_big_selects;
+SET @@global.max_join_size = -1;
+SET @@session.max_join_size = default;
+--echo change_user
+--change_user default
+SELECT @@session.sql_big_selects;
+
+#
+# Bug#31418 User locks misfunctioning after mysql_change_user()
+#
+
+--echo Bug#31418
+SELECT IS_FREE_LOCK('bug31418');
+SELECT IS_USED_LOCK('bug31418');
+SELECT GET_LOCK('bug31418', 1);
+SELECT IS_USED_LOCK('bug31418');
+--echo change_user
+--change_user default
+SELECT IS_FREE_LOCK('bug31418');
+SELECT IS_USED_LOCK('bug31418');