List:Commits« Previous MessageNext Message »
From:Davi Arnaut Date:October 16 2007 2:52pm
Subject:Re: bk commit into 5.1 tree (davi:1.2599) BUG#31608
View as plain text  
Magnus Svensson wrote:
> mån 2007-10-15 klockan 11:47 -0300 skrev Davi Arnaut:

[..]

>>  /*
>>    SYNOPSIS
>> +  do_change_user
>> +  command       called command
>> +
>> +  DESCRIPTION
> magnus: Add the description of the new mysqltest command here(docs team
> will ask about it...)
> 
>      change_user [<user>], [<passwd>], [<db>]

Ok.

>> +  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;
> magnus: You better use the "static" keyword word or our NetWare compiler
> will fail. :(
>      static DYNAMIC_STRING ds_conn, ds_user, ds_passwd, ds_db;

Ok, and I will add a comment. I was wondering why the others had the
static keyword..

>> +  const struct command_arg change_user_args[] = {
>> +    { "connection name", ARG_STRING, TRUE, &ds_conn, "Name of the
> connection" },
> 
> magnus: No need to specify the connection name as part of the command,
> all comands work with current connection.

Ok.

>> +    { "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);
> 
> magnus: Thus drop this ^

Ok.

>> +
>> +  if (!ds_user.length)
>> +    dynstr_append(&ds_user, con->mysql.user);
> 
> magnus:
>     dynstr_set(&ds_user, cur_con->mysql.user);
>     and same for the two below

Ok.

>> +
>> +  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));
> 
> magnus: Use "cur_con" instead of con.

Ok.

>> +
>> +  dynstr_free(&ds_conn);
>> +  dynstr_free(&ds_user);
>> +  dynstr_free(&ds_passwd);
>> +  dynstr_free(&ds_db);
>> +
>> +  DBUG_VOID_RETURN;
>> +}

[..]

> 
> Please also add some tests to mysql-test/t/mysqltest.test for the new
> command. That way it's behaviour is documented by tests.

Ok, thanks for the review.

Regards,

-- 
Davi Arnaut, Software Engineer
MySQL Inc, www.mysql.com

Are you MySQL certified?  www.mysql.com/certification

Thread
bk commit into 5.1 tree (davi:1.2599) BUG#31608Davi Arnaut15 Oct
  • Re: bk commit into 5.1 tree (davi:1.2599) BUG#31608Konstantin Osipov15 Oct
  • Re: bk commit into 5.1 tree (davi:1.2599) BUG#31608Magnus Svensson16 Oct
    • Re: bk commit into 5.1 tree (davi:1.2599) BUG#31608Davi Arnaut16 Oct