Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

bk commit into 5.0 tree (msvensson:1.2540)

From: <msvensson(at)mysql.com>
Date: Wed Oct 31 2007 - 13:44:37 EDT


Below is the list of changes that have just been committed into a local 5.0 repository of msvensson. When msvensson 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@1.2540, 2007-10-31 18:44:31+01:00, msvensson@pilot.mysql.com +3 -0   Backport mysqltests "change_user" command

  client/mysqltest.c@1.310, 2007-10-31 18:44:27+01:00, msvensson@pilot.mysql.com +66 -1     Backport mysqltests "change_user" command

  mysql-test/r/mysqltest.result@1.57, 2007-10-31 18:44:28+01:00, msvensson@pilot.mysql.com +3 -0     Backport mysqltests "change_user" command

  mysql-test/t/mysqltest.test@1.70, 2007-10-31 18:44:28+01:00, msvensson@pilot.mysql.com +19 -0     Backport mysqltests "change_user" command

diff -Nrup a/client/mysqltest.c b/client/mysqltest.c
--- a/client/mysqltest.c	2007-10-05 18:18:47 +02:00
+++ b/client/mysqltest.c	2007-10-31 18:44:27 +01:00
@@ -277,7 +277,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. */
@@ -366,6 +366,7 @@ const char *command_names[]=
   "cat_file",
   "diff_files",
   "send_quit",

+ "change_user",

   0
 };  

@@ -3048,6 +3049,69 @@ void do_send_quit(struct st_command *com  

 /*
   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 (cur_con->stmt)
+ {
+ mysql_stmt_close(cur_con->stmt);
+ cur_con->stmt= NULL;
+ }
+

+ 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  
Do you need help?X

@@ -6852,6 +6916,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/mysqltest.result b/mysql-test/r/mysqltest.result --- a/mysql-test/r/mysqltest.result 2007-08-13 15:46:10 +02:00 +++ b/mysql-test/r/mysqltest.result 2007-10-31 18:44:28 +01:00 @@ -722,4 +722,7 @@ a int(11) YES NULL b varchar(255) YES NULL c datetime YES NULL

 drop table t1;
+mysqltest: At line 1: change user failed: Unknown database 'inexistent'
+mysqltest: At line 1: change user failed: Access denied for user 'inexistent'@'localhost' (using password: NO)
+mysqltest: At line 1: change user failed: Access denied for user 'root'@'localhost' (using password: YES)
 End of tests
diff -Nrup a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test
--- a/mysql-test/t/mysqltest.test	2007-10-05 19:28:07 +02:00
+++ b/mysql-test/t/mysqltest.test	2007-10-31 18:44:28 +01:00
@@ -2083,5 +2083,24 @@ eval $show_statement;  

 drop table t1;  

+# ----------------------------------------------------------------------------
+# Test change_user command
+# ----------------------------------------------------------------------------
Do you need more help?X
+ +--error 1 +--exec echo "--change_user root,,inexistent" | $MYSQL_TEST 2>&1 + +--error 1 +--exec echo "--change_user inexistent,,test" | $MYSQL_TEST 2>&1 + +--error 1 +--exec echo "--change_user root,inexistent,test" | $MYSQL_TEST 2>&1 + +--change_user +--change_user root +--change_user root,, +--change_user root,,test

+
+
 --echo End of tests  
-- 
MySQL Code Commits Mailing List
For list archives: 
http://lists.mysql.com/commits
To unsubscribe:    
http://lists.mysql.com/commits?unsub=lists@pantek.com
Received on Wed Oct 31 13:45:05 2007

This archive was generated by hypermail 2.1.8 : Thu Jul 03 2008 - 11:13:22 EDT


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library