diff options
author | unknown <davi@moksha.com.br> | 2007-10-16 12:29:22 -0300 |
---|---|---|
committer | unknown <davi@moksha.com.br> | 2007-10-16 12:29:22 -0300 |
commit | 88e5aa69f786c25bde3b895230bd3c04c3aa717b (patch) | |
tree | 2d2446c78221432deb6a2ba3a50f9236a3549280 /client/mysqltest.c | |
parent | 73458352133ac1d2660e60e84b96d3659cff399a (diff) | |
download | mariadb-git-88e5aa69f786c25bde3b895230bd3c04c3aa717b.tar.gz |
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:
Add change_user command to mysqltest.
mysql-test/r/mysqltest.result:
Add test case result for change_user command
mysql-test/t/mysqltest.test:
Add test case for change_user command
mysql-test/r/change_user.result:
Add new file with test case results for bugs 20023 and 31418.
mysql-test/t/change_user.test:
Add new file with test cases for bugs 20023 and 31418.
Diffstat (limited to 'client/mysqltest.c')
-rw-r--r-- | client/mysqltest.c | 61 |
1 files changed, 60 insertions, 1 deletions
diff --git a/client/mysqltest.c b/client/mysqltest.c index 702eab0078f..7a84ec8cf40 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -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 *command) /* SYNOPSIS + do_change_user + command called command + + DESCRIPTION + change_user [<user>], [<passwd>], [<db>] + <user> - user to change to + <passwd> - user password + <db> - default database + + Changes the user and causes the database specified by db to become + the default (current) database for the the current connection. + +*/ + +void do_change_user(struct st_command *command) +{ + MYSQL *mysql = &cur_con->mysql; + /* static keyword to make the NetWare compiler happy. */ + static DYNAMIC_STRING ds_user, ds_passwd, ds_db; + const struct command_arg change_user_args[] = { + { "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 (!ds_user.length) + dynstr_set(&ds_user, mysql->user); + + if (!ds_passwd.length) + dynstr_set(&ds_passwd, mysql->passwd); + + if (!ds_db.length) + dynstr_set(&ds_db, mysql->db); + + DBUG_PRINT("info",("connection: '%s' user: '%s' password: '%s' database: '%s'", + cur_con->name, ds_user.str, ds_passwd.str, ds_db.str)); + + if (mysql_change_user(mysql, ds_user.str, ds_passwd.str, ds_db.str)) + die("change user failed: %s", mysql_error(mysql)); + + 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; |