Commit 81bda323 authored by joreland@mysql.com's avatar joreland@mysql.com

Merge joreland@bk-internal.mysql.com:/home/bk/mysql-5.0

into mysql.com:/home/jonas/src/mysql-5.0
parents 0328d3de 7269388d
...@@ -539,8 +539,8 @@ character-set=latin1 ...@@ -539,8 +539,8 @@ character-set=latin1
"Using storage engine %s for table '%s'", "Using storage engine %s for table '%s'",
#define ER_CANT_AGGREGATE_2COLLATIONS 1267 #define ER_CANT_AGGREGATE_2COLLATIONS 1267
"Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", "Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'",
#define ER_DROP_USER 1268 #define ER_HANDLE_USER 1268
"Can't drop one or more of the requested users", "Operation %s failed for %d of the requested users",
#define ER_REVOKE_GRANTS 1269 #define ER_REVOKE_GRANTS 1269
"Can't revoke all privileges, grant for one or more of the requested users", "Can't revoke all privileges, grant for one or more of the requested users",
#define ER_CANT_AGGREGATE_3COLLATIONS 1270 #define ER_CANT_AGGREGATE_3COLLATIONS 1270
......
...@@ -284,7 +284,7 @@ ...@@ -284,7 +284,7 @@
#define ER_WARN_DATA_TRUNCATED 1265 #define ER_WARN_DATA_TRUNCATED 1265
#define ER_WARN_USING_OTHER_HANDLER 1266 #define ER_WARN_USING_OTHER_HANDLER 1266
#define ER_CANT_AGGREGATE_2COLLATIONS 1267 #define ER_CANT_AGGREGATE_2COLLATIONS 1267
#define ER_DROP_USER 1268 #define ER_HANDLE_USER 1268
#define ER_REVOKE_GRANTS 1269 #define ER_REVOKE_GRANTS 1269
#define ER_CANT_AGGREGATE_3COLLATIONS 1270 #define ER_CANT_AGGREGATE_3COLLATIONS 1270
#define ER_CANT_AGGREGATE_NCOLLATIONS 1271 #define ER_CANT_AGGREGATE_NCOLLATIONS 1271
......
...@@ -218,17 +218,19 @@ grant select on test.* to drop_user3@localhost; ...@@ -218,17 +218,19 @@ grant select on test.* to drop_user3@localhost;
grant select on *.* to drop_user4@localhost; grant select on *.* to drop_user4@localhost;
drop user drop_user1@localhost, drop_user2@localhost, drop_user3@localhost, drop user drop_user1@localhost, drop_user2@localhost, drop_user3@localhost,
drop_user4@localhost; drop_user4@localhost;
ERROR HY000: Can't drop one or more of the requested users
revoke all privileges, grant option from drop_user1@localhost, drop_user2@localhost, revoke all privileges, grant option from drop_user1@localhost, drop_user2@localhost,
drop_user3@localhost, drop_user4@localhost; drop_user3@localhost, drop_user4@localhost;
ERROR HY000: Can't revoke all privileges, grant for one or more of the requested users
drop user drop_user1@localhost, drop_user2@localhost, drop_user3@localhost, drop user drop_user1@localhost, drop_user2@localhost, drop_user3@localhost,
drop_user4@localhost; drop_user4@localhost;
ERROR HY000: Operation DROP USER failed for 4 of the requested users
drop table t1; drop table t1;
grant usage on *.* to mysqltest_1@localhost identified by "password"; grant usage on *.* to mysqltest_1@localhost identified by "password";
grant select, update, insert on test.* to mysqltest@localhost; grant select, update, insert on test.* to mysqltest_1@localhost;
show grants for mysqltest_1@localhost; show grants for mysqltest_1@localhost;
Grants for mysqltest_1@localhost Grants for mysqltest_1@localhost
GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' IDENTIFIED BY PASSWORD '*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19' GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' IDENTIFIED BY PASSWORD '*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19'
GRANT SELECT, INSERT, UPDATE ON `test`.* TO 'mysqltest_1'@'localhost'
drop user mysqltest_1@localhost; drop user mysqltest_1@localhost;
SET NAMES koi8r; SET NAMES koi8r;
CREATE DATABASE ; CREATE DATABASE ;
...@@ -252,6 +254,7 @@ Grants for ...@@ -252,6 +254,7 @@ Grants for
GRANT USAGE ON *.* TO ''@'localhost' GRANT USAGE ON *.* TO ''@'localhost'
GRANT SELECT () ON ``.`` TO ''@'localhost' GRANT SELECT () ON ``.`` TO ''@'localhost'
REVOKE SELECT () ON . FROM @localhost; REVOKE SELECT () ON . FROM @localhost;
DROP USER @localhost;
DROP DATABASE ; DROP DATABASE ;
SET NAMES latin1; SET NAMES latin1;
USE test; USE test;
......
...@@ -60,3 +60,165 @@ use test; ...@@ -60,3 +60,165 @@ use test;
delete from mysql.user where user like 'mysqltest\_%'; delete from mysql.user where user like 'mysqltest\_%';
delete from mysql.db where user like 'mysqltest\_%'; delete from mysql.db where user like 'mysqltest\_%';
flush privileges; flush privileges;
set sql_mode='maxdb';
drop table if exists t1, t2;
create table t1(c1 int);
create table t2(c1 int, c2 int);
create user 'mysqltest_1';
create user 'mysqltest_1';
ERROR HY000: Operation CREATE USER failed for 1 of the requested users
create user 'mysqltest_2' identified by 'Mysqltest-2';
create user 'mysqltest_3' identified by password 'fffffffffffffffffffffffffffffffffffffffff';
grant select on *.* to 'mysqltest_2';
grant insert on test.* to 'mysqltest_2';
grant update on test.t1 to 'mysqltest_2';
grant update (c2) on test.t2 to 'mysqltest_2';
select host,user,password from mysql.user where user like 'mysqltest_%' order by host,user,password;
host user password
% mysqltest_1
% mysqltest_2 *BD447CBA355AF58578D3AE33BA2E2CD388BA08D1
% mysqltest_3 fffffffffffffffffffffffffffffffffffffffff
select host,db,user from mysql.db where user like 'mysqltest_%' order by host,db,user;
host db user
% test mysqltest_2
select host,db,user,table_name from mysql.tables_priv where user like 'mysqltest_%' order by host,db,user,table_name;
host db user table_name
% test mysqltest_2 t1
% test mysqltest_2 t2
select host,db,user,table_name,column_name from mysql.columns_priv where user like 'mysqltest_%' order by host,db,user,table_name,column_name;
host db user table_name column_name
% test mysqltest_2 t2 c2
show grants for 'mysqltest_1';
Grants for mysqltest_1@%
GRANT USAGE ON *.* TO 'mysqltest_1'@'%'
show grants for 'mysqltest_2';
Grants for mysqltest_2@%
GRANT SELECT ON *.* TO 'mysqltest_2'@'%' IDENTIFIED BY PASSWORD '*BD447CBA355AF58578D3AE33BA2E2CD388BA08D1'
GRANT INSERT ON "test".* TO 'mysqltest_2'@'%'
GRANT UPDATE (c2) ON "test"."t2" TO 'mysqltest_2'@'%'
GRANT UPDATE ON "test"."t1" TO 'mysqltest_2'@'%'
drop user 'mysqltest_1';
select host,user,password from mysql.user where user like 'mysqltest_%' order by host,user,password;
host user password
% mysqltest_2 *BD447CBA355AF58578D3AE33BA2E2CD388BA08D1
% mysqltest_3 fffffffffffffffffffffffffffffffffffffffff
select host,db,user from mysql.db where user like 'mysqltest_%' order by host,db,user;
host db user
% test mysqltest_2
select host,db,user,table_name from mysql.tables_priv where user like 'mysqltest_%' order by host,db,user,table_name;
host db user table_name
% test mysqltest_2 t1
% test mysqltest_2 t2
select host,db,user,table_name,column_name from mysql.columns_priv where user like 'mysqltest_%' order by host,db,user,table_name,column_name;
host db user table_name column_name
% test mysqltest_2 t2 c2
show grants for 'mysqltest_1';
ERROR 42000: There is no such grant defined for user 'mysqltest_1' on host '%'
rename user 'mysqltest_2' to 'mysqltest_1';
select host,user,password from mysql.user where user like 'mysqltest_%' order by host,user,password;
host user password
% mysqltest_1 *BD447CBA355AF58578D3AE33BA2E2CD388BA08D1
% mysqltest_3 fffffffffffffffffffffffffffffffffffffffff
select host,db,user from mysql.db where user like 'mysqltest_%' order by host,db,user;
host db user
% test mysqltest_1
select host,db,user,table_name from mysql.tables_priv where user like 'mysqltest_%' order by host,db,user,table_name;
host db user table_name
% test mysqltest_1 t1
% test mysqltest_1 t2
select host,db,user,table_name,column_name from mysql.columns_priv where user like 'mysqltest_%' order by host,db,user,table_name,column_name;
host db user table_name column_name
% test mysqltest_1 t2 c2
show grants for 'mysqltest_1';
Grants for mysqltest_1@%
GRANT SELECT ON *.* TO 'mysqltest_1'@'%' IDENTIFIED BY PASSWORD '*BD447CBA355AF58578D3AE33BA2E2CD388BA08D1'
GRANT INSERT ON "test".* TO 'mysqltest_1'@'%'
GRANT UPDATE (c2) ON "test"."t2" TO 'mysqltest_1'@'%'
GRANT UPDATE ON "test"."t1" TO 'mysqltest_1'@'%'
drop user 'mysqltest_1', 'mysqltest_3';
grant all on test.t1 to 'mysqltest_1';
ERROR 42000: 'root'@'localhost' is not allowed to create new users
drop user 'mysqltest_1';
ERROR HY000: Operation DROP USER failed for 1 of the requested users
drop table t1, t2;
insert into mysql.db set user='mysqltest_1', db='%', host='%';
flush privileges;
show grants for 'mysqltest_1';
ERROR 42000: There is no such grant defined for user 'mysqltest_1' on host '%'
revoke all privileges, grant option from 'mysqltest_1';
ERROR HY000: Can't revoke all privileges, grant for one or more of the requested users
drop user 'mysqltest_1';
select host,db,user from mysql.db where user = 'mysqltest_1' order by host,db,user;
host db user
insert into mysql.tables_priv set host='%', db='test', user='mysqltest_1', table_name='t1';
flush privileges;
show grants for 'mysqltest_1';
ERROR 42000: There is no such grant defined for user 'mysqltest_1' on host '%'
drop user 'mysqltest_1';
select host,db,user,table_name from mysql.tables_priv where user = 'mysqltest_1' order by host,db,user,table_name;
host db user table_name
insert into mysql.columns_priv set host='%', db='test', user='mysqltest_1', table_name='t1', column_name='c1';
flush privileges;
show grants for 'mysqltest_1';
ERROR 42000: There is no such grant defined for user 'mysqltest_1' on host '%'
drop user 'mysqltest_1';
select host,db,user,table_name,column_name from mysql.columns_priv where user = 'mysqltest_1' order by host,db,user,table_name,column_name;
host db user table_name column_name
create user 'mysqltest_1', 'mysqltest_2', 'mysqltest_3';
drop user 'mysqltest_1', 'mysqltest_2', 'mysqltest_3';
create user 'mysqltest_1', 'mysqltest_2' identified by 'Mysqltest-2', 'mysqltest_3' identified by password 'fffffffffffffffffffffffffffffffffffffffff';
rename user 'mysqltest_1' to 'mysqltest_1a', 'mysqltest_2' TO 'mysqltest_2a', 'mysqltest_3' TO 'mysqltest_3a';
drop user 'mysqltest_1', 'mysqltest_2', 'mysqltest_3';
ERROR HY000: Operation DROP USER failed for 3 of the requested users
drop user 'mysqltest_1a', 'mysqltest_2a', 'mysqltest_3a';
create user 'mysqltest_1', 'mysqltest_2', 'mysqltest_3';
create user 'mysqltest_1a', 'mysqltest_2', 'mysqltest_3a';
ERROR HY000: Operation CREATE USER failed for 1 of the requested users
rename user 'mysqltest_1a' to 'mysqltest_1b', 'mysqltest_2a' TO 'mysqltest_2b', 'mysqltest_3a' TO 'mysqltest_3b';
ERROR HY000: Operation RENAME USER failed for 1 of the requested users
drop user 'mysqltest_1', 'mysqltest_2', 'mysqltest_3';
drop user 'mysqltest_1b', 'mysqltest_2b', 'mysqltest_3b';
ERROR HY000: Operation DROP USER failed for 1 of the requested users
create user 'mysqltest_2' identified by 'Mysqltest-2';
drop user 'mysqltest_2' identified by 'Mysqltest-2';
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'identified by 'Mysqltest-2'' at line 1
create user '%@b'@'b';
show grants for '%@b'@'b';
Grants for %@b@b
GRANT USAGE ON *.* TO '%@b'@'b'
grant select on mysql.* to '%@b'@'b';
show grants for '%@b'@'b';
Grants for %@b@b
GRANT USAGE ON *.* TO '%@b'@'b'
GRANT SELECT ON "mysql".* TO '%@b'@'b'
rename user '%@b'@'b' to '%@a'@'a';
show grants for '%@b'@'b';
ERROR 42000: There is no such grant defined for user '%@b' on host 'b'
show grants for '%@a'@'a';
Grants for %@a@a
GRANT USAGE ON *.* TO '%@a'@'a'
GRANT SELECT ON "mysql".* TO '%@a'@'a'
drop user '%@a'@'a';
create user mysqltest_2@localhost;
grant usage on *.* to mysqltest_2@localhost with grant option;
select host,user,password from mysql.user where user like 'mysqltest_%' order by host,user,password;
ERROR 42000: Access denied for user 'mysqltest_2'@'localhost' to database 'mysql'
create user mysqltest_A@'%';
rename user mysqltest_A@'%' to mysqltest_B@'%';
drop user mysqltest_B@'%';
drop user mysqltest_2@localhost;
create user mysqltest_3@localhost;
grant all privileges on mysql.* to mysqltest_3@localhost;
select host,user,password from mysql.user where user like 'mysqltest_%' order by host,user,password;
host user password
% mysqltest_2 *BD447CBA355AF58578D3AE33BA2E2CD388BA08D1
localhost mysqltest_3
insert into mysql.user set host='%', user='mysqltest_B';
create user mysqltest_A@'%';
ERROR 42000: Access denied for user 'mysqltest_3'@'localhost' to database 'mysql'
rename user mysqltest_B@'%' to mysqltest_C@'%';
ERROR 42000: Access denied for user 'mysqltest_3'@'localhost' to database 'mysql'
drop user mysqltest_B@'%';
ERROR 42000: Access denied for user 'mysqltest_3'@'localhost' to database 'mysql'
drop user mysqltest_B@'%';
drop user mysqltest_3@localhost;
...@@ -252,7 +252,7 @@ sel2 sel2 ...@@ -252,7 +252,7 @@ sel2 sel2
select count(*) from information_schema.ROUTINES; select count(*) from information_schema.ROUTINES;
count(*) count(*)
2 2
create view v0 (c) as select schema_name from information_schema.SCHEMATA; create view v0 (c) as select schema_name from information_schema.schemata;
select * from v0; select * from v0;
c c
mysql mysql
...@@ -260,22 +260,22 @@ test ...@@ -260,22 +260,22 @@ test
explain select * from v0; explain select * from v0;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY # ALL NULL NULL NULL NULL 2 1 PRIMARY # ALL NULL NULL NULL NULL 2
create view v1 (c) as select table_name from information_schema.TABLES create view v1 (c) as select table_name from information_schema.tables
where table_name="v1"; where table_name="v1";
select * from v1; select * from v1;
c c
v1 v1
create view v2 (c) as select column_name from information_schema.COLUMNS create view v2 (c) as select column_name from information_schema.columns
where table_name="v2"; where table_name="v2";
select * from v2; select * from v2;
c c
c c
create view v3 (c) as select CHARACTER_SET_NAME from information_schema.CHARACTER_SETS create view v3 (c) as select CHARACTER_SET_NAME from information_schema.character_sets
where CHARACTER_SET_NAME like "latin1%"; where CHARACTER_SET_NAME like "latin1%";
select * from v3; select * from v3;
c c
latin1 latin1
create view v4 (c) as select COLLATION_NAME from information_schema.COLLATIONS create view v4 (c) as select COLLATION_NAME from information_schema.collations
where COLLATION_NAME like "latin1%"; where COLLATION_NAME like "latin1%";
select * from v4; select * from v4;
c c
...@@ -289,13 +289,13 @@ latin1_general_cs ...@@ -289,13 +289,13 @@ latin1_general_cs
latin1_spanish_ci latin1_spanish_ci
show keys from v4; show keys from v4;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
select * from information_schema.VIEWS where TABLE_NAME like "v%"; select * from information_schema.views where TABLE_NAME like "v%";
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE
NULL test v0 select `SCHEMATA`.`SCHEMA_NAME` AS `c` from `information_schema`.`SCHEMATA` NONE NO NULL test v0 select `schemata`.`SCHEMA_NAME` AS `c` from `information_schema`.`schemata` NONE NO
NULL test v1 select `TABLES`.`TABLE_NAME` AS `c` from `information_schema`.`TABLES` where (`TABLES`.`TABLE_NAME` = _utf8'v1') NONE NO NULL test v1 select `tables`.`TABLE_NAME` AS `c` from `information_schema`.`tables` where (`tables`.`TABLE_NAME` = _utf8'v1') NONE NO
NULL test v2 select `COLUMNS`.`COLUMN_NAME` AS `c` from `information_schema`.`COLUMNS` where (`COLUMNS`.`TABLE_NAME` = _utf8'v2') NONE NO NULL test v2 select `columns`.`COLUMN_NAME` AS `c` from `information_schema`.`columns` where (`columns`.`TABLE_NAME` = _utf8'v2') NONE NO
NULL test v3 select `CHARACTER_SETS`.`CHARACTER_SET_NAME` AS `c` from `information_schema`.`CHARACTER_SETS` where (`CHARACTER_SETS`.`CHARACTER_SET_NAME` like _utf8'latin1%') NONE NO NULL test v3 select `character_sets`.`CHARACTER_SET_NAME` AS `c` from `information_schema`.`character_sets` where (`character_sets`.`CHARACTER_SET_NAME` like _utf8'latin1%') NONE NO
NULL test v4 select `COLLATIONS`.`COLLATION_NAME` AS `c` from `information_schema`.`COLLATIONS` where (`COLLATIONS`.`COLLATION_NAME` like _utf8'latin1%') NONE NO NULL test v4 select `collations`.`COLLATION_NAME` AS `c` from `information_schema`.`collations` where (`collations`.`COLLATION_NAME` like _utf8'latin1%') NONE NO
drop view v0, v1, v2, v3, v4; drop view v0, v1, v2, v3, v4;
create table t1 (a int); create table t1 (a int);
grant select,update,insert on t1 to mysqltest_1@localhost; grant select,update,insert on t1 to mysqltest_1@localhost;
...@@ -434,18 +434,18 @@ information_schema.tables; ...@@ -434,18 +434,18 @@ information_schema.tables;
s1 s1
9 9
drop table t1; drop table t1;
SHOW CREATE TABLE INFORMATION_SCHEMA.CHARACTER_SETS; SHOW CREATE TABLE INFORMATION_SCHEMA.character_sets;
Table Create Table Table Create Table
CHARACTER_SETS CREATE TEMPORARY TABLE `CHARACTER_SETS` ( character_sets CREATE TEMPORARY TABLE `character_sets` (
`CHARACTER_SET_NAME` char(30) NOT NULL default '', `CHARACTER_SET_NAME` char(30) NOT NULL default '',
`DESCRIPTION` char(60) NOT NULL default '', `DESCRIPTION` char(60) NOT NULL default '',
`DEFAULT_COLLATE_NAME` char(60) NOT NULL default '', `DEFAULT_COLLATE_NAME` char(60) NOT NULL default '',
`MAXLEN` bigint(3) NOT NULL default '0' `MAXLEN` bigint(3) NOT NULL default '0'
) ENGINE=HEAP DEFAULT CHARSET=utf8 MAX_ROWS=2282 ) ENGINE=HEAP DEFAULT CHARSET=utf8 MAX_ROWS=2282
set names latin2; set names latin2;
SHOW CREATE TABLE INFORMATION_SCHEMA.CHARACTER_SETS; SHOW CREATE TABLE INFORMATION_SCHEMA.character_sets;
Table Create Table Table Create Table
CHARACTER_SETS CREATE TEMPORARY TABLE `CHARACTER_SETS` ( character_sets CREATE TEMPORARY TABLE `character_sets` (
`CHARACTER_SET_NAME` char(30) NOT NULL default '', `CHARACTER_SET_NAME` char(30) NOT NULL default '',
`DESCRIPTION` char(60) NOT NULL default '', `DESCRIPTION` char(60) NOT NULL default '',
`DEFAULT_COLLATE_NAME` char(60) NOT NULL default '', `DEFAULT_COLLATE_NAME` char(60) NOT NULL default '',
...@@ -517,3 +517,19 @@ from information_schema.columns; open c; open c; end;// ...@@ -517,3 +517,19 @@ from information_schema.columns; open c; open c; end;//
call p108()// call p108()//
ERROR 24000: Cursor is already open ERROR 24000: Cursor is already open
drop procedure p108; drop procedure p108;
create view v1 as select A1.table_name from information_schema.TABLES A1
where table_name= "user";
select * from v1;
table_name
user
drop view v1;
create view vo as select 'a' union select 'a';
show index from vo;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
select * from information_schema.TABLE_CONSTRAINTS where
TABLE_NAME= "vo";
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE CONSTRAINT_METHOD
select * from information_schema.KEY_COLUMN_USAGE where
TABLE_NAME= "vo";
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION REFERENCED_TABLE_SCHEMA REFERENCED_TABLE_NAME REFERENCED_COLUMN_NAME
drop view vo;
...@@ -835,19 +835,19 @@ identified by 'looser' ; ...@@ -835,19 +835,19 @@ identified by 'looser' ;
show grants for second_user@localhost ; show grants for second_user@localhost ;
Grants for second_user@localhost Grants for second_user@localhost
GRANT USAGE ON *.* TO 'second_user'@'localhost' IDENTIFIED BY PASSWORD '*13843FE600B19A81E32AF50D4A6FED25875FF1F3' GRANT USAGE ON *.* TO 'second_user'@'localhost' IDENTIFIED BY PASSWORD '*13843FE600B19A81E32AF50D4A6FED25875FF1F3'
GRANT SELECT ON `mysqltest`.`t9` TO 'second_user'@'localhost'
GRANT SELECT ON `mysqltest`.`t1` TO 'second_user'@'localhost' GRANT SELECT ON `mysqltest`.`t1` TO 'second_user'@'localhost'
GRANT SELECT ON `mysqltest`.`t9` TO 'second_user'@'localhost'
drop table mysqltest.t9 ; drop table mysqltest.t9 ;
show grants for second_user@localhost ; show grants for second_user@localhost ;
Grants for second_user@localhost Grants for second_user@localhost
GRANT USAGE ON *.* TO 'second_user'@'localhost' IDENTIFIED BY PASSWORD '*13843FE600B19A81E32AF50D4A6FED25875FF1F3' GRANT USAGE ON *.* TO 'second_user'@'localhost' IDENTIFIED BY PASSWORD '*13843FE600B19A81E32AF50D4A6FED25875FF1F3'
GRANT SELECT ON `mysqltest`.`t9` TO 'second_user'@'localhost'
GRANT SELECT ON `mysqltest`.`t1` TO 'second_user'@'localhost' GRANT SELECT ON `mysqltest`.`t1` TO 'second_user'@'localhost'
GRANT SELECT ON `mysqltest`.`t9` TO 'second_user'@'localhost'
show grants for second_user@localhost ; show grants for second_user@localhost ;
Grants for second_user@localhost Grants for second_user@localhost
GRANT USAGE ON *.* TO 'second_user'@'localhost' IDENTIFIED BY PASSWORD '*13843FE600B19A81E32AF50D4A6FED25875FF1F3' GRANT USAGE ON *.* TO 'second_user'@'localhost' IDENTIFIED BY PASSWORD '*13843FE600B19A81E32AF50D4A6FED25875FF1F3'
GRANT SELECT ON `mysqltest`.`t9` TO 'second_user'@'localhost'
GRANT SELECT ON `mysqltest`.`t1` TO 'second_user'@'localhost' GRANT SELECT ON `mysqltest`.`t1` TO 'second_user'@'localhost'
GRANT SELECT ON `mysqltest`.`t9` TO 'second_user'@'localhost'
prepare s_t1 from 'select a as my_col from t1' ; prepare s_t1 from 'select a as my_col from t1' ;
execute s_t1 ; execute s_t1 ;
my_col my_col
......
...@@ -460,4 +460,17 @@ end| ...@@ -460,4 +460,17 @@ end|
call bug3294()| call bug3294()|
ERROR 42S02: Unknown table 't5' ERROR 42S02: Unknown table 't5'
drop procedure bug3294| drop procedure bug3294|
drop procedure if exists bug6807|
create procedure bug6807()
begin
declare id int;
set id = connection_id();
kill query id;
select 'Not reached';
end|
call bug6807()|
ERROR 70100: Query execution was interrupted
call bug6807()|
ERROR 70100: Query execution was interrupted
drop procedure bug6807|
drop table t1| drop table t1|
...@@ -713,8 +713,8 @@ NULL ...@@ -713,8 +713,8 @@ NULL
-99.99 -99.99
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (col1 FLOAT, col2 FLOAT UNSIGNED); CREATE TABLE t1 (col1 FLOAT, col2 FLOAT UNSIGNED);
INSERT INTO t1 VALUES (-1.1E-38,0),(+3.4E+38,+3.4E+38); INSERT INTO t1 VALUES (-1.1E-37,0),(+3.4E+38,+3.4E+38);
INSERT INTO t1 VALUES ('-1.1E-38',0),('+3.4E+38','+3.4E+38'); INSERT INTO t1 VALUES ('-1.1E-37',0),('+3.4E+38','+3.4E+38');
INSERT INTO t1 (col1) VALUES (3E-46); INSERT INTO t1 (col1) VALUES (3E-46);
INSERT INTO t1 (col1) VALUES (+3.4E+39); INSERT INTO t1 (col1) VALUES (+3.4E+39);
ERROR 22003: Out of range value adjusted for column 'col1' at row 1 ERROR 22003: Out of range value adjusted for column 'col1' at row 1
...@@ -752,9 +752,9 @@ Warning 1264 Out of range value adjusted for column 'col1' at row 1 ...@@ -752,9 +752,9 @@ Warning 1264 Out of range value adjusted for column 'col1' at row 1
Warning 1264 Out of range value adjusted for column 'col2' at row 1 Warning 1264 Out of range value adjusted for column 'col2' at row 1
SELECT * FROM t1; SELECT * FROM t1;
col1 col2 col1 col2
-1.1e-38 0 -1.1e-37 0
3.4e+38 3.4e+38 3.4e+38 3.4e+38
-1.1e-38 0 -1.1e-37 0
3.4e+38 3.4e+38 3.4e+38 3.4e+38
0 NULL 0 NULL
2 NULL 2 NULL
...@@ -763,8 +763,8 @@ NULL NULL ...@@ -763,8 +763,8 @@ NULL NULL
3.40282e+38 0 3.40282e+38 0
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (col1 DOUBLE PRECISION, col2 DOUBLE PRECISION UNSIGNED); CREATE TABLE t1 (col1 DOUBLE PRECISION, col2 DOUBLE PRECISION UNSIGNED);
INSERT INTO t1 VALUES (-2.2E-308,0),(+1.7E+308,+1.7E+308); INSERT INTO t1 VALUES (-2.2E-307,0),(+1.7E+308,+1.7E+308);
INSERT INTO t1 VALUES ('-2.2E-308',0),('+1.7E+308','+1.7E+308'); INSERT INTO t1 VALUES ('-2.2E-307',0),('+1.7E+308','+1.7E+308');
INSERT INTO t1 (col1) VALUES (-2.2E-330); INSERT INTO t1 (col1) VALUES (-2.2E-330);
INSERT INTO t1 (col1) VALUES (+1.7E+309); INSERT INTO t1 (col1) VALUES (+1.7E+309);
ERROR 22007: Illegal double '1.7E+309' value found during parsing ERROR 22007: Illegal double '1.7E+309' value found during parsing
...@@ -801,9 +801,9 @@ Warning 1264 Out of range value adjusted for column 'col2' at row 1 ...@@ -801,9 +801,9 @@ Warning 1264 Out of range value adjusted for column 'col2' at row 1
Warning 1264 Out of range value adjusted for column 'col2' at row 1 Warning 1264 Out of range value adjusted for column 'col2' at row 1
SELECT * FROM t1; SELECT * FROM t1;
col1 col2 col1 col2
-2.2e-308 0 -2.2e-307 0
1.7e+308 1.7e+308 1.7e+308 1.7e+308
-2.2e-308 0 -2.2e-307 0
1.7e+308 1.7e+308 1.7e+308 1.7e+308
0 NULL 0 NULL
2 NULL 2 NULL
......
...@@ -162,16 +162,18 @@ grant select(a) on test.t1 to drop_user1@localhost; ...@@ -162,16 +162,18 @@ grant select(a) on test.t1 to drop_user1@localhost;
grant select on test.t1 to drop_user2@localhost; grant select on test.t1 to drop_user2@localhost;
grant select on test.* to drop_user3@localhost; grant select on test.* to drop_user3@localhost;
grant select on *.* to drop_user4@localhost; grant select on *.* to drop_user4@localhost;
--error 1268 # Drop user now implicitly revokes all privileges.
drop user drop_user1@localhost, drop_user2@localhost, drop_user3@localhost, drop user drop_user1@localhost, drop_user2@localhost, drop_user3@localhost,
drop_user4@localhost; drop_user4@localhost;
--error 1269
revoke all privileges, grant option from drop_user1@localhost, drop_user2@localhost, revoke all privileges, grant option from drop_user1@localhost, drop_user2@localhost,
drop_user3@localhost, drop_user4@localhost; drop_user3@localhost, drop_user4@localhost;
--error 1268
drop user drop_user1@localhost, drop_user2@localhost, drop_user3@localhost, drop user drop_user1@localhost, drop_user2@localhost, drop_user3@localhost,
drop_user4@localhost; drop_user4@localhost;
drop table t1; drop table t1;
grant usage on *.* to mysqltest_1@localhost identified by "password"; grant usage on *.* to mysqltest_1@localhost identified by "password";
grant select, update, insert on test.* to mysqltest@localhost; grant select, update, insert on test.* to mysqltest_1@localhost;
show grants for mysqltest_1@localhost; show grants for mysqltest_1@localhost;
drop user mysqltest_1@localhost; drop user mysqltest_1@localhost;
...@@ -195,6 +197,9 @@ GRANT SELECT ( ...@@ -195,6 +197,9 @@ GRANT SELECT (
SHOW GRANTS FOR @localhost; SHOW GRANTS FOR @localhost;
REVOKE SELECT () ON . FROM @localhost; REVOKE SELECT () ON . FROM @localhost;
# Revoke does not drop user. Leave a clean user table for the next tests.
DROP USER @localhost;
DROP DATABASE ; DROP DATABASE ;
SET NAMES latin1; SET NAMES latin1;
......
...@@ -78,3 +78,152 @@ use test; ...@@ -78,3 +78,152 @@ use test;
delete from mysql.user where user like 'mysqltest\_%'; delete from mysql.user where user like 'mysqltest\_%';
delete from mysql.db where user like 'mysqltest\_%'; delete from mysql.db where user like 'mysqltest\_%';
flush privileges; flush privileges;
#
# Create and drop user
#
set sql_mode='maxdb';
--disable_warnings
drop table if exists t1, t2;
--enable_warnings
create table t1(c1 int);
create table t2(c1 int, c2 int);
#
# Three forms of CREATE USER
create user 'mysqltest_1';
--error 1268
create user 'mysqltest_1';
create user 'mysqltest_2' identified by 'Mysqltest-2';
create user 'mysqltest_3' identified by password 'fffffffffffffffffffffffffffffffffffffffff';
grant select on *.* to 'mysqltest_2';
grant insert on test.* to 'mysqltest_2';
grant update on test.t1 to 'mysqltest_2';
grant update (c2) on test.t2 to 'mysqltest_2';
select host,user,password from mysql.user where user like 'mysqltest_%' order by host,user,password;
select host,db,user from mysql.db where user like 'mysqltest_%' order by host,db,user;
select host,db,user,table_name from mysql.tables_priv where user like 'mysqltest_%' order by host,db,user,table_name;
select host,db,user,table_name,column_name from mysql.columns_priv where user like 'mysqltest_%' order by host,db,user,table_name,column_name;
show grants for 'mysqltest_1';
show grants for 'mysqltest_2';
#
# Drop
drop user 'mysqltest_1';
select host,user,password from mysql.user where user like 'mysqltest_%' order by host,user,password;
select host,db,user from mysql.db where user like 'mysqltest_%' order by host,db,user;
select host,db,user,table_name from mysql.tables_priv where user like 'mysqltest_%' order by host,db,user,table_name;
select host,db,user,table_name,column_name from mysql.columns_priv where user like 'mysqltest_%' order by host,db,user,table_name,column_name;
--error 1141
show grants for 'mysqltest_1';
#
# Rename
rename user 'mysqltest_2' to 'mysqltest_1';
select host,user,password from mysql.user where user like 'mysqltest_%' order by host,user,password;
select host,db,user from mysql.db where user like 'mysqltest_%' order by host,db,user;
select host,db,user,table_name from mysql.tables_priv where user like 'mysqltest_%' order by host,db,user,table_name;
select host,db,user,table_name,column_name from mysql.columns_priv where user like 'mysqltest_%' order by host,db,user,table_name,column_name;
show grants for 'mysqltest_1';
drop user 'mysqltest_1', 'mysqltest_3';
#
# Grant must not create user
--error 1211
grant all on test.t1 to 'mysqltest_1';
--error 1268
drop user 'mysqltest_1';
#
# Cleanup
drop table t1, t2;
#
# Add a stray record
insert into mysql.db set user='mysqltest_1', db='%', host='%';
flush privileges;
--error 1141
show grants for 'mysqltest_1';
--error 1269
revoke all privileges, grant option from 'mysqltest_1';
drop user 'mysqltest_1';
select host,db,user from mysql.db where user = 'mysqltest_1' order by host,db,user;
#
# Add a stray record
insert into mysql.tables_priv set host='%', db='test', user='mysqltest_1', table_name='t1';
flush privileges;
--error 1141
show grants for 'mysqltest_1';
drop user 'mysqltest_1';
select host,db,user,table_name from mysql.tables_priv where user = 'mysqltest_1' order by host,db,user,table_name;
#
# Add a stray record
insert into mysql.columns_priv set host='%', db='test', user='mysqltest_1', table_name='t1', column_name='c1';
flush privileges;
--error 1141
show grants for 'mysqltest_1';
drop user 'mysqltest_1';
select host,db,user,table_name,column_name from mysql.columns_priv where user = 'mysqltest_1' order by host,db,user,table_name,column_name;
#
# Handle multi user lists
create user 'mysqltest_1', 'mysqltest_2', 'mysqltest_3';
drop user 'mysqltest_1', 'mysqltest_2', 'mysqltest_3';
create user 'mysqltest_1', 'mysqltest_2' identified by 'Mysqltest-2', 'mysqltest_3' identified by password 'fffffffffffffffffffffffffffffffffffffffff';
rename user 'mysqltest_1' to 'mysqltest_1a', 'mysqltest_2' TO 'mysqltest_2a', 'mysqltest_3' TO 'mysqltest_3a';
--error 1268
drop user 'mysqltest_1', 'mysqltest_2', 'mysqltest_3';
drop user 'mysqltest_1a', 'mysqltest_2a', 'mysqltest_3a';
#
# Let one of multiple users fail
create user 'mysqltest_1', 'mysqltest_2', 'mysqltest_3';
--error 1268
create user 'mysqltest_1a', 'mysqltest_2', 'mysqltest_3a';
--error 1268
rename user 'mysqltest_1a' to 'mysqltest_1b', 'mysqltest_2a' TO 'mysqltest_2b', 'mysqltest_3a' TO 'mysqltest_3b';
drop user 'mysqltest_1', 'mysqltest_2', 'mysqltest_3';
--error 1268
drop user 'mysqltest_1b', 'mysqltest_2b', 'mysqltest_3b';
#
# Obsolete syntax has been dropped
create user 'mysqltest_2' identified by 'Mysqltest-2';
--error 1064
drop user 'mysqltest_2' identified by 'Mysqltest-2';
#
# Strange user names
create user '%@b'@'b';
show grants for '%@b'@'b';
grant select on mysql.* to '%@b'@'b';
show grants for '%@b'@'b';
rename user '%@b'@'b' to '%@a'@'a';
--error 1141
show grants for '%@b'@'b';
show grants for '%@a'@'a';
drop user '%@a'@'a';
#
# USAGE WITH GRANT OPTION is sufficient.
create user mysqltest_2@localhost;
grant usage on *.* to mysqltest_2@localhost with grant option;
connect (user2,localhost,mysqltest_2,,);
connection user2;
--error 1044
select host,user,password from mysql.user where user like 'mysqltest_%' order by host,user,password;
create user mysqltest_A@'%';
rename user mysqltest_A@'%' to mysqltest_B@'%';
drop user mysqltest_B@'%';
disconnect user2;
connection default;
drop user mysqltest_2@localhost;
#
# ALL PRIVILEGES without GRANT OPTION is not sufficient.
create user mysqltest_3@localhost;
grant all privileges on mysql.* to mysqltest_3@localhost;
connect (user3,localhost,mysqltest_3,,);
connection user3;
select host,user,password from mysql.user where user like 'mysqltest_%' order by host,user,password;
insert into mysql.user set host='%', user='mysqltest_B';
--error 1044
create user mysqltest_A@'%';
--error 1044
rename user mysqltest_B@'%' to mysqltest_C@'%';
--error 1044
drop user mysqltest_B@'%';
disconnect user3;
connection default;
drop user mysqltest_B@'%';
drop user mysqltest_3@localhost;
#
...@@ -110,24 +110,24 @@ select count(*) from information_schema.ROUTINES; ...@@ -110,24 +110,24 @@ select count(*) from information_schema.ROUTINES;
# #
# Test for views # Test for views
# #
create view v0 (c) as select schema_name from information_schema.SCHEMATA; create view v0 (c) as select schema_name from information_schema.schemata;
select * from v0; select * from v0;
--replace_column 3 # --replace_column 3 #
explain select * from v0; explain select * from v0;
create view v1 (c) as select table_name from information_schema.TABLES create view v1 (c) as select table_name from information_schema.tables
where table_name="v1"; where table_name="v1";
select * from v1; select * from v1;
create view v2 (c) as select column_name from information_schema.COLUMNS create view v2 (c) as select column_name from information_schema.columns
where table_name="v2"; where table_name="v2";
select * from v2; select * from v2;
create view v3 (c) as select CHARACTER_SET_NAME from information_schema.CHARACTER_SETS create view v3 (c) as select CHARACTER_SET_NAME from information_schema.character_sets
where CHARACTER_SET_NAME like "latin1%"; where CHARACTER_SET_NAME like "latin1%";
select * from v3; select * from v3;
create view v4 (c) as select COLLATION_NAME from information_schema.COLLATIONS create view v4 (c) as select COLLATION_NAME from information_schema.collations
where COLLATION_NAME like "latin1%"; where COLLATION_NAME like "latin1%";
select * from v4; select * from v4;
show keys from v4; show keys from v4;
select * from information_schema.VIEWS where TABLE_NAME like "v%"; select * from information_schema.views where TABLE_NAME like "v%";
drop view v0, v1, v2, v3, v4; drop view v0, v1, v2, v3, v4;
# #
...@@ -222,9 +222,9 @@ information_schema.tables) union select version from ...@@ -222,9 +222,9 @@ information_schema.tables) union select version from
information_schema.tables; information_schema.tables;
drop table t1; drop table t1;
SHOW CREATE TABLE INFORMATION_SCHEMA.CHARACTER_SETS; SHOW CREATE TABLE INFORMATION_SCHEMA.character_sets;
set names latin2; set names latin2;
SHOW CREATE TABLE INFORMATION_SCHEMA.CHARACTER_SETS; SHOW CREATE TABLE INFORMATION_SCHEMA.character_sets;
set names latin1; set names latin1;
create table t1 select * from information_schema.CHARACTER_SETS create table t1 select * from information_schema.CHARACTER_SETS
...@@ -260,3 +260,16 @@ from information_schema.columns; open c; open c; end;// ...@@ -260,3 +260,16 @@ from information_schema.columns; open c; open c; end;//
call p108()// call p108()//
delimiter ;// delimiter ;//
drop procedure p108; drop procedure p108;
create view v1 as select A1.table_name from information_schema.TABLES A1
where table_name= "user";
select * from v1;
drop view v1;
create view vo as select 'a' union select 'a';
show index from vo;
select * from information_schema.TABLE_CONSTRAINTS where
TABLE_NAME= "vo";
select * from information_schema.KEY_COLUMN_USAGE where
TABLE_NAME= "vo";
drop view vo;
...@@ -632,6 +632,28 @@ end| ...@@ -632,6 +632,28 @@ end|
call bug3294()| call bug3294()|
drop procedure bug3294| drop procedure bug3294|
#
# BUG#6807: Stored procedure crash if CREATE PROCEDURE ... KILL QUERY
#
--disable_warnings
drop procedure if exists bug6807|
--enable_warnings
create procedure bug6807()
begin
declare id int;
set id = connection_id();
kill query id;
select 'Not reached';
end|
--error 1317
call bug6807()|
--error 1317
call bug6807()|
drop procedure bug6807|
drop table t1| drop table t1|
......
...@@ -493,8 +493,8 @@ DROP TABLE t1; ...@@ -493,8 +493,8 @@ DROP TABLE t1;
# Test INSERT with FLOAT # Test INSERT with FLOAT
CREATE TABLE t1 (col1 FLOAT, col2 FLOAT UNSIGNED); CREATE TABLE t1 (col1 FLOAT, col2 FLOAT UNSIGNED);
INSERT INTO t1 VALUES (-1.1E-38,0),(+3.4E+38,+3.4E+38); INSERT INTO t1 VALUES (-1.1E-37,0),(+3.4E+38,+3.4E+38);
INSERT INTO t1 VALUES ('-1.1E-38',0),('+3.4E+38','+3.4E+38'); INSERT INTO t1 VALUES ('-1.1E-37',0),('+3.4E+38','+3.4E+38');
# We don't give warnings for underflow # We don't give warnings for underflow
INSERT INTO t1 (col1) VALUES (3E-46); INSERT INTO t1 (col1) VALUES (3E-46);
--error 1264 --error 1264
...@@ -527,8 +527,8 @@ DROP TABLE t1; ...@@ -527,8 +527,8 @@ DROP TABLE t1;
# Test INSERT with DOUBLE # Test INSERT with DOUBLE
CREATE TABLE t1 (col1 DOUBLE PRECISION, col2 DOUBLE PRECISION UNSIGNED); CREATE TABLE t1 (col1 DOUBLE PRECISION, col2 DOUBLE PRECISION UNSIGNED);
INSERT INTO t1 VALUES (-2.2E-308,0),(+1.7E+308,+1.7E+308); INSERT INTO t1 VALUES (-2.2E-307,0),(+1.7E+308,+1.7E+308);
INSERT INTO t1 VALUES ('-2.2E-308',0),('+1.7E+308','+1.7E+308'); INSERT INTO t1 VALUES ('-2.2E-307',0),('+1.7E+308','+1.7E+308');
# We don't give warnings for underflow # We don't give warnings for underflow
INSERT INTO t1 (col1) VALUES (-2.2E-330); INSERT INTO t1 (col1) VALUES (-2.2E-330);
--error 1367 --error 1367
......
...@@ -56,7 +56,7 @@ void manager(const char *socket_file_name) ...@@ -56,7 +56,7 @@ void manager(const char *socket_file_name)
in the process. in the process.
*/ */
int signo; int signo;
sigwait(&mask, &signo); my_sigwait(&mask, &signo);
thread_repository.deliver_shutdown(); thread_repository.deliver_shutdown();
/* don't pthread_exit to kill all threads who did not shut down in time */ /* don't pthread_exit to kill all threads who did not shut down in time */
} }
...@@ -296,7 +296,7 @@ character-set=latin2 ...@@ -296,7 +296,7 @@ character-set=latin2
"Data truncated for column '%s' at row %ld", "Data truncated for column '%s' at row %ld",
"Using storage engine %s for table '%s'", "Using storage engine %s for table '%s'",
"Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", "Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'",
"Can't drop one or more of the requested users", "Operation %s failed for %d of the requested users",
"Can't revoke all privileges, grant for one or more of the requested users", "Can't revoke all privileges, grant for one or more of the requested users",
"Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'",
"Illegal mix of collations for operation '%s'", "Illegal mix of collations for operation '%s'",
......
...@@ -287,7 +287,7 @@ character-set=latin1 ...@@ -287,7 +287,7 @@ character-set=latin1
"Data truncated for column '%s' at row %ld", "Data truncated for column '%s' at row %ld",
"Using storage engine %s for table '%s'", "Using storage engine %s for table '%s'",
"Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", "Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'",
"Can't drop one or more of the requested users", "Operation %s failed for %d of the requested users",
"Can't revoke all privileges, grant for one or more of the requested users", "Can't revoke all privileges, grant for one or more of the requested users",
"Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'",
"Illegal mix of collations for operation '%s'", "Illegal mix of collations for operation '%s'",
......
...@@ -296,7 +296,7 @@ character-set=latin1 ...@@ -296,7 +296,7 @@ character-set=latin1
"Data truncated for column '%s' at row %ld", "Data truncated for column '%s' at row %ld",
"Using storage engine %s for table '%s'", "Using storage engine %s for table '%s'",
"Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", "Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'",
"Can't drop one or more of the requested users", "Operation %s failed for %d of the requested users",
"Can't revoke all privileges, grant for one or more of the requested users", "Can't revoke all privileges, grant for one or more of the requested users",
"Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'",
"Illegal mix of collations for operation '%s'", "Illegal mix of collations for operation '%s'",
......
...@@ -284,7 +284,7 @@ character-set=latin1 ...@@ -284,7 +284,7 @@ character-set=latin1
"Data truncated for column '%s' at row %ld", "Data truncated for column '%s' at row %ld",
"Using storage engine %s for table '%s'", "Using storage engine %s for table '%s'",
"Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", "Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'",
"Can't drop one or more of the requested users", "Operation %s failed for %d of the requested users",
"Can't revoke all privileges, grant for one or more of the requested users", "Can't revoke all privileges, grant for one or more of the requested users",
"Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'",
"Illegal mix of collations for operation '%s'", "Illegal mix of collations for operation '%s'",
......
...@@ -289,7 +289,7 @@ character-set=latin7 ...@@ -289,7 +289,7 @@ character-set=latin7
"Data truncated for column '%s' at row %ld", "Data truncated for column '%s' at row %ld",
"Using storage engine %s for table '%s'", "Using storage engine %s for table '%s'",
"Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", "Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'",
"Can't drop one or more of the requested users", "Operation %s failed for %d of the requested users",
"Can't revoke all privileges, grant for one or more of the requested users", "Can't revoke all privileges, grant for one or more of the requested users",
"Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'",
"Illegal mix of collations for operation '%s'", "Illegal mix of collations for operation '%s'",
......
...@@ -284,7 +284,7 @@ character-set=latin1 ...@@ -284,7 +284,7 @@ character-set=latin1
"Data truncated for column '%s' at row %ld", "Data truncated for column '%s' at row %ld",
"Using storage engine %s for table '%s'", "Using storage engine %s for table '%s'",
"Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", "Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'",
"Can't drop one or more of the requested users", "Operation %s failed for %d of the requested users",
"Can't revoke all privileges, grant for one or more of the requested users", "Can't revoke all privileges, grant for one or more of the requested users",
"Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'",
"Illegal mix of collations for operation '%s'", "Illegal mix of collations for operation '%s'",
......
...@@ -297,7 +297,7 @@ character-set=latin1 ...@@ -297,7 +297,7 @@ character-set=latin1
"Daten abgeschnitten für Spalte '%s' in Zeile %ld", "Daten abgeschnitten für Spalte '%s' in Zeile %ld",
"Für Tabelle '%s' wird Speicher-Engine %s benutzt", "Für Tabelle '%s' wird Speicher-Engine %s benutzt",
"Unerlaubte Vermischung der Kollationen (%s,%s) und (%s,%s) für die Operation '%s'", "Unerlaubte Vermischung der Kollationen (%s,%s) und (%s,%s) für die Operation '%s'",
"Kann einen oder mehrere der angegebenen Benutzer nicht löschen", "Das Kommando %s scheiterte für %d von den betroffenen Benutzern",
"Kann nicht alle Berechtigungen widerrufen, grant for one or more of the requested users", "Kann nicht alle Berechtigungen widerrufen, grant for one or more of the requested users",
"Unerlaubte Vermischung der Kollationen (%s,%s), (%s,%s), (%s,%s) für die Operation '%s'", "Unerlaubte Vermischung der Kollationen (%s,%s), (%s,%s), (%s,%s) für die Operation '%s'",
"Unerlaubte Vermischung der Kollationen für die Operation '%s'", "Unerlaubte Vermischung der Kollationen für die Operation '%s'",
......
...@@ -284,7 +284,7 @@ character-set=greek ...@@ -284,7 +284,7 @@ character-set=greek
"Data truncated for column '%s' at row %ld", "Data truncated for column '%s' at row %ld",
"Using storage engine %s for table '%s'", "Using storage engine %s for table '%s'",
"Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", "Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'",
"Can't drop one or more of the requested users", "Operation %s failed for %d of the requested users",
"Can't revoke all privileges, grant for one or more of the requested users", "Can't revoke all privileges, grant for one or more of the requested users",
"Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'",
"Illegal mix of collations for operation '%s'", "Illegal mix of collations for operation '%s'",
......
...@@ -289,7 +289,7 @@ character-set=latin2 ...@@ -289,7 +289,7 @@ character-set=latin2
"Data truncated for column '%s' at row %ld", "Data truncated for column '%s' at row %ld",
"Using storage engine %s for table '%s'", "Using storage engine %s for table '%s'",
"Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", "Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'",
"Can't drop one or more of the requested users", "Operation %s failed for %d of the requested users",
"Can't revoke all privileges, grant for one or more of the requested users", "Can't revoke all privileges, grant for one or more of the requested users",
"Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'",
"Illegal mix of collations for operation '%s'", "Illegal mix of collations for operation '%s'",
......
...@@ -284,7 +284,7 @@ character-set=latin1 ...@@ -284,7 +284,7 @@ character-set=latin1
"Data truncated for column '%s' at row %ld", "Data truncated for column '%s' at row %ld",
"Using storage engine %s for table '%s'", "Using storage engine %s for table '%s'",
"Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", "Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'",
"Can't drop one or more of the requested users", "Operation %s failed for %d of the requested users",
"Can't revoke all privileges, grant for one or more of the requested users", "Can't revoke all privileges, grant for one or more of the requested users",
"Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'",
"Illegal mix of collations for operation '%s'", "Illegal mix of collations for operation '%s'",
......
...@@ -288,7 +288,7 @@ character-set=ujis ...@@ -288,7 +288,7 @@ character-set=ujis
"Data truncated for column '%s' at row %ld", "Data truncated for column '%s' at row %ld",
"Using storage engine %s for table '%s'", "Using storage engine %s for table '%s'",
"Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", "Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'",
"Can't drop one or more of the requested users", "Operation %s failed for %d of the requested users",
"Can't revoke all privileges, grant for one or more of the requested users", "Can't revoke all privileges, grant for one or more of the requested users",
"Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'",
"Illegal mix of collations for operation '%s'", "Illegal mix of collations for operation '%s'",
......
...@@ -284,7 +284,7 @@ character-set=euckr ...@@ -284,7 +284,7 @@ character-set=euckr
"Data truncated for column '%s' at row %ld", "Data truncated for column '%s' at row %ld",
"Using storage engine %s for table '%s'", "Using storage engine %s for table '%s'",
"Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", "Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'",
"Can't drop one or more of the requested users", "Operation %s failed for %d of the requested users",
"Can't revoke all privileges, grant for one or more of the requested users", "Can't revoke all privileges, grant for one or more of the requested users",
"Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'",
"Illegal mix of collations for operation '%s'", "Illegal mix of collations for operation '%s'",
......
...@@ -286,7 +286,7 @@ character-set=latin1 ...@@ -286,7 +286,7 @@ character-set=latin1
"Data truncated for column '%s' at row %ld", "Data truncated for column '%s' at row %ld",
"Using storage engine %s for table '%s'", "Using storage engine %s for table '%s'",
"Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", "Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'",
"Can't drop one or more of the requested users", "Operation %s failed for %d of the requested users",
"Can't revoke all privileges, grant for one or more of the requested users", "Can't revoke all privileges, grant for one or more of the requested users",
"Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'",
"Illegal mix of collations for operation '%s'", "Illegal mix of collations for operation '%s'",
......
...@@ -286,7 +286,7 @@ character-set=latin1 ...@@ -286,7 +286,7 @@ character-set=latin1
"Data truncated for column '%s' at row %ld", "Data truncated for column '%s' at row %ld",
"Using storage engine %s for table '%s'", "Using storage engine %s for table '%s'",
"Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", "Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'",
"Can't drop one or more of the requested users", "Operation %s failed for %d of the requested users",
"Can't revoke all privileges, grant for one or more of the requested users", "Can't revoke all privileges, grant for one or more of the requested users",
"Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'",
"Illegal mix of collations for operation '%s'", "Illegal mix of collations for operation '%s'",
......
...@@ -289,7 +289,7 @@ character-set=latin2 ...@@ -289,7 +289,7 @@ character-set=latin2
"Data truncated for column '%s' at row %ld", "Data truncated for column '%s' at row %ld",
"Using storage engine %s for table '%s'", "Using storage engine %s for table '%s'",
"Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", "Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'",
"Can't drop one or more of the requested users", "Operation %s failed for %d of the requested users",
"Can't revoke all privileges, grant for one or more of the requested users", "Can't revoke all privileges, grant for one or more of the requested users",
"Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'",
"Illegal mix of collations for operation '%s'", "Illegal mix of collations for operation '%s'",
......
...@@ -286,7 +286,7 @@ character-set=latin1 ...@@ -286,7 +286,7 @@ character-set=latin1
"Dado truncado para coluna '%s' na linha %ld", "Dado truncado para coluna '%s' na linha %ld",
"Usando engine de armazenamento %s para tabela '%s'", "Usando engine de armazenamento %s para tabela '%s'",
"Combinação ilegal de collations (%s,%s) e (%s,%s) para operação '%s'", "Combinação ilegal de collations (%s,%s) e (%s,%s) para operação '%s'",
"Não pode remover um ou mais dos usuários pedidos", "Operation %s failed for %d of the requested users",
"Não pode revocar todos os privilégios, grant para um ou mais dos usuários pedidos", "Não pode revocar todos os privilégios, grant para um ou mais dos usuários pedidos",
"Ilegal combinação de collations (%s,%s), (%s,%s), (%s,%s) para operação '%s'", "Ilegal combinação de collations (%s,%s), (%s,%s), (%s,%s) para operação '%s'",
"Ilegal combinação de collations para operação '%s'", "Ilegal combinação de collations para operação '%s'",
......
...@@ -289,7 +289,7 @@ character-set=latin2 ...@@ -289,7 +289,7 @@ character-set=latin2
"Data truncated for column '%s' at row %ld", "Data truncated for column '%s' at row %ld",
"Using storage engine %s for table '%s'", "Using storage engine %s for table '%s'",
"Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", "Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'",
"Can't drop one or more of the requested users", "Operation %s failed for %d of the requested users",
"Can't revoke all privileges, grant for one or more of the requested users", "Can't revoke all privileges, grant for one or more of the requested users",
"Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'",
"Illegal mix of collations for operation '%s'", "Illegal mix of collations for operation '%s'",
......
...@@ -289,7 +289,7 @@ character-set=koi8r ...@@ -289,7 +289,7 @@ character-set=koi8r
"Data truncated for column '%s' at row %ld", "Data truncated for column '%s' at row %ld",
"Using storage engine %s for table '%s'", "Using storage engine %s for table '%s'",
"Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", "Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'",
"Can't drop one or more of the requested users", "Operation %s failed for %d of the requested users",
"Can't revoke all privileges, grant for one or more of the requested users", "Can't revoke all privileges, grant for one or more of the requested users",
"Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'",
"Illegal mix of collations for operation '%s'", "Illegal mix of collations for operation '%s'",
......
...@@ -277,7 +277,7 @@ character-set=cp1250 ...@@ -277,7 +277,7 @@ character-set=cp1250
"Data truncated for column '%s' at row %ld", "Data truncated for column '%s' at row %ld",
"Using storage engine %s for table '%s'", "Using storage engine %s for table '%s'",
"Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", "Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'",
"Can't drop one or more of the requested users", "Operation %s failed for %d of the requested users",
"Can't revoke all privileges, grant for one or more of the requested users", "Can't revoke all privileges, grant for one or more of the requested users",
"Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'",
"Illegal mix of collations for operation '%s'", "Illegal mix of collations for operation '%s'",
......
...@@ -292,7 +292,7 @@ character-set=latin2 ...@@ -292,7 +292,7 @@ character-set=latin2
"Data truncated for column '%s' at row %ld", "Data truncated for column '%s' at row %ld",
"Using storage engine %s for table '%s'", "Using storage engine %s for table '%s'",
"Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", "Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'",
"Can't drop one or more of the requested users", "Operation %s failed for %d of the requested users",
"Can't revoke all privileges, grant for one or more of the requested users", "Can't revoke all privileges, grant for one or more of the requested users",
"Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'",
"Illegal mix of collations for operation '%s'", "Illegal mix of collations for operation '%s'",
......
...@@ -288,7 +288,7 @@ character-set=latin1 ...@@ -288,7 +288,7 @@ character-set=latin1
"Datos truncados para columna '%s' en la línea %ld", "Datos truncados para columna '%s' en la línea %ld",
"Usando motor de almacenamiento %s para tabla '%s'", "Usando motor de almacenamiento %s para tabla '%s'",
"Ilegal mezcla de collations (%s,%s) y (%s,%s) para operación '%s'", "Ilegal mezcla de collations (%s,%s) y (%s,%s) para operación '%s'",
"No puede remover uno o mas de los usuarios solicitados", "Operation %s failed for %d of the requested users",
"No puede revocar todos los privilegios, derecho para uno o mas de los usuarios solicitados", "No puede revocar todos los privilegios, derecho para uno o mas de los usuarios solicitados",
"Ilegal mezcla de collations (%s,%s), (%s,%s), (%s,%s) para operación '%s'", "Ilegal mezcla de collations (%s,%s), (%s,%s), (%s,%s) para operación '%s'",
"Ilegal mezcla de collations para operación '%s'", "Ilegal mezcla de collations para operación '%s'",
......
...@@ -284,7 +284,7 @@ character-set=latin1 ...@@ -284,7 +284,7 @@ character-set=latin1
"Data truncated for column '%s' at row %ld", "Data truncated for column '%s' at row %ld",
"Använder handler %s för tabell '%s'", "Använder handler %s för tabell '%s'",
"Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", "Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'",
"Can't drop one or more of the requested users", "Operation %s failed for %d of the requested users",
"Can't revoke all privileges, grant for one or more of the requested users", "Can't revoke all privileges, grant for one or more of the requested users",
"Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'",
"Illegal mix of collations for operation '%s'", "Illegal mix of collations for operation '%s'",
......
...@@ -290,7 +290,7 @@ character-set=koi8u ...@@ -290,7 +290,7 @@ character-set=koi8u
"Data truncated for column '%s' at row %ld", "Data truncated for column '%s' at row %ld",
"Using storage engine %s for table '%s'", "Using storage engine %s for table '%s'",
"Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", "Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'",
"Can't drop one or more of the requested users", "Operation %s failed for %d of the requested users",
"Can't revoke all privileges, grant for one or more of the requested users", "Can't revoke all privileges, grant for one or more of the requested users",
"Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'",
"Illegal mix of collations for operation '%s'", "Illegal mix of collations for operation '%s'",
......
...@@ -919,7 +919,7 @@ static void acl_update_user(const char *user, const char *host, ...@@ -919,7 +919,7 @@ static void acl_update_user(const char *user, const char *host,
{ {
if (!acl_user->host.hostname && !host[0] || if (!acl_user->host.hostname && !host[0] ||
acl_user->host.hostname && acl_user->host.hostname &&
!my_strcasecmp(&my_charset_latin1, host, acl_user->host.hostname)) !my_strcasecmp(system_charset_info, host, acl_user->host.hostname))
{ {
acl_user->access=privileges; acl_user->access=privileges;
if (mqh->bits & 1) if (mqh->bits & 1)
...@@ -998,7 +998,7 @@ static void acl_update_db(const char *user, const char *host, const char *db, ...@@ -998,7 +998,7 @@ static void acl_update_db(const char *user, const char *host, const char *db,
{ {
if (!acl_db->host.hostname && !host[0] || if (!acl_db->host.hostname && !host[0] ||
acl_db->host.hostname && acl_db->host.hostname &&
!my_strcasecmp(&my_charset_latin1, host, acl_db->host.hostname)) !my_strcasecmp(system_charset_info, host, acl_db->host.hostname))
{ {
if (!acl_db->db && !db[0] || if (!acl_db->db && !db[0] ||
acl_db->db && !strcmp(db,acl_db->db)) acl_db->db && !strcmp(db,acl_db->db))
...@@ -1141,7 +1141,7 @@ static void init_check_host(void) ...@@ -1141,7 +1141,7 @@ static void init_check_host(void)
DBUG_ENTER("init_check_host"); DBUG_ENTER("init_check_host");
VOID(my_init_dynamic_array(&acl_wild_hosts,sizeof(struct acl_host_and_ip), VOID(my_init_dynamic_array(&acl_wild_hosts,sizeof(struct acl_host_and_ip),
acl_users.elements,1)); acl_users.elements,1));
VOID(hash_init(&acl_check_hosts,&my_charset_latin1,acl_users.elements,0,0, VOID(hash_init(&acl_check_hosts,system_charset_info,acl_users.elements,0,0,
(hash_get_key) check_get_key,0,0)); (hash_get_key) check_get_key,0,0));
if (!allow_all_hosts) if (!allow_all_hosts)
{ {
...@@ -1157,7 +1157,7 @@ static void init_check_host(void) ...@@ -1157,7 +1157,7 @@ static void init_check_host(void)
{ // Check if host already exists { // Check if host already exists
acl_host_and_ip *acl=dynamic_element(&acl_wild_hosts,j, acl_host_and_ip *acl=dynamic_element(&acl_wild_hosts,j,
acl_host_and_ip *); acl_host_and_ip *);
if (!my_strcasecmp(&my_charset_latin1, if (!my_strcasecmp(system_charset_info,
acl_user->host.hostname, acl->hostname)) acl_user->host.hostname, acl->hostname))
break; // already stored break; // already stored
} }
...@@ -1233,7 +1233,7 @@ bool check_change_password(THD *thd, const char *host, const char *user, ...@@ -1233,7 +1233,7 @@ bool check_change_password(THD *thd, const char *host, const char *user,
} }
if (!thd->slave_thread && if (!thd->slave_thread &&
(strcmp(thd->user,user) || (strcmp(thd->user,user) ||
my_strcasecmp(&my_charset_latin1, host, thd->host_or_ip))) my_strcasecmp(system_charset_info, host, thd->host_or_ip)))
{ {
if (check_access(thd, UPDATE_ACL, "mysql",0,1,0)) if (check_access(thd, UPDATE_ACL, "mysql",0,1,0))
return(1); return(1);
...@@ -1402,7 +1402,7 @@ static bool compare_hostname(const acl_host_and_ip *host, const char *hostname, ...@@ -1402,7 +1402,7 @@ static bool compare_hostname(const acl_host_and_ip *host, const char *hostname,
return (tmp & host->ip_mask) == host->ip; return (tmp & host->ip_mask) == host->ip;
} }
return (!host->hostname || return (!host->hostname ||
(hostname && !wild_case_compare(&my_charset_latin1, (hostname && !wild_case_compare(system_charset_info,
hostname,host->hostname)) || hostname,host->hostname)) ||
(ip && !wild_compare(ip,host->hostname,0))); (ip && !wild_compare(ip,host->hostname,0)));
} }
...@@ -1415,7 +1415,7 @@ bool hostname_requires_resolving(const char *hostname) ...@@ -1415,7 +1415,7 @@ bool hostname_requires_resolving(const char *hostname)
int namelen= strlen(hostname); int namelen= strlen(hostname);
int lhlen= strlen(my_localhost); int lhlen= strlen(my_localhost);
if ((namelen == lhlen) && if ((namelen == lhlen) &&
!my_strnncoll(&my_charset_latin1, (const uchar *)hostname, namelen, !my_strnncoll(system_charset_info, (const uchar *)hostname, namelen,
(const uchar *)my_localhost, strlen(my_localhost))) (const uchar *)my_localhost, strlen(my_localhost)))
return FALSE; return FALSE;
for (; (cur=*hostname); hostname++) for (; (cur=*hostname); hostname++)
...@@ -1464,8 +1464,8 @@ static bool update_user_table(THD *thd, const char *host, const char *user, ...@@ -1464,8 +1464,8 @@ static bool update_user_table(THD *thd, const char *host, const char *user,
if (!(table=open_ltable(thd,&tables,TL_WRITE))) if (!(table=open_ltable(thd,&tables,TL_WRITE)))
DBUG_RETURN(1); /* purecov: deadcode */ DBUG_RETURN(1); /* purecov: deadcode */
table->field[0]->store(host,(uint) strlen(host), &my_charset_latin1); table->field[0]->store(host,(uint) strlen(host), system_charset_info);
table->field[1]->store(user,(uint) strlen(user), &my_charset_latin1); table->field[1]->store(user,(uint) strlen(user), system_charset_info);
table->file->extra(HA_EXTRA_RETRIEVE_ALL_COLS); table->file->extra(HA_EXTRA_RETRIEVE_ALL_COLS);
if (table->file->index_read_idx(table->record[0],0, if (table->file->index_read_idx(table->record[0],0,
...@@ -1478,7 +1478,7 @@ static bool update_user_table(THD *thd, const char *host, const char *user, ...@@ -1478,7 +1478,7 @@ static bool update_user_table(THD *thd, const char *host, const char *user,
DBUG_RETURN(1); /* purecov: deadcode */ DBUG_RETURN(1); /* purecov: deadcode */
} }
store_record(table,record[1]); store_record(table,record[1]);
table->field[2]->store(new_password, new_password_len, &my_charset_latin1); table->field[2]->store(new_password, new_password_len, system_charset_info);
if ((error=table->file->update_row(table->record[1],table->record[0]))) if ((error=table->file->update_row(table->record[1],table->record[0])))
{ {
table->file->print_error(error,MYF(0)); /* purecov: deadcode */ table->file->print_error(error,MYF(0)); /* purecov: deadcode */
...@@ -1546,8 +1546,8 @@ static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo, ...@@ -1546,8 +1546,8 @@ static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo,
password=combo.password.str; password=combo.password.str;
} }
table->field[0]->store(combo.host.str,combo.host.length, &my_charset_latin1); table->field[0]->store(combo.host.str,combo.host.length, system_charset_info);
table->field[1]->store(combo.user.str,combo.user.length, &my_charset_latin1); table->field[1]->store(combo.user.str,combo.user.length, system_charset_info);
table->file->extra(HA_EXTRA_RETRIEVE_ALL_COLS); table->file->extra(HA_EXTRA_RETRIEVE_ALL_COLS);
if (table->file->index_read_idx(table->record[0], 0, if (table->file->index_read_idx(table->record[0], 0,
(byte*) table->field[0]->ptr, (byte*) table->field[0]->ptr,
...@@ -1581,11 +1581,11 @@ static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo, ...@@ -1581,11 +1581,11 @@ static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo,
old_row_exists = 0; old_row_exists = 0;
restore_record(table,default_values); // cp empty row from default_values restore_record(table,default_values); // cp empty row from default_values
table->field[0]->store(combo.host.str,combo.host.length, table->field[0]->store(combo.host.str,combo.host.length,
&my_charset_latin1); system_charset_info);
table->field[1]->store(combo.user.str,combo.user.length, table->field[1]->store(combo.user.str,combo.user.length,
&my_charset_latin1); system_charset_info);
table->field[2]->store(password, password_len, table->field[2]->store(password, password_len,
&my_charset_latin1); system_charset_info);
} }
else else
{ {
...@@ -1596,14 +1596,14 @@ static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo, ...@@ -1596,14 +1596,14 @@ static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo,
DBUG_ASSERT(combo.host.str); DBUG_ASSERT(combo.host.str);
if (thd->user && combo.password.str && if (thd->user && combo.password.str &&
(strcmp(thd->user,combo.user.str) || (strcmp(thd->user,combo.user.str) ||
my_strcasecmp(&my_charset_latin1, my_strcasecmp(system_charset_info,
combo.host.str, thd->host_or_ip)) && combo.host.str, thd->host_or_ip)) &&
check_access(thd, UPDATE_ACL, "mysql",0,1,0)) check_access(thd, UPDATE_ACL, "mysql",0,1,0))
goto end; goto end;
old_row_exists = 1; old_row_exists = 1;
store_record(table,record[1]); // Save copy for update store_record(table,record[1]); // Save copy for update
if (combo.password.str) // If password given if (combo.password.str) // If password given
table->field[2]->store(password, password_len, &my_charset_latin1); table->field[2]->store(password, password_len, system_charset_info);
else if (!rights && !revoke_grant && else if (!rights && !revoke_grant &&
lex->ssl_type == SSL_TYPE_NOT_SPECIFIED && !lex->mqh.bits) lex->ssl_type == SSL_TYPE_NOT_SPECIFIED && !lex->mqh.bits)
{ {
...@@ -1648,13 +1648,13 @@ static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo, ...@@ -1648,13 +1648,13 @@ static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo,
table->field[27]->store("", 0, &my_charset_latin1); table->field[27]->store("", 0, &my_charset_latin1);
if (lex->ssl_cipher) if (lex->ssl_cipher)
table->field[25]->store(lex->ssl_cipher, table->field[25]->store(lex->ssl_cipher,
strlen(lex->ssl_cipher), &my_charset_latin1); strlen(lex->ssl_cipher), system_charset_info);
if (lex->x509_issuer) if (lex->x509_issuer)
table->field[26]->store(lex->x509_issuer, table->field[26]->store(lex->x509_issuer,
strlen(lex->x509_issuer), &my_charset_latin1); strlen(lex->x509_issuer), system_charset_info);
if (lex->x509_subject) if (lex->x509_subject)
table->field[27]->store(lex->x509_subject, table->field[27]->store(lex->x509_subject,
strlen(lex->x509_subject), &my_charset_latin1); strlen(lex->x509_subject), system_charset_info);
break; break;
case SSL_TYPE_NOT_SPECIFIED: case SSL_TYPE_NOT_SPECIFIED:
break; break;
...@@ -1756,9 +1756,9 @@ static int replace_db_table(TABLE *table, const char *db, ...@@ -1756,9 +1756,9 @@ static int replace_db_table(TABLE *table, const char *db,
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
table->field[0]->store(combo.host.str,combo.host.length, &my_charset_latin1); table->field[0]->store(combo.host.str,combo.host.length, system_charset_info);
table->field[1]->store(db,(uint) strlen(db), &my_charset_latin1); table->field[1]->store(db,(uint) strlen(db), system_charset_info);
table->field[2]->store(combo.user.str,combo.user.length, &my_charset_latin1); table->field[2]->store(combo.user.str,combo.user.length, system_charset_info);
table->file->extra(HA_EXTRA_RETRIEVE_ALL_COLS); table->file->extra(HA_EXTRA_RETRIEVE_ALL_COLS);
if (table->file->index_read_idx(table->record[0],0, if (table->file->index_read_idx(table->record[0],0,
(byte*) table->field[0]->ptr, (byte*) table->field[0]->ptr,
...@@ -1772,9 +1772,9 @@ static int replace_db_table(TABLE *table, const char *db, ...@@ -1772,9 +1772,9 @@ static int replace_db_table(TABLE *table, const char *db,
} }
old_row_exists = 0; old_row_exists = 0;
restore_record(table,default_values); // cp empty row from default_values restore_record(table,default_values); // cp empty row from default_values
table->field[0]->store(combo.host.str,combo.host.length, &my_charset_latin1); table->field[0]->store(combo.host.str,combo.host.length, system_charset_info);
table->field[1]->store(db,(uint) strlen(db), &my_charset_latin1); table->field[1]->store(db,(uint) strlen(db), system_charset_info);
table->field[2]->store(combo.user.str,combo.user.length, &my_charset_latin1); table->field[2]->store(combo.user.str,combo.user.length, system_charset_info);
} }
else else
{ {
...@@ -1862,6 +1862,7 @@ public: ...@@ -1862,6 +1862,7 @@ public:
GRANT_TABLE(const char *h, const char *d,const char *u, GRANT_TABLE(const char *h, const char *d,const char *u,
const char *t, ulong p, ulong c); const char *t, ulong p, ulong c);
GRANT_TABLE (TABLE *form, TABLE *col_privs); GRANT_TABLE (TABLE *form, TABLE *col_privs);
~GRANT_TABLE();
bool ok() { return privs != 0 || cols != 0; } bool ok() { return privs != 0 || cols != 0; }
}; };
...@@ -1887,7 +1888,7 @@ GRANT_TABLE::GRANT_TABLE(const char *h, const char *d,const char *u, ...@@ -1887,7 +1888,7 @@ GRANT_TABLE::GRANT_TABLE(const char *h, const char *d,const char *u,
key_length =(uint) strlen(d)+(uint) strlen(u)+(uint) strlen(t)+3; key_length =(uint) strlen(d)+(uint) strlen(u)+(uint) strlen(t)+3;
hash_key = (char*) alloc_root(&memex,key_length); hash_key = (char*) alloc_root(&memex,key_length);
strmov(strmov(strmov(hash_key,user)+1,db)+1,tname); strmov(strmov(strmov(hash_key,user)+1,db)+1,tname);
(void) hash_init(&hash_columns,&my_charset_latin1, (void) hash_init(&hash_columns,system_charset_info,
0,0,0, (hash_get_key) get_key_column,0,0); 0,0,0, (hash_get_key) get_key_column,0,0);
} }
...@@ -1911,7 +1912,8 @@ GRANT_TABLE::GRANT_TABLE(TABLE *form, TABLE *col_privs) ...@@ -1911,7 +1912,8 @@ GRANT_TABLE::GRANT_TABLE(TABLE *form, TABLE *col_privs)
if (!db || !tname) if (!db || !tname)
{ {
/* Wrong table row; Ignore it */ /* Wrong table row; Ignore it */
privs = cols = 0; /* purecov: inspected */ hash_clear(&hash_columns); /* allow for destruction */
privs= cols= 0; /* purecov: inspected */
return; /* purecov: inspected */ return; /* purecov: inspected */
} }
if (lower_case_table_names) if (lower_case_table_names)
...@@ -1928,16 +1930,16 @@ GRANT_TABLE::GRANT_TABLE(TABLE *form, TABLE *col_privs) ...@@ -1928,16 +1930,16 @@ GRANT_TABLE::GRANT_TABLE(TABLE *form, TABLE *col_privs)
privs = fix_rights_for_table(privs); privs = fix_rights_for_table(privs);
cols = fix_rights_for_column(cols); cols = fix_rights_for_column(cols);
(void) hash_init(&hash_columns,&my_charset_latin1, (void) hash_init(&hash_columns,system_charset_info,
0,0,0, (hash_get_key) get_key_column,0,0); 0,0,0, (hash_get_key) get_key_column,0,0);
if (cols) if (cols)
{ {
int key_len; int key_len;
col_privs->field[0]->store(orig_host,(uint) strlen(orig_host), col_privs->field[0]->store(orig_host,(uint) strlen(orig_host),
&my_charset_latin1); system_charset_info);
col_privs->field[1]->store(db,(uint) strlen(db), &my_charset_latin1); col_privs->field[1]->store(db,(uint) strlen(db), system_charset_info);
col_privs->field[2]->store(user,(uint) strlen(user), &my_charset_latin1); col_privs->field[2]->store(user,(uint) strlen(user), system_charset_info);
col_privs->field[3]->store(tname,(uint) strlen(tname), &my_charset_latin1); col_privs->field[3]->store(tname,(uint) strlen(tname), system_charset_info);
key_len=(col_privs->field[0]->pack_length()+ key_len=(col_privs->field[0]->pack_length()+
col_privs->field[1]->pack_length()+ col_privs->field[1]->pack_length()+
col_privs->field[2]->pack_length()+ col_privs->field[2]->pack_length()+
...@@ -1975,6 +1977,12 @@ GRANT_TABLE::GRANT_TABLE(TABLE *form, TABLE *col_privs) ...@@ -1975,6 +1977,12 @@ GRANT_TABLE::GRANT_TABLE(TABLE *form, TABLE *col_privs)
} }
GRANT_TABLE::~GRANT_TABLE()
{
hash_free(&hash_columns);
}
static byte* get_grant_table(GRANT_TABLE *buff,uint *length, static byte* get_grant_table(GRANT_TABLE *buff,uint *length,
my_bool not_used __attribute__((unused))) my_bool not_used __attribute__((unused)))
{ {
...@@ -2011,15 +2019,15 @@ static GRANT_TABLE *table_hash_search(const char *host,const char* ip, ...@@ -2011,15 +2019,15 @@ static GRANT_TABLE *table_hash_search(const char *host,const char* ip,
if (exact) if (exact)
{ {
if ((host && if ((host &&
!my_strcasecmp(&my_charset_latin1, host, grant_table->host)) || !my_strcasecmp(system_charset_info, host, grant_table->host)) ||
(ip && !strcmp(ip,grant_table->host))) (ip && !strcmp(ip,grant_table->host)))
return grant_table; return grant_table;
} }
else else
{ {
if (((host && !wild_case_compare(&my_charset_latin1, if (((host && !wild_case_compare(system_charset_info,
host,grant_table->host)) || host,grant_table->host)) ||
(ip && !wild_case_compare(&my_charset_latin1, (ip && !wild_case_compare(system_charset_info,
ip,grant_table->host))) && ip,grant_table->host))) &&
(!found || found->sort < grant_table->sort)) (!found || found->sort < grant_table->sort))
found=grant_table; // Host ok found=grant_table; // Host ok
...@@ -2048,10 +2056,10 @@ static int replace_column_table(GRANT_TABLE *g_t, ...@@ -2048,10 +2056,10 @@ static int replace_column_table(GRANT_TABLE *g_t,
byte key[MAX_KEY_LENGTH]; byte key[MAX_KEY_LENGTH];
DBUG_ENTER("replace_column_table"); DBUG_ENTER("replace_column_table");
table->field[0]->store(combo.host.str,combo.host.length, &my_charset_latin1); table->field[0]->store(combo.host.str,combo.host.length, system_charset_info);
table->field[1]->store(db,(uint) strlen(db), &my_charset_latin1); table->field[1]->store(db,(uint) strlen(db), system_charset_info);
table->field[2]->store(combo.user.str,combo.user.length, &my_charset_latin1); table->field[2]->store(combo.user.str,combo.user.length, system_charset_info);
table->field[3]->store(table_name,(uint) strlen(table_name), &my_charset_latin1); table->field[3]->store(table_name,(uint) strlen(table_name), system_charset_info);
key_length=(table->field[0]->pack_length()+ table->field[1]->pack_length()+ key_length=(table->field[0]->pack_length()+ table->field[1]->pack_length()+
table->field[2]->pack_length()+ table->field[3]->pack_length()); table->field[2]->pack_length()+ table->field[3]->pack_length());
key_copy(key,table->record[0],table->key_info,key_length); key_copy(key,table->record[0],table->key_info,key_length);
...@@ -2069,7 +2077,7 @@ static int replace_column_table(GRANT_TABLE *g_t, ...@@ -2069,7 +2077,7 @@ static int replace_column_table(GRANT_TABLE *g_t,
bool old_row_exists=0; bool old_row_exists=0;
key_restore(table->record[0],key,table->key_info,key_length); key_restore(table->record[0],key,table->key_info,key_length);
table->field[4]->store(xx->column.ptr(),xx->column.length(), table->field[4]->store(xx->column.ptr(),xx->column.length(),
&my_charset_latin1); system_charset_info);
table->file->extra(HA_EXTRA_RETRIEVE_ALL_COLS); table->file->extra(HA_EXTRA_RETRIEVE_ALL_COLS);
if (table->file->index_read(table->record[0],(byte*) table->field[0]->ptr, if (table->file->index_read(table->record[0],(byte*) table->field[0]->ptr,
...@@ -2088,7 +2096,7 @@ static int replace_column_table(GRANT_TABLE *g_t, ...@@ -2088,7 +2096,7 @@ static int replace_column_table(GRANT_TABLE *g_t,
restore_record(table,default_values); // Get empty record restore_record(table,default_values); // Get empty record
key_restore(table->record[0],key,table->key_info,key_length); key_restore(table->record[0],key,table->key_info,key_length);
table->field[4]->store(xx->column.ptr(),xx->column.length(), table->field[4]->store(xx->column.ptr(),xx->column.length(),
&my_charset_latin1); system_charset_info);
} }
else else
{ {
...@@ -2160,7 +2168,7 @@ static int replace_column_table(GRANT_TABLE *g_t, ...@@ -2160,7 +2168,7 @@ static int replace_column_table(GRANT_TABLE *g_t,
{ {
GRANT_COLUMN *grant_column = NULL; GRANT_COLUMN *grant_column = NULL;
char colum_name_buf[HOSTNAME_LENGTH+1]; char colum_name_buf[HOSTNAME_LENGTH+1];
String column_name(colum_name_buf,sizeof(colum_name_buf),&my_charset_latin1); String column_name(colum_name_buf,sizeof(colum_name_buf),system_charset_info);
privileges&= ~rights; privileges&= ~rights;
table->field[6]->store((longlong) table->field[6]->store((longlong)
...@@ -2231,10 +2239,10 @@ static int replace_table_table(THD *thd, GRANT_TABLE *grant_table, ...@@ -2231,10 +2239,10 @@ static int replace_table_table(THD *thd, GRANT_TABLE *grant_table,
} }
restore_record(table,default_values); // Get empty record restore_record(table,default_values); // Get empty record
table->field[0]->store(combo.host.str,combo.host.length, &my_charset_latin1); table->field[0]->store(combo.host.str,combo.host.length, system_charset_info);
table->field[1]->store(db,(uint) strlen(db), &my_charset_latin1); table->field[1]->store(db,(uint) strlen(db), system_charset_info);
table->field[2]->store(combo.user.str,combo.user.length, &my_charset_latin1); table->field[2]->store(combo.user.str,combo.user.length, system_charset_info);
table->field[3]->store(table_name,(uint) strlen(table_name), &my_charset_latin1); table->field[3]->store(table_name,(uint) strlen(table_name), system_charset_info);
store_record(table,record[1]); // store at pos 1 store_record(table,record[1]); // store at pos 1
table->file->extra(HA_EXTRA_RETRIEVE_ALL_COLS); table->file->extra(HA_EXTRA_RETRIEVE_ALL_COLS);
if (table->file->index_read_idx(table->record[0],0, if (table->file->index_read_idx(table->record[0],0,
...@@ -2279,7 +2287,7 @@ static int replace_table_table(THD *thd, GRANT_TABLE *grant_table, ...@@ -2279,7 +2287,7 @@ static int replace_table_table(THD *thd, GRANT_TABLE *grant_table,
} }
} }
table->field[4]->store(grantor,(uint) strlen(grantor), &my_charset_latin1); table->field[4]->store(grantor,(uint) strlen(grantor), system_charset_info);
table->field[6]->store((longlong) store_table_rights); table->field[6]->store((longlong) store_table_rights);
table->field[7]->store((longlong) store_col_rights); table->field[7]->store((longlong) store_col_rights);
rights=fix_rights_for_table(store_table_rights); rights=fix_rights_for_table(store_table_rights);
...@@ -2694,7 +2702,7 @@ my_bool grant_init(THD *org_thd) ...@@ -2694,7 +2702,7 @@ my_bool grant_init(THD *org_thd)
DBUG_ENTER("grant_init"); DBUG_ENTER("grant_init");
grant_option = FALSE; grant_option = FALSE;
(void) hash_init(&column_priv_hash,&my_charset_latin1, (void) hash_init(&column_priv_hash,system_charset_info,
0,0,0, (hash_get_key) get_grant_table, 0,0,0, (hash_get_key) get_grant_table,
(hash_free_key) free_grant_table,0); (hash_free_key) free_grant_table,0);
init_sql_alloc(&memex, ACL_ALLOC_BLOCK_SIZE, 0); init_sql_alloc(&memex, ACL_ALLOC_BLOCK_SIZE, 0);
...@@ -2759,8 +2767,11 @@ my_bool grant_init(THD *org_thd) ...@@ -2759,8 +2767,11 @@ my_bool grant_init(THD *org_thd)
} }
} }
if (mem_check->ok() && my_hash_insert(&column_priv_hash,(byte*) mem_check)) if (! mem_check->ok())
delete mem_check;
else if (my_hash_insert(&column_priv_hash,(byte*) mem_check))
{ {
delete mem_check;
grant_option= FALSE; grant_option= FALSE;
goto end_unlock; goto end_unlock;
} }
...@@ -3077,9 +3088,9 @@ bool check_grant_db(THD *thd,const char *db) ...@@ -3077,9 +3088,9 @@ bool check_grant_db(THD *thd,const char *db)
idx); idx);
if (len < grant_table->key_length && if (len < grant_table->key_length &&
!memcmp(grant_table->hash_key,helping,len) && !memcmp(grant_table->hash_key,helping,len) &&
(thd->host && !wild_case_compare(&my_charset_latin1, (thd->host && !wild_case_compare(system_charset_info,
thd->host,grant_table->host) || thd->host,grant_table->host) ||
(thd->ip && !wild_case_compare(&my_charset_latin1, (thd->ip && !wild_case_compare(system_charset_info,
thd->ip,grant_table->host)))) thd->ip,grant_table->host))))
{ {
error=0; // Found match error=0; // Found match
...@@ -3230,7 +3241,7 @@ bool mysql_show_grants(THD *thd,LEX_USER *lex_user) ...@@ -3230,7 +3241,7 @@ bool mysql_show_grants(THD *thd,LEX_USER *lex_user)
if (!(host=acl_user->host.hostname)) if (!(host=acl_user->host.hostname))
host= ""; host= "";
if (!strcmp(lex_user->user.str,user) && if (!strcmp(lex_user->user.str,user) &&
!my_strcasecmp(&my_charset_latin1, lex_user->host.str, host)) !my_strcasecmp(system_charset_info, lex_user->host.str, host))
break; break;
} }
if (counter == acl_users.elements) if (counter == acl_users.elements)
...@@ -3284,7 +3295,8 @@ bool mysql_show_grants(THD *thd,LEX_USER *lex_user) ...@@ -3284,7 +3295,8 @@ bool mysql_show_grants(THD *thd,LEX_USER *lex_user)
global.append(lex_user->user.str, lex_user->user.length, global.append(lex_user->user.str, lex_user->user.length,
system_charset_info); system_charset_info);
global.append ("'@'",3); global.append ("'@'",3);
global.append(lex_user->host.str,lex_user->host.length); global.append(lex_user->host.str,lex_user->host.length,
system_charset_info);
global.append ('\''); global.append ('\'');
if (acl_user->salt_len) if (acl_user->salt_len)
{ {
...@@ -3318,7 +3330,8 @@ bool mysql_show_grants(THD *thd,LEX_USER *lex_user) ...@@ -3318,7 +3330,8 @@ bool mysql_show_grants(THD *thd,LEX_USER *lex_user)
if (ssl_options++) if (ssl_options++)
global.append(' '); global.append(' ');
global.append("SUBJECT \'",9); global.append("SUBJECT \'",9);
global.append(acl_user->x509_subject,strlen(acl_user->x509_subject)); global.append(acl_user->x509_subject,strlen(acl_user->x509_subject),
system_charset_info);
global.append('\''); global.append('\'');
} }
if (acl_user->ssl_cipher) if (acl_user->ssl_cipher)
...@@ -3326,7 +3339,8 @@ bool mysql_show_grants(THD *thd,LEX_USER *lex_user) ...@@ -3326,7 +3339,8 @@ bool mysql_show_grants(THD *thd,LEX_USER *lex_user)
if (ssl_options++) if (ssl_options++)
global.append(' '); global.append(' ');
global.append("CIPHER '",8); global.append("CIPHER '",8);
global.append(acl_user->ssl_cipher,strlen(acl_user->ssl_cipher)); global.append(acl_user->ssl_cipher,strlen(acl_user->ssl_cipher),
system_charset_info);
global.append('\''); global.append('\'');
} }
} }
...@@ -3365,7 +3379,7 @@ bool mysql_show_grants(THD *thd,LEX_USER *lex_user) ...@@ -3365,7 +3379,7 @@ bool mysql_show_grants(THD *thd,LEX_USER *lex_user)
host= ""; host= "";
if (!strcmp(lex_user->user.str,user) && if (!strcmp(lex_user->user.str,user) &&
!my_strcasecmp(&my_charset_latin1, lex_user->host.str, host)) !my_strcasecmp(system_charset_info, lex_user->host.str, host))
{ {
want_access=acl_db->access; want_access=acl_db->access;
if (want_access) if (want_access)
...@@ -3399,7 +3413,8 @@ bool mysql_show_grants(THD *thd,LEX_USER *lex_user) ...@@ -3399,7 +3413,8 @@ bool mysql_show_grants(THD *thd,LEX_USER *lex_user)
db.append(lex_user->user.str, lex_user->user.length, db.append(lex_user->user.str, lex_user->user.length,
system_charset_info); system_charset_info);
db.append ("'@'",3); db.append ("'@'",3);
db.append(lex_user->host.str, lex_user->host.length); db.append(lex_user->host.str, lex_user->host.length,
system_charset_info);
db.append ('\''); db.append ('\'');
if (want_access & GRANT_ACL) if (want_access & GRANT_ACL)
db.append(" WITH GRANT OPTION",18); db.append(" WITH GRANT OPTION",18);
...@@ -3425,7 +3440,7 @@ bool mysql_show_grants(THD *thd,LEX_USER *lex_user) ...@@ -3425,7 +3440,7 @@ bool mysql_show_grants(THD *thd,LEX_USER *lex_user)
user= ""; user= "";
if (!strcmp(lex_user->user.str,user) && if (!strcmp(lex_user->user.str,user) &&
!my_strcasecmp(&my_charset_latin1, lex_user->host.str, !my_strcasecmp(system_charset_info, lex_user->host.str,
grant_table->orig_host)) grant_table->orig_host))
{ {
ulong table_access= grant_table->privs; ulong table_access= grant_table->privs;
...@@ -3505,7 +3520,8 @@ bool mysql_show_grants(THD *thd,LEX_USER *lex_user) ...@@ -3505,7 +3520,8 @@ bool mysql_show_grants(THD *thd,LEX_USER *lex_user)
global.append(lex_user->user.str, lex_user->user.length, global.append(lex_user->user.str, lex_user->user.length,
system_charset_info); system_charset_info);
global.append("'@'",3); global.append("'@'",3);
global.append(lex_user->host.str,lex_user->host.length); global.append(lex_user->host.str,lex_user->host.length,
system_charset_info);
global.append('\''); global.append('\'');
if (table_access & GRANT_ACL) if (table_access & GRANT_ACL)
global.append(" WITH GRANT OPTION",18); global.append(" WITH GRANT OPTION",18);
...@@ -3565,6 +3581,27 @@ void get_mqh(const char *user, const char *host, USER_CONN *uc) ...@@ -3565,6 +3581,27 @@ void get_mqh(const char *user, const char *host, USER_CONN *uc)
bzero((char*) &uc->user_resources, sizeof(uc->user_resources)); bzero((char*) &uc->user_resources, sizeof(uc->user_resources));
} }
/*
Open the grant tables.
SYNOPSIS
open_grant_tables()
thd The current thread.
tables (out) The 4 elements array for the opened tables.
DESCRIPTION
Tables are numbered as follows:
0 user
1 db
2 tables_priv
3 columns_priv
RETURN
1 Skip GRANT handling during replication.
0 OK.
< 0 Error.
*/
int open_grant_tables(THD *thd, TABLE_LIST *tables) int open_grant_tables(THD *thd, TABLE_LIST *tables)
{ {
DBUG_ENTER("open_grant_tables"); DBUG_ENTER("open_grant_tables");
...@@ -3640,111 +3677,641 @@ ACL_USER *check_acl_user(LEX_USER *user_name, ...@@ -3640,111 +3677,641 @@ ACL_USER *check_acl_user(LEX_USER *user_name,
} }
bool mysql_drop_user(THD *thd, List <LEX_USER> &list) /*
Modify a privilege table.
SYNOPSIS
modify_grant_table()
table The table to modify.
host_field The host name field.
user_field The user name field.
user_to The new name for the user if to be renamed,
NULL otherwise.
DESCRIPTION
Update user/host in the current record if user_to is not NULL.
Delete the current record if user_to is NULL.
RETURN
0 OK.
!= 0 Error.
*/
static int modify_grant_table(TABLE *table, Field *host_field,
Field *user_field, LEX_USER *user_to)
{ {
uint counter, acl_userd; int error;
int result; DBUG_ENTER("modify_grant_table");
ACL_USER *acl_user;
ACL_DB *acl_db;
TABLE_LIST tables[4];
DBUG_ENTER("mysql_drop_user"); if (user_to)
{
/* rename */
store_record(table, record[1]);
host_field->store(user_to->host.str, user_to->host.length,
system_charset_info);
user_field->store(user_to->user.str, user_to->user.length,
system_charset_info);
if ((error= table->file->update_row(table->record[1], table->record[0])))
table->file->print_error(error, MYF(0));
}
else
{
/* delete */
if ((error=table->file->delete_row(table->record[0])))
table->file->print_error(error, MYF(0));
}
if ((result= open_grant_tables(thd, tables))) DBUG_RETURN(error);
DBUG_RETURN(result != 1); }
rw_wrlock(&LOCK_grant);
VOID(pthread_mutex_lock(&acl_cache->lock));
LEX_USER *user_name; /*
List_iterator <LEX_USER> user_list(list); Handle a privilege table.
while ((user_name=user_list++))
SYNOPSIS
handle_grant_table()
tables The array with the four open tables.
table_no The number of the table to handle (0..3).
drop If user_from is to be dropped.
user_from The the user to be searched/dropped/renamed.
user_to The new name for the user if to be renamed,
NULL otherwise.
DESCRIPTION
Scan through all records in a grant table and apply the requested
operation. For the "user" table, a single index access is sufficient,
since there is an unique index on (host, user).
Delete from grant table if drop is true.
Update in grant table if drop is false and user_to is not NULL.
Search in grant table if drop is false and user_to is NULL.
Tables are numbered as follows:
0 user
1 db
2 tables_priv
3 columns_priv
RETURN
> 0 At least one record matched.
0 OK, but no record matched.
< 0 Error.
*/
static int handle_grant_table(TABLE_LIST *tables, uint table_no, bool drop,
LEX_USER *user_from, LEX_USER *user_to)
{
int result= 0;
int error;
TABLE *table= tables[table_no].table;
Field *host_field= table->field[0];
Field *user_field= table->field[table_no ? 2 : 1];
char *host_str= user_from->host.str;
char *user_str= user_from->user.str;
const char *host;
const char *user;
DBUG_ENTER("handle_grant_table");
if (! table_no)
{ {
if (!(acl_user= check_acl_user(user_name, &counter))) /*
The 'user' table has an unique index on (host, user).
Thus, we can handle everything with a single index access.
The host- and user fields are consecutive in the user table records.
So we set host- and user fields of table->record[0] and use the
pointer to the host field as key.
index_read_idx() will replace table->record[0] (its first argument)
by the searched record, if it exists.
*/
DBUG_PRINT("info",("read table: '%s' search: '%s'@'%s'",
table->real_name, user_str, host_str));
host_field->store(host_str, user_from->host.length, system_charset_info);
user_field->store(user_str, user_from->user.length, system_charset_info);
if ((error= table->file->index_read_idx(table->record[0], 0,
(byte*) host_field->ptr, 0,
HA_READ_KEY_EXACT)))
{ {
sql_print_error("DROP USER: Can't drop user: '%s'@'%s'; No such user", if (error != HA_ERR_KEY_NOT_FOUND)
user_name->user.str, {
user_name->host.str); table->file->print_error(error, MYF(0));
result= -1; result= -1;
continue;
} }
if ((acl_user->access & ~0)) }
else
{ {
sql_print_error("DROP USER: Can't drop user: '%s'@'%s'; Global privileges exists", /* If requested, delete or update the record. */
user_name->user.str, result= ((drop || user_to) &&
user_name->host.str); modify_grant_table(table, host_field, user_field, user_to)) ?
-1 : 1; /* Error or found. */
}
DBUG_PRINT("info",("read result: %d", result));
}
else
{
/*
The non-'user' table do not have indexes on (host, user).
And their host- and user fields are not consecutive.
Thus, we need to do a table scan to find all matching records.
*/
if ((error= table->file->ha_rnd_init(1)))
{
table->file->print_error(error, MYF(0));
result= -1; result= -1;
}
else
{
#ifdef EXTRA_DEBUG
DBUG_PRINT("info",("scan table: '%s' search: '%s'@'%s'",
table->real_name, user_str, host_str));
#endif
while ((error= table->file->rnd_next(table->record[0])) !=
HA_ERR_END_OF_FILE)
{
if (error)
{
/* Most probable 'deleted record'. */
DBUG_PRINT("info",("scan error: %d", error));
continue;
}
if (! (host= get_field(&mem, host_field)))
host= "";
if (! (user= get_field(&mem, user_field)))
user= "";
#ifdef EXTRA_DEBUG
DBUG_PRINT("loop",("scan fields: '%s'@'%s' '%s' '%s' '%s'",
user, host,
get_field(&mem, table->field[1]) /*db*/,
get_field(&mem, table->field[3]) /*table*/,
get_field(&mem, table->field[4]) /*column*/));
#endif
if (strcmp(user_str, user) ||
my_strcasecmp(system_charset_info, host_str, host))
continue; continue;
/* If requested, delete or update the record. */
result= ((drop || user_to) &&
modify_grant_table(table, host_field, user_field, user_to)) ?
-1 : result ? result : 1; /* Error or keep result or found. */
/* If search is requested, we do not need to search further. */
if (! drop && ! user_to)
break ;
}
(void) table->file->ha_rnd_end();
DBUG_PRINT("info",("scan result: %d", result));
}
} }
acl_userd= counter;
for (counter= 0 ; counter < acl_dbs.elements ; counter++) DBUG_RETURN(result);
}
/*
Handle an in-memory privilege structure.
SYNOPSIS
handle_grant_struct()
struct_no The number of the structure to handle (0..2).
drop If user_from is to be dropped.
user_from The the user to be searched/dropped/renamed.
user_to The new name for the user if to be renamed,
NULL otherwise.
DESCRIPTION
Scan through all elements in an in-memory grant structure and apply
the requested operation.
Delete from grant structure if drop is true.
Update in grant structure if drop is false and user_to is not NULL.
Search in grant structure if drop is false and user_to is NULL.
Structures are numbered as follows:
0 acl_users
1 acl_dbs
2 column_priv_hash
RETURN
> 0 At least one element matched.
0 OK, but no element matched.
*/
static int handle_grant_struct(uint struct_no, bool drop,
LEX_USER *user_from, LEX_USER *user_to)
{
int result= 0;
uint idx;
uint elements;
const char *user;
const char *host;
ACL_USER *acl_user;
ACL_DB *acl_db;
GRANT_TABLE *grant_table;
DBUG_ENTER("handle_grant_struct");
LINT_INIT(acl_user);
LINT_INIT(acl_db);
LINT_INIT(grant_table);
DBUG_PRINT("info",("scan struct: %u search: '%s'@'%s'",
struct_no, user_from->user.str, user_from->host.str));
/* Get the number of elements in the in-memory structure. */
switch (struct_no)
{ {
const char *user,*host; case 0:
acl_db=dynamic_element(&acl_dbs,counter,ACL_DB*); elements= acl_users.elements;
if (!(user= acl_db->user)) break;
case 1:
elements= acl_dbs.elements;
break;
default:
elements= column_priv_hash.records;
}
#ifdef EXTRA_DEBUG
DBUG_PRINT("loop",("scan struct: %u search user: '%s' host: '%s'",
struct_no, user_from->user.str, user_from->host.str));
#endif
/* Loop over all elements. */
for (idx= 0; idx < elements; idx++)
{
/*
Get a pointer to the element.
Unfortunaltely, the host default differs for the structures.
*/
switch (struct_no)
{
case 0:
acl_user= dynamic_element(&acl_users, idx, ACL_USER*);
user= acl_user->user;
if (!(host= acl_user->host.hostname))
host= "%";
break;
case 1:
acl_db= dynamic_element(&acl_dbs, idx, ACL_DB*);
user= acl_db->user;
host= acl_db->host.hostname;
break;
default:
grant_table= (GRANT_TABLE*) hash_element(&column_priv_hash, idx);
user= grant_table->user;
host= grant_table->host;
}
if (! user)
user= ""; user= "";
if (!(host= acl_db->host.hostname)) if (! host)
host= ""; host= "";
#ifdef EXTRA_DEBUG
DBUG_PRINT("loop",("scan struct: %u index: %u user: '%s' host: '%s'",
struct_no, idx, user, host));
#endif
if (strcmp(user_from->user.str, user) ||
my_strcasecmp(system_charset_info, user_from->host.str, host))
continue;
if (!strcmp(user_name->user.str,user) && result= 1; /* At least one element found. */
!my_strcasecmp(system_charset_info, user_name->host.str, host)) if ( drop )
{
switch ( struct_no )
{
case 0:
delete_dynamic_element(&acl_users, idx);
break;
case 1:
delete_dynamic_element(&acl_dbs, idx);
break;
default:
hash_delete(&column_priv_hash, (byte*) grant_table);
}
elements--;
idx--;
}
else if ( user_to )
{
switch ( struct_no )
{
case 0:
acl_user->user= strdup_root(&mem, user_to->user.str);
acl_user->host.hostname= strdup_root(&mem, user_to->host.str);
break;
case 1:
acl_db->user= strdup_root(&mem, user_to->user.str);
acl_db->host.hostname= strdup_root(&mem, user_to->host.str);
break; break;
default:
grant_table->user= strdup_root(&mem, user_to->user.str);
grant_table->host= strdup_root(&mem, user_to->host.str);
} }
if (counter != acl_dbs.elements) }
else
{ {
sql_print_error("DROP USER: Can't drop user: '%s'@'%s'; Database privileges exists", /* If search is requested, we do not need to search further. */
break;
}
}
#ifdef EXTRA_DEBUG
DBUG_PRINT("loop",("scan struct: %u result %d", struct_no, result));
#endif
DBUG_RETURN(result);
}
/*
Handle all privilege tables and in-memory privilege structures.
SYNOPSIS
handle_grant_data()
tables The array with the four open tables.
drop If user_from is to be dropped.
user_from The the user to be searched/dropped/renamed.
user_to The new name for the user if to be renamed,
NULL otherwise.
DESCRIPTION
Go through all grant tables and in-memory grant structures and apply
the requested operation.
Delete from grant data if drop is true.
Update in grant data if drop is false and user_to is not NULL.
Search in grant data if drop is false and user_to is NULL.
RETURN
> 0 At least one element matched.
0 OK, but no element matched.
< 0 Error.
*/
static int handle_grant_data(TABLE_LIST *tables, bool drop,
LEX_USER *user_from, LEX_USER *user_to)
{
int result= 0;
int found;
DBUG_ENTER("handle_grant_data");
/* Handle user table. */
if ((found= handle_grant_table(tables, 0, drop, user_from, user_to)) < 0)
{
/* Handle of table failed, don't touch the in-memory array. */
result= -1;
}
else
{
/* Handle user array. */
if ((handle_grant_struct(0, drop, user_from, user_to) && ! result) || found)
{
result= 1; /* At least one record/element found. */
/* If search is requested, we do not need to search further. */
if (! drop && ! user_to)
goto end;
}
}
/* Handle db table. */
if ((found= handle_grant_table(tables, 1, drop, user_from, user_to)) < 0)
{
/* Handle of table failed, don't touch the in-memory array. */
result= -1;
}
else
{
/* Handle db array. */
if (((handle_grant_struct(1, drop, user_from, user_to) && ! result) ||
found) && ! result)
{
result= 1; /* At least one record/element found. */
/* If search is requested, we do not need to search further. */
if (! drop && ! user_to)
goto end;
}
}
/* Handle tables table. */
if ((found= handle_grant_table(tables, 2, drop, user_from, user_to)) < 0)
{
/* Handle of table failed, don't touch columns and in-memory array. */
result= -1;
}
else
{
if (found && ! result)
{
result= 1; /* At least one record found. */
/* If search is requested, we do not need to search further. */
if (! drop && ! user_to)
goto end;
}
/* Handle columns table. */
if ((found= handle_grant_table(tables, 3, drop, user_from, user_to)) < 0)
{
/* Handle of table failed, don't touch the in-memory array. */
result= -1;
}
else
{
/* Handle columns hash. */
if (((handle_grant_struct(2, drop, user_from, user_to) && ! result) ||
found) && ! result)
result= 1; /* At least one record/element found. */
}
}
end:
DBUG_RETURN(result);
}
/*
Create a list of users.
SYNOPSIS
mysql_create_user()
thd The current thread.
list The users to create.
RETURN
FALSE OK.
TRUE Error.
*/
bool mysql_create_user(THD *thd, List <LEX_USER> &list)
{
int result;
int found;
uint failures;
ulong sql_mode;
LEX_USER *user_name;
List_iterator <LEX_USER> user_list(list);
TABLE_LIST tables[4];
DBUG_ENTER("mysql_create_user");
/* CREATE USER may be skipped on replication client. */
if ((result= open_grant_tables(thd, tables)))
DBUG_RETURN(result != 1);
rw_wrlock(&LOCK_grant);
VOID(pthread_mutex_lock(&acl_cache->lock));
failures= 0;
while ((user_name= user_list++))
{
/*
Search all in-memory structures and grant tables
for a mention of the new user name.
*/
if ((found= handle_grant_data(tables, 0, user_name, NULL)))
{
if (found > 0)
sql_print_error("CREATE USER: Cannot create user: '%s'@'%s': "
"User exists",
user_name->user.str, user_name->user.str,
user_name->host.str); user_name->host.str);
result= -1; failures++;
continue; result= TRUE;
} }
for (counter= 0 ; counter < column_priv_hash.records ; counter++) sql_mode= thd->variables.sql_mode;
thd->variables.sql_mode&= ~MODE_NO_AUTO_CREATE_USER;
if (replace_user_table(thd, tables[0].table, *user_name, 0, 0, 1))
{ {
const char *user,*host; failures++;
GRANT_TABLE *grant_table= (GRANT_TABLE*) hash_element(&column_priv_hash, result= TRUE;
counter); }
if (!(user=grant_table->user)) thd->variables.sql_mode= sql_mode;
user= ""; }
if (!(host=grant_table->host))
host= "";
if (!strcmp(user_name->user.str,user) && VOID(pthread_mutex_unlock(&acl_cache->lock));
!my_strcasecmp(system_charset_info, user_name->host.str, host)) rw_unlock(&LOCK_grant);
break; close_thread_tables(thd);
if (result)
my_error(ER_HANDLE_USER, MYF(0), "CREATE USER" , failures );
DBUG_RETURN(result);
}
/*
Drop a list of users and all their privileges.
SYNOPSIS
mysql_drop_user()
thd The current thread.
list The users to drop.
RETURN
FALSE OK.
TRUE Error.
*/
bool mysql_drop_user(THD *thd, List <LEX_USER> &list)
{
int result;
int found;
uint failures;
LEX_USER *user_name;
List_iterator <LEX_USER> user_list(list);
TABLE_LIST tables[4];
DBUG_ENTER("mysql_drop_user");
/* CREATE USER may be skipped on replication client. */
if ((result= open_grant_tables(thd, tables)))
DBUG_RETURN(result != 1);
rw_wrlock(&LOCK_grant);
VOID(pthread_mutex_lock(&acl_cache->lock));
failures= 0;
while ((user_name= user_list++))
{
if ((found= handle_grant_data(tables, 1, user_name, NULL)) < 0)
{
failures++;
result= TRUE;
} }
if (counter != column_priv_hash.records) else if (! found)
{ {
sql_print_error("DROP USER: Can't drop user: '%s'@'%s'; Table privileges exists", sql_print_error("DROP USER: Cannot drop user '%s'@'%s': "
"No such user",
user_name->user.str, user_name->user.str,
user_name->host.str); user_name->host.str);
result= -1; failures++;
continue; result= TRUE;
}
} }
tables[0].table->field[0]->store(user_name->host.str,(uint) VOID(pthread_mutex_unlock(&acl_cache->lock));
user_name->host.length, rw_unlock(&LOCK_grant);
system_charset_info); close_thread_tables(thd);
tables[0].table->field[1]->store(user_name->user.str,(uint) if (result)
user_name->user.length, my_error(ER_HANDLE_USER, MYF(0), "DROP USER" , failures );
system_charset_info); DBUG_RETURN(result);
tables[0].table->file->extra(HA_EXTRA_RETRIEVE_ALL_COLS); }
if (!tables[0].table->file->index_read_idx(tables[0].table->record[0],0,
(byte*) tables[0].table->
field[0]->ptr, /*
tables[0].table-> Rename a user.
key_info[0].key_length,
HA_READ_KEY_EXACT)) SYNOPSIS
mysql_rename_user()
thd The current thread.
list The user name pairs: (from, to).
RETURN
FALSE OK.
TRUE Error.
*/
bool mysql_rename_user(THD *thd, List <LEX_USER> &list)
{
int result= 0;
int found;
uint failures;
LEX_USER *user_from;
LEX_USER *user_to;
List_iterator <LEX_USER> user_list(list);
TABLE_LIST tables[4];
DBUG_ENTER("mysql_rename_user");
/* CREATE USER may be skipped on replication client. */
if ((result= open_grant_tables(thd, tables)))
DBUG_RETURN(result != 1);
rw_wrlock(&LOCK_grant);
VOID(pthread_mutex_lock(&acl_cache->lock));
failures= 0;
while ((user_from= user_list++))
{ {
int error; user_to= user_list++;
if ((error = tables[0].table->file->delete_row(tables[0].table-> DBUG_ASSERT((user_to)); /* Syntax enforces pairs of users. */
record[0])))
/*
Search all in-memory structures and grant tables
for a mention of the new user name.
*/
if ((found= handle_grant_data(tables, 0, user_to, NULL)))
{ {
tables[0].table->file->print_error(error, MYF(0)); if (found > 0)
DBUG_RETURN(TRUE); sql_print_error("RENAME USER: Cannot rename to: '%s'@'%s': User exists",
user_to->user.str,
user_to->host.str);
failures++;
result= TRUE;
}
else
{
if ((found= handle_grant_data(tables, 0, user_from, user_to)) < 0)
{
failures++;
result= TRUE;
}
else if (! found)
{
sql_print_error("RENAME USER: Cannot rename user: '%s'@'%s': "
"No such user",
user_from->user.str,
user_from->host.str);
failures++;
result= TRUE;
} }
delete_dynamic_element(&acl_users, acl_userd);
} }
} }
...@@ -3752,10 +4319,24 @@ bool mysql_drop_user(THD *thd, List <LEX_USER> &list) ...@@ -3752,10 +4319,24 @@ bool mysql_drop_user(THD *thd, List <LEX_USER> &list)
rw_unlock(&LOCK_grant); rw_unlock(&LOCK_grant);
close_thread_tables(thd); close_thread_tables(thd);
if (result) if (result)
my_message(ER_DROP_USER, ER(ER_DROP_USER), MYF(0)); my_error(ER_HANDLE_USER, MYF(0), "RENAME USER", failures);
DBUG_RETURN(result); DBUG_RETURN(result);
} }
/*
Revoke all privileges from a list of users.
SYNOPSIS
mysql_revoke_all()
thd The current thread.
list The users to revoke all privileges from.
RETURN
> 0 Error. Error message already sent.
0 OK.
< 0 Error. Error message not yet sent.
*/
bool mysql_revoke_all(THD *thd, List <LEX_USER> &list) bool mysql_revoke_all(THD *thd, List <LEX_USER> &list)
{ {
uint counter, revoked; uint counter, revoked;
......
...@@ -182,7 +182,9 @@ ulong get_column_grant(THD *thd, GRANT_INFO *grant, ...@@ -182,7 +182,9 @@ ulong get_column_grant(THD *thd, GRANT_INFO *grant,
bool mysql_show_grants(THD *thd, LEX_USER *user); bool mysql_show_grants(THD *thd, LEX_USER *user);
void get_privilege_desc(char *to, uint max_length, ulong access); void get_privilege_desc(char *to, uint max_length, ulong access);
void get_mqh(const char *user, const char *host, USER_CONN *uc); void get_mqh(const char *user, const char *host, USER_CONN *uc);
bool mysql_create_user(THD *thd, List <LEX_USER> &list);
bool mysql_drop_user(THD *thd, List <LEX_USER> &list); bool mysql_drop_user(THD *thd, List <LEX_USER> &list);
bool mysql_rename_user(THD *thd, List <LEX_USER> &list);
bool mysql_revoke_all(THD *thd, List <LEX_USER> &list); bool mysql_revoke_all(THD *thd, List <LEX_USER> &list);
void fill_effective_table_privileges(THD *thd, GRANT_INFO *grant, void fill_effective_table_privileges(THD *thd, GRANT_INFO *grant,
const char *db, const char *table); const char *db, const char *table);
......
...@@ -78,7 +78,8 @@ enum enum_sql_command { ...@@ -78,7 +78,8 @@ enum enum_sql_command {
SQLCOM_SHOW_BINLOG_EVENTS, SQLCOM_SHOW_NEW_MASTER, SQLCOM_DO, SQLCOM_SHOW_BINLOG_EVENTS, SQLCOM_SHOW_NEW_MASTER, SQLCOM_DO,
SQLCOM_SHOW_WARNS, SQLCOM_EMPTY_QUERY, SQLCOM_SHOW_ERRORS, SQLCOM_SHOW_WARNS, SQLCOM_EMPTY_QUERY, SQLCOM_SHOW_ERRORS,
SQLCOM_SHOW_COLUMN_TYPES, SQLCOM_SHOW_STORAGE_ENGINES, SQLCOM_SHOW_PRIVILEGES, SQLCOM_SHOW_COLUMN_TYPES, SQLCOM_SHOW_STORAGE_ENGINES, SQLCOM_SHOW_PRIVILEGES,
SQLCOM_HELP, SQLCOM_DROP_USER, SQLCOM_REVOKE_ALL, SQLCOM_CHECKSUM, SQLCOM_HELP, SQLCOM_CREATE_USER, SQLCOM_DROP_USER, SQLCOM_RENAME_USER,
SQLCOM_REVOKE_ALL, SQLCOM_CHECKSUM,
SQLCOM_CREATE_PROCEDURE, SQLCOM_CREATE_SPFUNCTION, SQLCOM_CALL, SQLCOM_CREATE_PROCEDURE, SQLCOM_CREATE_SPFUNCTION, SQLCOM_CALL,
SQLCOM_DROP_PROCEDURE, SQLCOM_ALTER_PROCEDURE,SQLCOM_ALTER_FUNCTION, SQLCOM_DROP_PROCEDURE, SQLCOM_ALTER_PROCEDURE,SQLCOM_ALTER_FUNCTION,
SQLCOM_SHOW_CREATE_PROC, SQLCOM_SHOW_CREATE_FUNC, SQLCOM_SHOW_CREATE_PROC, SQLCOM_SHOW_CREATE_FUNC,
...@@ -650,7 +651,6 @@ typedef struct st_lex ...@@ -650,7 +651,6 @@ typedef struct st_lex
char *help_arg; char *help_arg;
char *backup_dir; /* For RESTORE/BACKUP */ char *backup_dir; /* For RESTORE/BACKUP */
char* to_log; /* For PURGE MASTER LOGS TO */ char* to_log; /* For PURGE MASTER LOGS TO */
time_t purge_time; /* For PURGE MASTER LOGS BEFORE */
char* x509_subject,*x509_issuer,*ssl_cipher; char* x509_subject,*x509_issuer,*ssl_cipher;
char* found_colon; /* For multi queries - next query */ char* found_colon; /* For multi queries - next query */
String *wild; String *wild;
...@@ -694,7 +694,7 @@ typedef struct st_lex ...@@ -694,7 +694,7 @@ typedef struct st_lex
HA_CREATE_INFO create_info; HA_CREATE_INFO create_info;
LEX_MASTER_INFO mi; // used by CHANGE MASTER LEX_MASTER_INFO mi; // used by CHANGE MASTER
USER_RESOURCES mqh; USER_RESOURCES mqh;
ulong thread_id,type; ulong type;
enum_sql_command sql_command, orig_sql_command; enum_sql_command sql_command, orig_sql_command;
thr_lock_type lock_option, multi_lock_option; thr_lock_type lock_option, multi_lock_option;
enum SSL_type ssl_type; /* defined in violite.h */ enum SSL_type ssl_type; /* defined in violite.h */
......
...@@ -2327,10 +2327,24 @@ mysql_execute_command(THD *thd) ...@@ -2327,10 +2327,24 @@ mysql_execute_command(THD *thd)
} }
case SQLCOM_PURGE_BEFORE: case SQLCOM_PURGE_BEFORE:
{ {
Item *it;
if (check_global_access(thd, SUPER_ACL)) if (check_global_access(thd, SUPER_ACL))
goto error; goto error;
/* PURGE MASTER LOGS BEFORE 'data' */ /* PURGE MASTER LOGS BEFORE 'data' */
res = purge_master_logs_before_date(thd, lex->purge_time); it= (Item *)lex->value_list.head();
if (it->check_cols(1) || it->fix_fields(lex->thd, 0, &it))
{
my_error(ER_WRONG_ARGUMENTS, MYF(0), "PURGE LOGS BEFORE");
goto error;
}
it= new Item_func_unix_timestamp(it);
/*
it is OK only emulate fix_fieds, because we need only
value of constant
*/
it->quick_fix_field();
res = purge_master_logs_before_date(thd, (ulong)it->val_int());
break; break;
} }
#endif #endif
...@@ -3370,6 +3384,21 @@ create_error: ...@@ -3370,6 +3384,21 @@ create_error:
break; break;
} }
#ifndef NO_EMBEDDED_ACCESS_CHECKS #ifndef NO_EMBEDDED_ACCESS_CHECKS
case SQLCOM_CREATE_USER:
{
if (check_access(thd, GRANT_ACL,"mysql",0,1,0))
break;
if (!(res= mysql_create_user(thd, lex->users_list)))
{
if (mysql_bin_log.is_open())
{
Query_log_event qinfo(thd, thd->query, thd->query_length, 0);
mysql_bin_log.write(&qinfo);
}
send_ok(thd);
}
break;
}
case SQLCOM_DROP_USER: case SQLCOM_DROP_USER:
{ {
if (check_access(thd, GRANT_ACL,"mysql",0,1,0)) if (check_access(thd, GRANT_ACL,"mysql",0,1,0))
...@@ -3385,6 +3414,21 @@ create_error: ...@@ -3385,6 +3414,21 @@ create_error:
} }
break; break;
} }
case SQLCOM_RENAME_USER:
{
if (check_access(thd, GRANT_ACL,"mysql",0,1,0))
break;
if (!(res= mysql_rename_user(thd, lex->users_list)))
{
if (mysql_bin_log.is_open())
{
Query_log_event qinfo(thd, thd->query, thd->query_length, 0);
mysql_bin_log.write(&qinfo);
}
send_ok(thd);
}
break;
}
case SQLCOM_REVOKE_ALL: case SQLCOM_REVOKE_ALL:
{ {
if (check_access(thd, GRANT_ACL ,"mysql",0,1,0)) if (check_access(thd, GRANT_ACL ,"mysql",0,1,0))
...@@ -3505,8 +3549,18 @@ create_error: ...@@ -3505,8 +3549,18 @@ create_error:
break; break;
} }
case SQLCOM_KILL: case SQLCOM_KILL:
kill_one_thread(thd,lex->thread_id, lex->type & ONLY_KILL_QUERY); {
Item *it= (Item *)lex->value_list.head();
if (it->fix_fields(lex->thd, 0, &it) || it->check_cols(1))
{
my_message(ER_SET_CONSTANTS_ONLY, ER(ER_SET_CONSTANTS_ONLY),
MYF(0));
goto error;
}
kill_one_thread(thd, (ulong)it->val_int(), lex->type & ONLY_KILL_QUERY);
break; break;
}
#ifndef NO_EMBEDDED_ACCESS_CHECKS #ifndef NO_EMBEDDED_ACCESS_CHECKS
case SQLCOM_SHOW_GRANTS: case SQLCOM_SHOW_GRANTS:
if ((thd->priv_user && if ((thd->priv_user &&
......
...@@ -2628,7 +2628,7 @@ static int get_schema_stat_record(THD *thd, struct st_table_list *tables, ...@@ -2628,7 +2628,7 @@ static int get_schema_stat_record(THD *thd, struct st_table_list *tables,
{ {
CHARSET_INFO *cs= system_charset_info; CHARSET_INFO *cs= system_charset_info;
DBUG_ENTER("get_schema_stat_record"); DBUG_ENTER("get_schema_stat_record");
if (!res) if (!res && !tables->view)
{ {
TABLE *show_table= tables->table; TABLE *show_table= tables->table;
KEY *key_info=show_table->key_info; KEY *key_info=show_table->key_info;
...@@ -2737,7 +2737,7 @@ static int get_schema_constarints_record(THD *thd, struct st_table_list *tables, ...@@ -2737,7 +2737,7 @@ static int get_schema_constarints_record(THD *thd, struct st_table_list *tables,
{ {
CHARSET_INFO *cs= system_charset_info; CHARSET_INFO *cs= system_charset_info;
DBUG_ENTER("get_schema_constarints_record"); DBUG_ENTER("get_schema_constarints_record");
if (!res) if (!res && !tables->view)
{ {
List<FOREIGN_KEY_INFO> f_key_list; List<FOREIGN_KEY_INFO> f_key_list;
TABLE *show_table= tables->table; TABLE *show_table= tables->table;
...@@ -2792,7 +2792,7 @@ static int get_schema_key_column_usage_record(THD *thd, ...@@ -2792,7 +2792,7 @@ static int get_schema_key_column_usage_record(THD *thd,
{ {
DBUG_ENTER("get_schema_key_column_usage_record"); DBUG_ENTER("get_schema_key_column_usage_record");
CHARSET_INFO *cs= system_charset_info; CHARSET_INFO *cs= system_charset_info;
if (!res) if (!res && !tables->view)
{ {
List<FOREIGN_KEY_INFO> f_key_list; List<FOREIGN_KEY_INFO> f_key_list;
TABLE *show_table= tables->table; TABLE *show_table= tables->table;
...@@ -2960,7 +2960,7 @@ TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list) ...@@ -2960,7 +2960,7 @@ TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list)
field_list, (ORDER*) 0, 0, 0, field_list, (ORDER*) 0, 0, 0,
(select_lex->options | thd->options | (select_lex->options | thd->options |
TMP_TABLE_ALL_COLUMNS), TMP_TABLE_ALL_COLUMNS),
HA_POS_ERROR, table_list->real_name))) HA_POS_ERROR, table_list->alias)))
DBUG_RETURN(0); DBUG_RETURN(0);
DBUG_RETURN(table); DBUG_RETURN(table);
} }
...@@ -3136,6 +3136,9 @@ int mysql_schema_table(THD *thd, LEX *lex, TABLE_LIST *table_list) ...@@ -3136,6 +3136,9 @@ int mysql_schema_table(THD *thd, LEX *lex, TABLE_LIST *table_list)
} }
table->tmp_table= TMP_TABLE; table->tmp_table= TMP_TABLE;
table->grant.privilege= SELECT_ACL; table->grant.privilege= SELECT_ACL;
table->alias_name_used= my_strcasecmp(table_alias_charset,
table_list->real_name,
table_list->alias);
table_list->schema_table_name= table_list->real_name; table_list->schema_table_name= table_list->real_name;
table_list->real_name= table->real_name; table_list->real_name= table->real_name;
table_list->table= table; table_list->table= table;
......
...@@ -684,7 +684,7 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table) ...@@ -684,7 +684,7 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table)
mark to avoid temporary table using and put view reference and find mark to avoid temporary table using and put view reference and find
last view table last view table
*/ */
for (TABLE_LIST *tbl= view_tables; for (tbl= view_tables;
tbl; tbl;
tbl= (view_tables_tail= tbl)->next_global) tbl= (view_tables_tail= tbl)->next_global)
{ {
......
...@@ -788,9 +788,9 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); ...@@ -788,9 +788,9 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
opt_delete_options opt_delete_option varchar nchar nvarchar opt_delete_options opt_delete_option varchar nchar nvarchar
opt_outer table_list table_name opt_option opt_place opt_outer table_list table_name opt_option opt_place
opt_attribute opt_attribute_list attribute column_list column_list_id opt_attribute opt_attribute_list attribute column_list column_list_id
opt_column_list grant_privileges opt_table user_list grant_option opt_column_list grant_privileges opt_table grant_list grant_option
grant_privilege grant_privilege_list grant_privilege grant_privilege_list user_list rename_list
flush_options flush_option clear_privileges flush_options flush_option
equal optional_braces opt_key_definition key_usage_list2 equal optional_braces opt_key_definition key_usage_list2
opt_mi_check_type opt_to mi_check_types normal_join opt_mi_check_type opt_to mi_check_types normal_join
table_to_table_list table_to_table opt_table_list opt_as table_to_table_list table_to_table opt_table_list opt_as
...@@ -1287,6 +1287,24 @@ create: ...@@ -1287,6 +1287,24 @@ create:
TL_WRITE)) TL_WRITE))
YYABORT; YYABORT;
} }
| CREATE USER clear_privileges grant_list
{
Lex->sql_command = SQLCOM_CREATE_USER;
}
;
clear_privileges:
/* Nothing */
{
LEX *lex=Lex;
lex->users_list.empty();
lex->columns.empty();
lex->grant= lex->grant_tot_col= 0;
lex->select_lex.db= 0;
lex->ssl_type= SSL_TYPE_NOT_SPECIFIED;
lex->ssl_cipher= lex->x509_subject= lex->x509_issuer= 0;
bzero((char *)&(lex->mqh),sizeof(lex->mqh));
}
; ;
sp_name: sp_name:
...@@ -3671,6 +3689,23 @@ rename: ...@@ -3671,6 +3689,23 @@ rename:
} }
table_to_table_list table_to_table_list
{} {}
| RENAME USER clear_privileges rename_list
{
Lex->sql_command = SQLCOM_RENAME_USER;
}
;
rename_list:
user TO_SYM user
{
if (Lex->users_list.push_back($1) || Lex->users_list.push_back($3))
YYABORT;
}
| rename_list ',' user TO_SYM user
{
if (Lex->users_list.push_back($3) || Lex->users_list.push_back($5))
YYABORT;
}
; ;
table_to_table_list: table_to_table_list:
...@@ -5479,14 +5514,10 @@ drop: ...@@ -5479,14 +5514,10 @@ drop:
lex->drop_if_exists= $3; lex->drop_if_exists= $3;
lex->spname= $4; lex->spname= $4;
} }
| DROP USER | DROP USER clear_privileges user_list
{ {
LEX *lex=Lex; Lex->sql_command = SQLCOM_DROP_USER;
lex->sql_command = SQLCOM_DROP_USER;
lex->users_list.empty();
} }
user_list
{}
| DROP VIEW_SYM if_exists table_list opt_restrict | DROP VIEW_SYM if_exists table_list opt_restrict
{ {
THD *thd= YYTHD; THD *thd= YYTHD;
...@@ -6280,19 +6311,10 @@ purge_option: ...@@ -6280,19 +6311,10 @@ purge_option:
} }
| BEFORE_SYM expr | BEFORE_SYM expr
{ {
if ($2->check_cols(1) || $2->fix_fields(Lex->thd, 0, &$2)) LEX *lex= Lex;
{ lex->value_list.empty();
my_error(ER_WRONG_ARGUMENTS, MYF(0), "PURGE LOGS BEFORE"); lex->value_list.push_front($2);
YYABORT; lex->sql_command= SQLCOM_PURGE_BEFORE;
}
Item *tmp= new Item_func_unix_timestamp($2);
/*
it is OK only emulate fix_fieds, because we need only
value of constant
*/
tmp->quick_fix_field();
Lex->sql_command = SQLCOM_PURGE_BEFORE;
Lex->purge_time= (ulong) tmp->val_int();
} }
; ;
...@@ -6302,14 +6324,9 @@ kill: ...@@ -6302,14 +6324,9 @@ kill:
KILL_SYM kill_option expr KILL_SYM kill_option expr
{ {
LEX *lex=Lex; LEX *lex=Lex;
if ($3->fix_fields(lex->thd, 0, &$3) || $3->check_cols(1)) lex->value_list.empty();
{ lex->value_list.push_front($3);
my_message(ER_SET_CONSTANTS_ONLY, ER(ER_SET_CONSTANTS_ONLY), lex->sql_command= SQLCOM_KILL;
MYF(0));
YYABORT;
}
lex->sql_command=SQLCOM_KILL;
lex->thread_id= (ulong) $3->val_int();
}; };
kill_option: kill_option:
...@@ -7478,48 +7495,28 @@ handler_rkey_mode: ...@@ -7478,48 +7495,28 @@ handler_rkey_mode:
/* GRANT / REVOKE */ /* GRANT / REVOKE */
revoke: revoke:
REVOKE REVOKE clear_privileges revoke_command
{
LEX *lex=Lex;
lex->sql_command = SQLCOM_REVOKE;
lex->users_list.empty();
lex->columns.empty();
lex->grant= lex->grant_tot_col=0;
lex->select_lex.db=0;
lex->ssl_type= SSL_TYPE_NOT_SPECIFIED;
lex->ssl_cipher= lex->x509_subject= lex->x509_issuer= 0;
bzero((char*) &lex->mqh, sizeof(lex->mqh));
}
revoke_command
{} {}
; ;
revoke_command: revoke_command:
grant_privileges ON opt_table FROM user_list grant_privileges ON opt_table FROM grant_list
{} {
Lex->sql_command = SQLCOM_REVOKE;
}
| |
ALL opt_privileges ',' GRANT OPTION FROM user_list ALL opt_privileges ',' GRANT OPTION FROM grant_list
{ {
Lex->sql_command = SQLCOM_REVOKE_ALL; Lex->sql_command = SQLCOM_REVOKE_ALL;
} }
; ;
grant: grant:
GRANT GRANT clear_privileges grant_privileges ON opt_table TO_SYM grant_list
require_clause grant_options
{ {
LEX *lex=Lex; Lex->sql_command = SQLCOM_GRANT;
lex->users_list.empty();
lex->columns.empty();
lex->sql_command = SQLCOM_GRANT;
lex->grant= lex->grant_tot_col= 0;
lex->select_lex.db= 0;
lex->ssl_type= SSL_TYPE_NOT_SPECIFIED;
lex->ssl_cipher= lex->x509_subject= lex->x509_issuer= 0;
bzero((char *)&(lex->mqh),sizeof(lex->mqh));
} }
grant_privileges ON opt_table TO_SYM user_list
require_clause grant_options
{}
; ;
grant_privileges: grant_privileges:
...@@ -7659,8 +7656,18 @@ opt_table: ...@@ -7659,8 +7656,18 @@ opt_table:
user_list: user_list:
user { if (Lex->users_list.push_back($1)) YYABORT;}
| user_list ',' user
{
if (Lex->users_list.push_back($3))
YYABORT;
}
;
grant_list:
grant_user { if (Lex->users_list.push_back($1)) YYABORT;} grant_user { if (Lex->users_list.push_back($1)) YYABORT;}
| user_list ',' grant_user | grant_list ',' grant_user
{ {
if (Lex->users_list.push_back($3)) if (Lex->users_list.push_back($3))
YYABORT; YYABORT;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment