Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
eea87d9e
Commit
eea87d9e
authored
Oct 17, 2007
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge moksha.com.br:/Users/davi/mysql/bugs/31608-5.1
into moksha.com.br:/Users/davi/mysql/mysql-5.1-runtime
parents
3fe4de96
88e5aa69
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
162 additions
and
1 deletion
+162
-1
client/mysqltest.c
client/mysqltest.c
+60
-1
mysql-test/r/change_user.result
mysql-test/r/change_user.result
+46
-0
mysql-test/r/mysqltest.result
mysql-test/r/mysqltest.result
+3
-0
mysql-test/t/change_user.test
mysql-test/t/change_user.test
+35
-0
mysql-test/t/mysqltest.test
mysql-test/t/mysqltest.test
+18
-0
No files found.
client/mysqltest.c
View file @
eea87d9e
...
@@ -263,7 +263,7 @@ enum enum_commands {
...
@@ -263,7 +263,7 @@ enum enum_commands {
Q_REPLACE_REGEX
,
Q_REMOVE_FILE
,
Q_FILE_EXIST
,
Q_REPLACE_REGEX
,
Q_REMOVE_FILE
,
Q_FILE_EXIST
,
Q_WRITE_FILE
,
Q_COPY_FILE
,
Q_PERL
,
Q_DIE
,
Q_EXIT
,
Q_SKIP
,
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_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_UNKNOWN
,
/* Unknown command. */
Q_COMMENT
,
/* Comments, ignored. */
Q_COMMENT
,
/* Comments, ignored. */
...
@@ -352,6 +352,7 @@ const char *command_names[]=
...
@@ -352,6 +352,7 @@ const char *command_names[]=
"cat_file"
,
"cat_file"
,
"diff_files"
,
"diff_files"
,
"send_quit"
,
"send_quit"
,
"change_user"
,
0
0
};
};
...
@@ -3028,6 +3029,63 @@ void do_send_quit(struct st_command *command)
...
@@ -3028,6 +3029,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
SYNOPSIS
do_perl
do_perl
...
@@ -6836,6 +6894,7 @@ int main(int argc, char **argv)
...
@@ -6836,6 +6894,7 @@ int main(int argc, char **argv)
case
Q_APPEND_FILE
:
do_append_file
(
command
);
break
;
case
Q_APPEND_FILE
:
do_append_file
(
command
);
break
;
case
Q_DIFF_FILES
:
do_diff_files
(
command
);
break
;
case
Q_DIFF_FILES
:
do_diff_files
(
command
);
break
;
case
Q_SEND_QUIT
:
do_send_quit
(
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_CAT_FILE
:
do_cat_file
(
command
);
break
;
case
Q_COPY_FILE
:
do_copy_file
(
command
);
break
;
case
Q_COPY_FILE
:
do_copy_file
(
command
);
break
;
case
Q_CHMOD_FILE
:
do_chmod_file
(
command
);
break
;
case
Q_CHMOD_FILE
:
do_chmod_file
(
command
);
break
;
...
...
mysql-test/r/change_user.result
0 → 100644
View file @
eea87d9e
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
mysql-test/r/mysqltest.result
View file @
eea87d9e
...
@@ -722,4 +722,7 @@ a int(11) YES NULL
...
@@ -722,4 +722,7 @@ a int(11) YES NULL
b varchar(255) YES NULL
b varchar(255) YES NULL
c datetime YES NULL
c datetime YES NULL
drop table t1;
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
End of tests
mysql-test/t/change_user.test
0 → 100644
View file @
eea87d9e
#
# 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
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
SELECT
@@
session
.
sql_big_selects
;
SET
@@
global
.
max_join_size
=
-
1
;
SET
@@
session
.
max_join_size
=
default
;
--
echo
change_user
--
change_user
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
SELECT
IS_FREE_LOCK
(
'bug31418'
);
SELECT
IS_USED_LOCK
(
'bug31418'
);
mysql-test/t/mysqltest.test
View file @
eea87d9e
...
@@ -2080,5 +2080,23 @@ eval $show_statement;
...
@@ -2080,5 +2080,23 @@ eval $show_statement;
drop
table
t1
;
drop
table
t1
;
# ----------------------------------------------------------------------------
# Test change_user command
# ----------------------------------------------------------------------------
--
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
--
echo
End
of
tests
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment