Commit f554a3c0 authored by Sergey Glukhov's avatar Sergey Glukhov

5.0-bugteam->5.1-bugteam merge

parents fb043f9b f0a7ff84
--require r/case_insensitive_fs.require
--disable_query_log
show variables like 'lower_case_file_system';
--enable_query_log
Variable_name Value
lower_case_file_system ON
...@@ -1007,8 +1007,8 @@ DROP TABLE mysqltest1.t2; ...@@ -1007,8 +1007,8 @@ DROP TABLE mysqltest1.t2;
SHOW GRANTS; SHOW GRANTS;
Grants for mysqltest_1@localhost Grants for mysqltest_1@localhost
GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost'
GRANT SELECT, INSERT, CREATE, DROP, ALTER ON `mysqltest1`.`t2` TO 'mysqltest_1'@'localhost'
GRANT SELECT, INSERT, CREATE, DROP, ALTER ON `mysqltest1`.`t1` TO 'mysqltest_1'@'localhost' GRANT SELECT, INSERT, CREATE, DROP, ALTER ON `mysqltest1`.`t1` TO 'mysqltest_1'@'localhost'
GRANT SELECT, INSERT, CREATE, DROP, ALTER ON `mysqltest1`.`t2` TO 'mysqltest_1'@'localhost'
RENAME TABLE t1 TO t2; RENAME TABLE t1 TO t2;
RENAME TABLE t2 TO t1; RENAME TABLE t2 TO t1;
ALTER TABLE t1 RENAME TO t2; ALTER TABLE t1 RENAME TO t2;
...@@ -1018,8 +1018,8 @@ REVOKE DROP, INSERT ON mysqltest1.t2 FROM mysqltest_1@localhost; ...@@ -1018,8 +1018,8 @@ REVOKE DROP, INSERT ON mysqltest1.t2 FROM mysqltest_1@localhost;
SHOW GRANTS; SHOW GRANTS;
Grants for mysqltest_1@localhost Grants for mysqltest_1@localhost
GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost'
GRANT SELECT, CREATE, ALTER ON `mysqltest1`.`t2` TO 'mysqltest_1'@'localhost'
GRANT SELECT, CREATE, ALTER ON `mysqltest1`.`t1` TO 'mysqltest_1'@'localhost' GRANT SELECT, CREATE, ALTER ON `mysqltest1`.`t1` TO 'mysqltest_1'@'localhost'
GRANT SELECT, CREATE, ALTER ON `mysqltest1`.`t2` TO 'mysqltest_1'@'localhost'
RENAME TABLE t1 TO t2; RENAME TABLE t1 TO t2;
ERROR 42000: DROP command denied to user 'mysqltest_1'@'localhost' for table 't1' ERROR 42000: DROP command denied to user 'mysqltest_1'@'localhost' for table 't1'
ALTER TABLE t1 RENAME TO t2; ALTER TABLE t1 RENAME TO t2;
......
create database db1;
GRANT CREATE ON db1.* to user_1@localhost;
GRANT SELECT ON db1.* to USER_1@localhost;
CREATE TABLE t1(f1 int);
SELECT * FROM t1;
ERROR 42000: SELECT command denied to user 'user_1'@'localhost' for table 't1'
SELECT * FROM t1;
f1
CREATE TABLE t2(f1 int);
ERROR 42000: CREATE command denied to user 'USER_1'@'localhost' for table 't2'
REVOKE ALL PRIVILEGES, GRANT OPTION FROM user_1@localhost;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM USER_1@localhost;
DROP USER user_1@localhost;
DROP USER USER_1@localhost;
DROP DATABASE db1;
use test;
...@@ -10,3 +10,48 @@ create database D1; ...@@ -10,3 +10,48 @@ create database D1;
ERROR 42000: Access denied for user 'sample'@'localhost' to database 'D1' ERROR 42000: Access denied for user 'sample'@'localhost' to database 'D1'
drop user 'sample'@'localhost'; drop user 'sample'@'localhost';
drop database if exists d1; drop database if exists d1;
CREATE DATABASE d1;
USE d1;
CREATE TABLE T1(f1 INT);
CREATE TABLE t1(f1 INT);
GRANT SELECT ON T1 to user_1@localhost;
select * from t1;
ERROR 42000: SELECT command denied to user 'user_1'@'localhost' for table 't1'
select * from T1;
f1
GRANT SELECT ON t1 to user_1@localhost;
select * from information_schema.table_privileges;
GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE
'user_1'@'localhost' NULL d1 T1 SELECT NO
'user_1'@'localhost' NULL d1 t1 SELECT NO
REVOKE ALL PRIVILEGES, GRANT OPTION FROM user_1@localhost;
DROP USER user_1@localhost;
DROP DATABASE d1;
USE test;
CREATE DATABASE db1;
USE db1;
CREATE PROCEDURE p1() BEGIN END;
CREATE FUNCTION f1(i INT) RETURNS INT RETURN i+1;
GRANT USAGE ON db1.* to user_1@localhost;
GRANT EXECUTE ON PROCEDURE db1.P1 to user_1@localhost;
GRANT EXECUTE ON FUNCTION db1.f1 to user_1@localhost;
GRANT UPDATE ON db1.* to USER_1@localhost;
call p1();
call P1();
select f1(1);
f1(1)
2
call p1();
ERROR 42000: execute command denied to user 'USER_1'@'localhost' for routine 'db1.p1'
call P1();
ERROR 42000: execute command denied to user 'USER_1'@'localhost' for routine 'db1.p1'
select f1(1);
ERROR 42000: execute command denied to user 'USER_1'@'localhost' for routine 'db1.f1'
REVOKE ALL PRIVILEGES, GRANT OPTION FROM user_1@localhost;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM USER_1@localhost;
DROP FUNCTION f1;
DROP PROCEDURE p1;
DROP USER user_1@localhost;
DROP USER USER_1@localhost;
DROP DATABASE db1;
use test;
...@@ -32,19 +32,19 @@ identified by 'looser' ; ...@@ -32,19 +32,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`.`t1` TO 'second_user'@'localhost'
GRANT SELECT ON `mysqltest`.`t9` TO 'second_user'@'localhost' GRANT SELECT ON `mysqltest`.`t9` TO 'second_user'@'localhost'
GRANT SELECT ON `mysqltest`.`t1` 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`.`t1` TO 'second_user'@'localhost'
GRANT SELECT ON `mysqltest`.`t9` TO 'second_user'@'localhost' GRANT SELECT ON `mysqltest`.`t9` TO 'second_user'@'localhost'
GRANT SELECT ON `mysqltest`.`t1` 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`.`t1` TO 'second_user'@'localhost'
GRANT SELECT ON `mysqltest`.`t9` TO 'second_user'@'localhost' GRANT SELECT ON `mysqltest`.`t9` TO 'second_user'@'localhost'
GRANT SELECT ON `mysqltest`.`t1` 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
......
...@@ -161,7 +161,7 @@ procs_priv CREATE TABLE `procs_priv` ( ...@@ -161,7 +161,7 @@ procs_priv CREATE TABLE `procs_priv` (
`Host` char(60) COLLATE utf8_bin NOT NULL DEFAULT '', `Host` char(60) COLLATE utf8_bin NOT NULL DEFAULT '',
`Db` char(64) COLLATE utf8_bin NOT NULL DEFAULT '', `Db` char(64) COLLATE utf8_bin NOT NULL DEFAULT '',
`User` char(16) COLLATE utf8_bin NOT NULL DEFAULT '', `User` char(16) COLLATE utf8_bin NOT NULL DEFAULT '',
`Routine_name` char(64) COLLATE utf8_bin NOT NULL DEFAULT '', `Routine_name` char(64) CHARACTER SET utf8 NOT NULL DEFAULT '',
`Routine_type` enum('FUNCTION','PROCEDURE') COLLATE utf8_bin NOT NULL, `Routine_type` enum('FUNCTION','PROCEDURE') COLLATE utf8_bin NOT NULL,
`Grantor` char(77) COLLATE utf8_bin NOT NULL DEFAULT '', `Grantor` char(77) COLLATE utf8_bin NOT NULL DEFAULT '',
`Proc_priv` set('Execute','Alter Routine','Grant') CHARACTER SET utf8 NOT NULL DEFAULT '', `Proc_priv` set('Execute','Alter Routine','Grant') CHARACTER SET utf8 NOT NULL DEFAULT '',
......
-- source include/have_case_insensitive_fs.inc
-- source include/not_embedded.inc
#
# Bug#41049 does syntax "grant" case insensitive?
#
create database db1;
GRANT CREATE ON db1.* to user_1@localhost;
GRANT SELECT ON db1.* to USER_1@localhost;
connect (con1,localhost,user_1,,db1);
CREATE TABLE t1(f1 int);
--error 1142
SELECT * FROM t1;
connect (con2,localhost,USER_1,,db1);
SELECT * FROM t1;
--error 1142
CREATE TABLE t2(f1 int);
connection default;
disconnect con1;
disconnect con2;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM user_1@localhost;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM USER_1@localhost;
DROP USER user_1@localhost;
DROP USER USER_1@localhost;
DROP DATABASE db1;
use test;
...@@ -29,3 +29,65 @@ disconnect master; ...@@ -29,3 +29,65 @@ disconnect master;
connection default; connection default;
# End of 4.1 tests # End of 4.1 tests
#
# Bug#41049 does syntax "grant" case insensitive?
#
CREATE DATABASE d1;
USE d1;
CREATE TABLE T1(f1 INT);
CREATE TABLE t1(f1 INT);
GRANT SELECT ON T1 to user_1@localhost;
connect (con1,localhost,user_1,,d1);
--error ER_TABLEACCESS_DENIED_ERROR
select * from t1;
select * from T1;
connection default;
GRANT SELECT ON t1 to user_1@localhost;
connection con1;
select * from information_schema.table_privileges;
connection default;
disconnect con1;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM user_1@localhost;
DROP USER user_1@localhost;
DROP DATABASE d1;
USE test;
CREATE DATABASE db1;
USE db1;
CREATE PROCEDURE p1() BEGIN END;
CREATE FUNCTION f1(i INT) RETURNS INT RETURN i+1;
GRANT USAGE ON db1.* to user_1@localhost;
GRANT EXECUTE ON PROCEDURE db1.P1 to user_1@localhost;
GRANT EXECUTE ON FUNCTION db1.f1 to user_1@localhost;
GRANT UPDATE ON db1.* to USER_1@localhost;
connect (con1,localhost,user_1,,db1);
call p1();
call P1();
select f1(1);
connect (con2,localhost,USER_1,,db1);
--error ER_PROCACCESS_DENIED_ERROR
call p1();
--error ER_PROCACCESS_DENIED_ERROR
call P1();
--error ER_PROCACCESS_DENIED_ERROR
select f1(1);
connection default;
disconnect con1;
disconnect con2;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM user_1@localhost;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM USER_1@localhost;
DROP FUNCTION f1;
DROP PROCEDURE p1;
DROP USER user_1@localhost;
DROP USER USER_1@localhost;
DROP DATABASE db1;
use test;
# End of 5.0 tests
...@@ -62,7 +62,7 @@ CREATE TABLE IF NOT EXISTS time_zone_leap_second ( Transition_time bigint sign ...@@ -62,7 +62,7 @@ CREATE TABLE IF NOT EXISTS time_zone_leap_second ( Transition_time bigint sign
CREATE TABLE IF NOT EXISTS proc (db char(64) collate utf8_bin DEFAULT '' NOT NULL, name char(64) DEFAULT '' NOT NULL, type enum('FUNCTION','PROCEDURE') NOT NULL, specific_name char(64) DEFAULT '' NOT NULL, language enum('SQL') DEFAULT 'SQL' NOT NULL, sql_data_access enum( 'CONTAINS_SQL', 'NO_SQL', 'READS_SQL_DATA', 'MODIFIES_SQL_DATA') DEFAULT 'CONTAINS_SQL' NOT NULL, is_deterministic enum('YES','NO') DEFAULT 'NO' NOT NULL, security_type enum('INVOKER','DEFINER') DEFAULT 'DEFINER' NOT NULL, param_list blob NOT NULL, returns longblob DEFAULT '' NOT NULL, body longblob NOT NULL, definer char(77) collate utf8_bin DEFAULT '' NOT NULL, created timestamp, modified timestamp, sql_mode set( 'REAL_AS_FLOAT', 'PIPES_AS_CONCAT', 'ANSI_QUOTES', 'IGNORE_SPACE', 'NOT_USED', 'ONLY_FULL_GROUP_BY', 'NO_UNSIGNED_SUBTRACTION', 'NO_DIR_IN_CREATE', 'POSTGRESQL', 'ORACLE', 'MSSQL', 'DB2', 'MAXDB', 'NO_KEY_OPTIONS', 'NO_TABLE_OPTIONS', 'NO_FIELD_OPTIONS', 'MYSQL323', 'MYSQL40', 'ANSI', 'NO_AUTO_VALUE_ON_ZERO', 'NO_BACKSLASH_ESCAPES', 'STRICT_TRANS_TABLES', 'STRICT_ALL_TABLES', 'NO_ZERO_IN_DATE', 'NO_ZERO_DATE', 'INVALID_DATES', 'ERROR_FOR_DIVISION_BY_ZERO', 'TRADITIONAL', 'NO_AUTO_CREATE_USER', 'HIGH_NOT_PRECEDENCE', 'NO_ENGINE_SUBSTITUTION', 'PAD_CHAR_TO_FULL_LENGTH') DEFAULT '' NOT NULL, comment char(64) collate utf8_bin DEFAULT '' NOT NULL, character_set_client char(32) collate utf8_bin, collation_connection char(32) collate utf8_bin, db_collation char(32) collate utf8_bin, body_utf8 longblob, PRIMARY KEY (db,name,type)) engine=MyISAM character set utf8 comment='Stored Procedures'; CREATE TABLE IF NOT EXISTS proc (db char(64) collate utf8_bin DEFAULT '' NOT NULL, name char(64) DEFAULT '' NOT NULL, type enum('FUNCTION','PROCEDURE') NOT NULL, specific_name char(64) DEFAULT '' NOT NULL, language enum('SQL') DEFAULT 'SQL' NOT NULL, sql_data_access enum( 'CONTAINS_SQL', 'NO_SQL', 'READS_SQL_DATA', 'MODIFIES_SQL_DATA') DEFAULT 'CONTAINS_SQL' NOT NULL, is_deterministic enum('YES','NO') DEFAULT 'NO' NOT NULL, security_type enum('INVOKER','DEFINER') DEFAULT 'DEFINER' NOT NULL, param_list blob NOT NULL, returns longblob DEFAULT '' NOT NULL, body longblob NOT NULL, definer char(77) collate utf8_bin DEFAULT '' NOT NULL, created timestamp, modified timestamp, sql_mode set( 'REAL_AS_FLOAT', 'PIPES_AS_CONCAT', 'ANSI_QUOTES', 'IGNORE_SPACE', 'NOT_USED', 'ONLY_FULL_GROUP_BY', 'NO_UNSIGNED_SUBTRACTION', 'NO_DIR_IN_CREATE', 'POSTGRESQL', 'ORACLE', 'MSSQL', 'DB2', 'MAXDB', 'NO_KEY_OPTIONS', 'NO_TABLE_OPTIONS', 'NO_FIELD_OPTIONS', 'MYSQL323', 'MYSQL40', 'ANSI', 'NO_AUTO_VALUE_ON_ZERO', 'NO_BACKSLASH_ESCAPES', 'STRICT_TRANS_TABLES', 'STRICT_ALL_TABLES', 'NO_ZERO_IN_DATE', 'NO_ZERO_DATE', 'INVALID_DATES', 'ERROR_FOR_DIVISION_BY_ZERO', 'TRADITIONAL', 'NO_AUTO_CREATE_USER', 'HIGH_NOT_PRECEDENCE', 'NO_ENGINE_SUBSTITUTION', 'PAD_CHAR_TO_FULL_LENGTH') DEFAULT '' NOT NULL, comment char(64) collate utf8_bin DEFAULT '' NOT NULL, character_set_client char(32) collate utf8_bin, collation_connection char(32) collate utf8_bin, db_collation char(32) collate utf8_bin, body_utf8 longblob, PRIMARY KEY (db,name,type)) engine=MyISAM character set utf8 comment='Stored Procedures';
CREATE TABLE IF NOT EXISTS procs_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Routine_name char(64) binary DEFAULT '' NOT NULL, Routine_type enum('FUNCTION','PROCEDURE') NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Timestamp timestamp(14), PRIMARY KEY (Host,Db,User,Routine_name,Routine_type), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Procedure privileges'; CREATE TABLE IF NOT EXISTS procs_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Routine_name char(64) COLLATE utf8_general_ci DEFAULT '' NOT NULL, Routine_type enum('FUNCTION','PROCEDURE') NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Timestamp timestamp(14), PRIMARY KEY (Host,Db,User,Routine_name,Routine_type), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Procedure privileges';
-- Create general_log if CSV is enabled. -- Create general_log if CSV is enabled.
......
...@@ -337,6 +337,10 @@ ALTER TABLE procs_priv ...@@ -337,6 +337,10 @@ ALTER TABLE procs_priv
MODIFY Proc_priv set('Execute','Alter Routine','Grant') MODIFY Proc_priv set('Execute','Alter Routine','Grant')
COLLATE utf8_general_ci DEFAULT '' NOT NULL; COLLATE utf8_general_ci DEFAULT '' NOT NULL;
ALTER IGNORE TABLE procs_priv
MODIFY Routine_name char(64)
COLLATE utf8_general_ci DEFAULT '' NOT NULL;
ALTER TABLE procs_priv ALTER TABLE procs_priv
ADD Routine_type enum('FUNCTION','PROCEDURE') ADD Routine_type enum('FUNCTION','PROCEDURE')
COLLATE utf8_general_ci NOT NULL AFTER Routine_name; COLLATE utf8_general_ci NOT NULL AFTER Routine_name;
......
...@@ -263,8 +263,7 @@ my_bool acl_init(bool dont_read_acl_tables) ...@@ -263,8 +263,7 @@ my_bool acl_init(bool dont_read_acl_tables)
acl_cache= new hash_filo(ACL_CACHE_SIZE, 0, 0, acl_cache= new hash_filo(ACL_CACHE_SIZE, 0, 0,
(hash_get_key) acl_entry_get_key, (hash_get_key) acl_entry_get_key,
(hash_free_key) free, (hash_free_key) free,
lower_case_file_system ? &my_charset_utf8_bin);
system_charset_info : &my_charset_bin);
if (dont_read_acl_tables) if (dont_read_acl_tables)
{ {
DBUG_RETURN(0); /* purecov: tested */ DBUG_RETURN(0); /* purecov: tested */
...@@ -2251,12 +2250,13 @@ class GRANT_NAME :public Sql_alloc ...@@ -2251,12 +2250,13 @@ class GRANT_NAME :public Sql_alloc
ulong sort; ulong sort;
size_t key_length; size_t key_length;
GRANT_NAME(const char *h, const char *d,const char *u, GRANT_NAME(const char *h, const char *d,const char *u,
const char *t, ulong p); const char *t, ulong p, bool is_routine);
GRANT_NAME (TABLE *form); GRANT_NAME (TABLE *form, bool is_routine);
virtual ~GRANT_NAME() {}; virtual ~GRANT_NAME() {};
virtual bool ok() { return privs != 0; } virtual bool ok() { return privs != 0; }
void set_user_details(const char *h, const char *d, void set_user_details(const char *h, const char *d,
const char *u, const char *t); const char *u, const char *t,
bool is_routine);
}; };
...@@ -2275,7 +2275,8 @@ class GRANT_TABLE :public GRANT_NAME ...@@ -2275,7 +2275,8 @@ class GRANT_TABLE :public GRANT_NAME
void GRANT_NAME::set_user_details(const char *h, const char *d, void GRANT_NAME::set_user_details(const char *h, const char *d,
const char *u, const char *t) const char *u, const char *t,
bool is_routine)
{ {
/* Host given by user */ /* Host given by user */
update_hostname(&host, strdup_root(&memex, h)); update_hostname(&host, strdup_root(&memex, h));
...@@ -2290,7 +2291,7 @@ void GRANT_NAME::set_user_details(const char *h, const char *d, ...@@ -2290,7 +2291,7 @@ void GRANT_NAME::set_user_details(const char *h, const char *d,
if (tname != t) if (tname != t)
{ {
tname= strdup_root(&memex, t); tname= strdup_root(&memex, t);
if (lower_case_table_names) if (lower_case_table_names || is_routine)
my_casedn_str(files_charset_info, tname); my_casedn_str(files_charset_info, tname);
} }
key_length= strlen(d) + strlen(u)+ strlen(t)+3; key_length= strlen(d) + strlen(u)+ strlen(t)+3;
...@@ -2299,22 +2300,22 @@ void GRANT_NAME::set_user_details(const char *h, const char *d, ...@@ -2299,22 +2300,22 @@ void GRANT_NAME::set_user_details(const char *h, const char *d,
} }
GRANT_NAME::GRANT_NAME(const char *h, const char *d,const char *u, GRANT_NAME::GRANT_NAME(const char *h, const char *d,const char *u,
const char *t, ulong p) const char *t, ulong p, bool is_routine)
:db(0), tname(0), privs(p) :db(0), tname(0), privs(p)
{ {
set_user_details(h, d, u, t); set_user_details(h, d, u, t, is_routine);
} }
GRANT_TABLE::GRANT_TABLE(const char *h, const char *d,const char *u, GRANT_TABLE::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_NAME(h,d,u,t,p), cols(c) :GRANT_NAME(h,d,u,t,p, FALSE), cols(c)
{ {
(void) hash_init2(&hash_columns,4,system_charset_info, (void) hash_init2(&hash_columns,4,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);
} }
GRANT_NAME::GRANT_NAME(TABLE *form) GRANT_NAME::GRANT_NAME(TABLE *form, bool is_routine)
{ {
update_hostname(&host, get_field(&memex, form->field[0])); update_hostname(&host, get_field(&memex, form->field[0]));
db= get_field(&memex,form->field[1]); db= get_field(&memex,form->field[1]);
...@@ -2332,6 +2333,9 @@ GRANT_NAME::GRANT_NAME(TABLE *form) ...@@ -2332,6 +2333,9 @@ GRANT_NAME::GRANT_NAME(TABLE *form)
if (lower_case_table_names) if (lower_case_table_names)
{ {
my_casedn_str(files_charset_info, db); my_casedn_str(files_charset_info, db);
}
if (lower_case_table_names || is_routine)
{
my_casedn_str(files_charset_info, tname); my_casedn_str(files_charset_info, tname);
} }
key_length= (strlen(db) + strlen(user) + strlen(tname) + 3); key_length= (strlen(db) + strlen(user) + strlen(tname) + 3);
...@@ -2343,7 +2347,7 @@ GRANT_NAME::GRANT_NAME(TABLE *form) ...@@ -2343,7 +2347,7 @@ GRANT_NAME::GRANT_NAME(TABLE *form)
GRANT_TABLE::GRANT_TABLE(TABLE *form, TABLE *col_privs) GRANT_TABLE::GRANT_TABLE(TABLE *form, TABLE *col_privs)
:GRANT_NAME(form) :GRANT_NAME(form, FALSE)
{ {
uchar key[MAX_KEY_LENGTH]; uchar key[MAX_KEY_LENGTH];
...@@ -3338,7 +3342,7 @@ bool mysql_routine_grant(THD *thd, TABLE_LIST *table_list, bool is_proc, ...@@ -3338,7 +3342,7 @@ bool mysql_routine_grant(THD *thd, TABLE_LIST *table_list, bool is_proc,
} }
grant_name= new GRANT_NAME(Str->host.str, db_name, grant_name= new GRANT_NAME(Str->host.str, db_name,
Str->user.str, table_name, Str->user.str, table_name,
rights); rights, TRUE);
if (!grant_name) if (!grant_name)
{ {
result= TRUE; result= TRUE;
...@@ -3549,10 +3553,10 @@ static my_bool grant_load_procs_priv(TABLE *p_table) ...@@ -3549,10 +3553,10 @@ static my_bool grant_load_procs_priv(TABLE *p_table)
MEM_ROOT **save_mem_root_ptr= my_pthread_getspecific_ptr(MEM_ROOT**, MEM_ROOT **save_mem_root_ptr= my_pthread_getspecific_ptr(MEM_ROOT**,
THR_MALLOC); THR_MALLOC);
DBUG_ENTER("grant_load_procs_priv"); DBUG_ENTER("grant_load_procs_priv");
(void) hash_init(&proc_priv_hash,system_charset_info, (void) hash_init(&proc_priv_hash, &my_charset_utf8_bin,
0,0,0, (hash_get_key) get_grant_table, 0,0,0, (hash_get_key) get_grant_table,
0,0); 0,0);
(void) hash_init(&func_priv_hash,system_charset_info, (void) hash_init(&func_priv_hash, &my_charset_utf8_bin,
0,0,0, (hash_get_key) get_grant_table, 0,0,0, (hash_get_key) get_grant_table,
0,0); 0,0);
p_table->file->ha_index_init(0, 1); p_table->file->ha_index_init(0, 1);
...@@ -3566,7 +3570,7 @@ static my_bool grant_load_procs_priv(TABLE *p_table) ...@@ -3566,7 +3570,7 @@ static my_bool grant_load_procs_priv(TABLE *p_table)
{ {
GRANT_NAME *mem_check; GRANT_NAME *mem_check;
HASH *hash; HASH *hash;
if (!(mem_check=new (memex_ptr) GRANT_NAME(p_table))) if (!(mem_check=new (memex_ptr) GRANT_NAME(p_table, TRUE)))
{ {
/* This could only happen if we are out memory */ /* This could only happen if we are out memory */
goto end_unlock; goto end_unlock;
...@@ -3650,7 +3654,7 @@ static my_bool grant_load(THD *thd, TABLE_LIST *tables) ...@@ -3650,7 +3654,7 @@ static my_bool grant_load(THD *thd, TABLE_LIST *tables)
thd->variables.sql_mode&= ~MODE_PAD_CHAR_TO_FULL_LENGTH; thd->variables.sql_mode&= ~MODE_PAD_CHAR_TO_FULL_LENGTH;
(void) hash_init(&column_priv_hash,system_charset_info, (void) hash_init(&column_priv_hash, &my_charset_utf8_bin,
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);
...@@ -5452,7 +5456,8 @@ static int handle_grant_struct(uint struct_no, bool drop, ...@@ -5452,7 +5456,8 @@ static int handle_grant_struct(uint struct_no, bool drop,
host name host name
*/ */
grant_name->set_user_details(user_to->host.str, grant_name->db, grant_name->set_user_details(user_to->host.str, grant_name->db,
user_to->user.str, grant_name->tname); user_to->user.str, grant_name->tname,
TRUE);
/* /*
Since username is part of the hash key, when the user name Since username is part of the hash key, when the user name
...@@ -6139,7 +6144,7 @@ bool sp_revoke_privileges(THD *thd, const char *sp_db, const char *sp_name, ...@@ -6139,7 +6144,7 @@ bool sp_revoke_privileges(THD *thd, const char *sp_db, const char *sp_name,
for (counter= 0, revoked= 0 ; counter < hash->records ; ) for (counter= 0, revoked= 0 ; counter < hash->records ; )
{ {
GRANT_NAME *grant_proc= (GRANT_NAME*) hash_element(hash, counter); GRANT_NAME *grant_proc= (GRANT_NAME*) hash_element(hash, counter);
if (!my_strcasecmp(system_charset_info, grant_proc->db, sp_db) && if (!my_strcasecmp(&my_charset_utf8_bin, grant_proc->db, sp_db) &&
!my_strcasecmp(system_charset_info, grant_proc->tname, sp_name)) !my_strcasecmp(system_charset_info, grant_proc->tname, sp_name))
{ {
LEX_USER lex_user; LEX_USER lex_user;
......
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