mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Merge bk-internal.mysql.com:/data0/bk/mysql-5.0
into bk-internal.mysql.com:/data0/bk/mysql-5.0-marvel client/mysql.cc: Auto merged heap/hp_write.c: Auto merged sql/ha_ndbcluster.cc: Auto merged sql/handler.cc: Auto merged sql/item.cc: Auto merged sql/mysqld.cc: Auto merged sql/opt_range.cc: Auto merged sql/sql_base.cc: Auto merged sql/sql_class.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_delete.cc: Auto merged sql/sql_insert.cc: Auto merged sql/sql_load.cc: Auto merged sql/sql_select.cc: Auto merged sql/sql_table.cc: Auto merged
This commit is contained in:
@ -972,4 +972,126 @@ REVOKE EXECUTE ON PROCEDURE t1 FROM some_user_name@1234567890abcdefghij123456789
|
||||
ERROR HY000: String '1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY' is too long for host name (should be no longer than 60)
|
||||
GRANT PROCESS ON * TO user@localhost;
|
||||
ERROR 3D000: No database selected
|
||||
DROP DATABASE IF EXISTS mysqltest1;
|
||||
DROP DATABASE IF EXISTS mysqltest2;
|
||||
DROP DATABASE IF EXISTS mysqltest3;
|
||||
DROP DATABASE IF EXISTS mysqltest4;
|
||||
CREATE DATABASE mysqltest1;
|
||||
CREATE DATABASE mysqltest2;
|
||||
CREATE DATABASE mysqltest3;
|
||||
CREATE DATABASE mysqltest4;
|
||||
CREATE PROCEDURE mysqltest1.p_def() SQL SECURITY DEFINER
|
||||
SELECT 1;
|
||||
CREATE PROCEDURE mysqltest2.p_inv() SQL SECURITY INVOKER
|
||||
SELECT 1;
|
||||
CREATE FUNCTION mysqltest3.f_def() RETURNS INT SQL SECURITY DEFINER
|
||||
RETURN 1;
|
||||
CREATE FUNCTION mysqltest4.f_inv() RETURNS INT SQL SECURITY INVOKER
|
||||
RETURN 1;
|
||||
GRANT EXECUTE ON PROCEDURE mysqltest1.p_def TO mysqltest_1@localhost;
|
||||
GRANT EXECUTE ON PROCEDURE mysqltest2.p_inv TO mysqltest_1@localhost;
|
||||
GRANT EXECUTE ON FUNCTION mysqltest3.f_def TO mysqltest_1@localhost;
|
||||
GRANT EXECUTE ON FUNCTION mysqltest4.f_inv TO mysqltest_1@localhost;
|
||||
GRANT ALL PRIVILEGES ON test.* TO mysqltest_1@localhost;
|
||||
|
||||
---> connection: bug9504_con1
|
||||
use mysqltest1;
|
||||
use mysqltest2;
|
||||
use mysqltest3;
|
||||
use mysqltest4;
|
||||
use test;
|
||||
CALL mysqltest1.p_def();
|
||||
1
|
||||
1
|
||||
CALL mysqltest2.p_inv();
|
||||
1
|
||||
1
|
||||
SELECT mysqltest3.f_def();
|
||||
mysqltest3.f_def()
|
||||
1
|
||||
SELECT mysqltest4.f_inv();
|
||||
mysqltest4.f_inv()
|
||||
1
|
||||
|
||||
---> connection: default
|
||||
DROP DATABASE mysqltest1;
|
||||
DROP DATABASE mysqltest2;
|
||||
DROP DATABASE mysqltest3;
|
||||
DROP DATABASE mysqltest4;
|
||||
DROP USER mysqltest_1@localhost;
|
||||
DROP DATABASE IF EXISTS mysqltest1;
|
||||
DROP DATABASE IF EXISTS mysqltest2;
|
||||
CREATE DATABASE mysqltest1;
|
||||
CREATE DATABASE mysqltest2;
|
||||
GRANT ALL PRIVILEGES ON mysqltest1.* TO mysqltest_1@localhost;
|
||||
GRANT SELECT ON mysqltest2.* TO mysqltest_1@localhost;
|
||||
CREATE PROCEDURE mysqltest1.p1() SQL SECURITY INVOKER
|
||||
SELECT 1;
|
||||
|
||||
---> connection: bug27337_con1
|
||||
CREATE TABLE t1(c INT);
|
||||
ERROR 42000: CREATE command denied to user 'mysqltest_1'@'localhost' for table 't1'
|
||||
CALL mysqltest1.p1();
|
||||
1
|
||||
1
|
||||
CREATE TABLE t1(c INT);
|
||||
ERROR 42000: CREATE command denied to user 'mysqltest_1'@'localhost' for table 't1'
|
||||
|
||||
---> connection: bug27337_con2
|
||||
CREATE TABLE t1(c INT);
|
||||
ERROR 42000: CREATE command denied to user 'mysqltest_1'@'localhost' for table 't1'
|
||||
SHOW TABLES;
|
||||
Tables_in_mysqltest2
|
||||
|
||||
---> connection: default
|
||||
DROP DATABASE mysqltest1;
|
||||
DROP DATABASE mysqltest2;
|
||||
DROP USER mysqltest_1@localhost;
|
||||
DROP DATABASE IF EXISTS mysqltest1;
|
||||
DROP DATABASE IF EXISTS mysqltest2;
|
||||
CREATE DATABASE mysqltest1;
|
||||
CREATE DATABASE mysqltest2;
|
||||
CREATE TABLE mysqltest1.t1(c INT);
|
||||
CREATE TABLE mysqltest2.t2(c INT);
|
||||
GRANT SELECT ON mysqltest1.t1 TO mysqltest_1@localhost;
|
||||
GRANT SELECT ON mysqltest2.t2 TO mysqltest_2@localhost;
|
||||
|
||||
---> connection: bug27337_con1
|
||||
SHOW TABLES FROM mysqltest1;
|
||||
Tables_in_mysqltest1
|
||||
t1
|
||||
PREPARE stmt1 FROM 'SHOW TABLES FROM mysqltest1';
|
||||
EXECUTE stmt1;
|
||||
Tables_in_mysqltest1
|
||||
t1
|
||||
|
||||
---> connection: bug27337_con2
|
||||
SHOW COLUMNS FROM mysqltest2.t2;
|
||||
Field Type Null Key Default Extra
|
||||
c int(11) YES NULL
|
||||
PREPARE stmt2 FROM 'SHOW COLUMNS FROM mysqltest2.t2';
|
||||
EXECUTE stmt2;
|
||||
Field Type Null Key Default Extra
|
||||
c int(11) YES NULL
|
||||
|
||||
---> connection: default
|
||||
REVOKE SELECT ON mysqltest1.t1 FROM mysqltest_1@localhost;
|
||||
REVOKE SELECT ON mysqltest2.t2 FROM mysqltest_2@localhost;
|
||||
|
||||
---> connection: bug27337_con1
|
||||
SHOW TABLES FROM mysqltest1;
|
||||
ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysqltest1'
|
||||
EXECUTE stmt1;
|
||||
ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysqltest1'
|
||||
|
||||
---> connection: bug27337_con2
|
||||
SHOW COLUMNS FROM mysqltest2.t2;
|
||||
ERROR 42000: SELECT command denied to user 'mysqltest_2'@'localhost' for table 't2'
|
||||
EXECUTE stmt2;
|
||||
ERROR 42000: SELECT command denied to user 'mysqltest_2'@'localhost' for table 't2'
|
||||
|
||||
---> connection: default
|
||||
DROP DATABASE mysqltest1;
|
||||
DROP DATABASE mysqltest2;
|
||||
DROP USER mysqltest_1@localhost;
|
||||
End of 5.0 tests
|
||||
|
@ -106,16 +106,82 @@ use testdb_1;
|
||||
create table t1 (f1 char(4));
|
||||
create view v1 as select f1 from t1;
|
||||
grant insert on v1 to testdb_2@localhost;
|
||||
create view v5 as select f1 from t1;
|
||||
grant show view on v5 to testdb_2@localhost;
|
||||
create definer=`no_such_user`@`no_such_host` view v6 as select f1 from t1;
|
||||
ERROR 42000: Access denied; you need the SUPER privilege for this operation
|
||||
use testdb_1;
|
||||
create view v6 as select f1 from t1;
|
||||
grant show view on v6 to testdb_2@localhost;
|
||||
create table t2 (f1 char(4));
|
||||
create definer=`no_such_user`@`no_such_host` view v7 as select * from t2;
|
||||
Warnings:
|
||||
Note 1449 There is no 'no_such_user'@'no_such_host' registered
|
||||
show fields from testdb_1.v6;
|
||||
Field Type Null Key Default Extra
|
||||
f1 char(4) YES NULL
|
||||
show create view testdb_1.v6;
|
||||
View Create View
|
||||
v6 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v6` AS select `t1`.`f1` AS `f1` from `t1`
|
||||
show create view testdb_1.v7;
|
||||
View Create View
|
||||
v7 CREATE ALGORITHM=UNDEFINED DEFINER=`no_such_user`@`no_such_host` SQL SECURITY DEFINER VIEW `v7` AS select `testdb_1`.`t2`.`f1` AS `f1` from `t2`
|
||||
Warnings:
|
||||
Warning 1356 View 'testdb_1.v7' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
|
||||
show fields from testdb_1.v7;
|
||||
Field Type Null Key Default Extra
|
||||
f1 null YES NULL
|
||||
Warnings:
|
||||
Note 1449 There is no 'no_such_user'@'no_such_host' registered
|
||||
create table t3 (f1 char(4), f2 char(4));
|
||||
create view v3 as select f1,f2 from t3;
|
||||
grant insert(f1), insert(f2) on v3 to testdb_2@localhost;
|
||||
create view v2 as select f1 from testdb_1.v1;
|
||||
create view v4 as select f1,f2 from testdb_1.v3;
|
||||
show fields from testdb_1.v5;
|
||||
Field Type Null Key Default Extra
|
||||
f1 char(4) YES NULL
|
||||
show create view testdb_1.v5;
|
||||
View Create View
|
||||
v5 CREATE ALGORITHM=UNDEFINED DEFINER=`testdb_1`@`localhost` SQL SECURITY DEFINER VIEW `testdb_1`.`v5` AS select `testdb_1`.`t1`.`f1` AS `f1` from `testdb_1`.`t1`
|
||||
show fields from testdb_1.v6;
|
||||
Field Type Null Key Default Extra
|
||||
f1 char(4) YES NULL
|
||||
show create view testdb_1.v6;
|
||||
View Create View
|
||||
v6 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `testdb_1`.`v6` AS select `testdb_1`.`t1`.`f1` AS `f1` from `testdb_1`.`t1`
|
||||
show fields from testdb_1.v7;
|
||||
Field Type Null Key Default Extra
|
||||
f1 null YES NULL
|
||||
Warnings:
|
||||
Note 1449 There is no 'no_such_user'@'no_such_host' registered
|
||||
show create view testdb_1.v7;
|
||||
View Create View
|
||||
v7 CREATE ALGORITHM=UNDEFINED DEFINER=`no_such_user`@`no_such_host` SQL SECURITY DEFINER VIEW `v7` AS select `testdb_1`.`t2`.`f1` AS `f1` from `t2`
|
||||
Warnings:
|
||||
Warning 1356 View 'testdb_1.v7' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
|
||||
revoke insert(f1) on v3 from testdb_2@localhost;
|
||||
revoke show view on v5 from testdb_2@localhost;
|
||||
use testdb_1;
|
||||
revoke show view on v6 from testdb_2@localhost;
|
||||
show fields from testdb_1.v5;
|
||||
ERROR 42000: SELECT command denied to user 'testdb_2'@'localhost' for table 'v5'
|
||||
show create view testdb_1.v5;
|
||||
ERROR 42000: SELECT command denied to user 'testdb_2'@'localhost' for table 'v5'
|
||||
show fields from testdb_1.v6;
|
||||
ERROR 42000: SELECT command denied to user 'testdb_2'@'localhost' for table 'v6'
|
||||
show create view testdb_1.v6;
|
||||
ERROR 42000: SELECT command denied to user 'testdb_2'@'localhost' for table 'v6'
|
||||
show fields from testdb_1.v7;
|
||||
ERROR 42000: SELECT command denied to user 'testdb_2'@'localhost' for table 'v7'
|
||||
show create view testdb_1.v7;
|
||||
ERROR 42000: SELECT command denied to user 'testdb_2'@'localhost' for table 'v7'
|
||||
show create view v4;
|
||||
ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
|
||||
show fields from v4;
|
||||
ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
|
||||
Field Type Null Key Default Extra
|
||||
f1 null YES NULL
|
||||
f2 char(4) YES NULL
|
||||
show fields from v2;
|
||||
Field Type Null Key Default Extra
|
||||
f1 char(4) YES NULL
|
||||
@ -140,7 +206,8 @@ where a.table_name = 'testdb_1.v1';
|
||||
view_definition
|
||||
select * from v2;
|
||||
ERROR HY000: View 'test.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
|
||||
drop view testdb_1.v1,v2, testdb_1.v3, v4;
|
||||
use test;
|
||||
drop view testdb_1.v1, v2, testdb_1.v3, v4;
|
||||
drop database testdb_1;
|
||||
drop user testdb_1@localhost;
|
||||
drop user testdb_2@localhost;
|
||||
|
@ -122,6 +122,24 @@ DELIMITER ;
|
||||
ROLLBACK /* added by mysqlbinlog */;
|
||||
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
|
||||
|
||||
--- start and stop positions ---
|
||||
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
|
||||
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
|
||||
DELIMITER /*!*/;
|
||||
SET INSERT_ID=4/*!*/;
|
||||
use test/*!*/;
|
||||
SET TIMESTAMP=1579609946/*!*/;
|
||||
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1/*!*/;
|
||||
SET @@session.sql_mode=0/*!*/;
|
||||
/*!\C latin1 *//*!*/;
|
||||
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
|
||||
insert into t1 values(null, "d")/*!*/;
|
||||
SET INSERT_ID=5/*!*/;
|
||||
DELIMITER ;
|
||||
# End of log file
|
||||
ROLLBACK /* added by mysqlbinlog */;
|
||||
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
|
||||
|
||||
--- start-datetime --
|
||||
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
|
||||
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
|
||||
@ -481,6 +499,24 @@ DELIMITER ;
|
||||
ROLLBACK /* added by mysqlbinlog */;
|
||||
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
|
||||
|
||||
--- start and stop positions ---
|
||||
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
|
||||
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
|
||||
DELIMITER /*!*/;
|
||||
SET INSERT_ID=4/*!*/;
|
||||
use test/*!*/;
|
||||
SET TIMESTAMP=1579609946/*!*/;
|
||||
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1/*!*/;
|
||||
SET @@session.sql_mode=0/*!*/;
|
||||
/*!\C latin1 *//*!*/;
|
||||
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
|
||||
insert into t1 values(null, "d")/*!*/;
|
||||
SET INSERT_ID=5/*!*/;
|
||||
DELIMITER ;
|
||||
# End of log file
|
||||
ROLLBACK /* added by mysqlbinlog */;
|
||||
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
|
||||
|
||||
--- start-datetime --
|
||||
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
|
||||
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
|
||||
|
@ -8,22 +8,29 @@ create procedure db1_secret.dummy() begin end;
|
||||
drop procedure db1_secret.dummy;
|
||||
use db1_secret;
|
||||
create table t1 ( u varchar(64), i int );
|
||||
insert into t1 values('test', 0);
|
||||
create procedure stamp(i int)
|
||||
insert into db1_secret.t1 values (user(), i);
|
||||
show procedure status like 'stamp';
|
||||
Db Name Type Definer Modified Created Security_type Comment
|
||||
db1_secret stamp PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
|
||||
create function db() returns varchar(64) return database();
|
||||
create function db() returns varchar(64)
|
||||
begin
|
||||
declare v varchar(64);
|
||||
select u into v from t1 limit 1;
|
||||
return v;
|
||||
end|
|
||||
show function status like 'db';
|
||||
Db Name Type Definer Modified Created Security_type Comment
|
||||
db1_secret db FUNCTION root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
|
||||
call stamp(1);
|
||||
select * from t1;
|
||||
u i
|
||||
test 0
|
||||
root@localhost 1
|
||||
select db();
|
||||
db()
|
||||
db1_secret
|
||||
test
|
||||
grant execute on procedure db1_secret.stamp to user1@'%';
|
||||
grant execute on function db1_secret.db to user1@'%';
|
||||
grant execute on procedure db1_secret.stamp to ''@'%';
|
||||
@ -31,25 +38,34 @@ grant execute on function db1_secret.db to ''@'%';
|
||||
call db1_secret.stamp(2);
|
||||
select db1_secret.db();
|
||||
db1_secret.db()
|
||||
db1_secret
|
||||
test
|
||||
select * from db1_secret.t1;
|
||||
ERROR 42000: SELECT command denied to user 'user1'@'localhost' for table 't1'
|
||||
create procedure db1_secret.dummy() begin end;
|
||||
ERROR 42000: Access denied for user 'user1'@'localhost' to database 'db1_secret'
|
||||
drop procedure db1_secret.dummy;
|
||||
ERROR 42000: PROCEDURE db1_secret.dummy does not exist
|
||||
drop procedure db1_secret.stamp;
|
||||
ERROR 42000: alter routine command denied to user 'user1'@'localhost' for routine 'db1_secret.stamp'
|
||||
drop function db1_secret.db;
|
||||
ERROR 42000: alter routine command denied to user 'user1'@'localhost' for routine 'db1_secret.db'
|
||||
call db1_secret.stamp(3);
|
||||
select db1_secret.db();
|
||||
db1_secret.db()
|
||||
db1_secret
|
||||
test
|
||||
select * from db1_secret.t1;
|
||||
ERROR 42000: SELECT command denied to user ''@'localhost' for table 't1'
|
||||
create procedure db1_secret.dummy() begin end;
|
||||
ERROR 42000: Access denied for user ''@'%' to database 'db1_secret'
|
||||
drop procedure db1_secret.dummy;
|
||||
ERROR 42000: PROCEDURE db1_secret.dummy does not exist
|
||||
drop procedure db1_secret.stamp;
|
||||
ERROR 42000: alter routine command denied to user ''@'%' for routine 'db1_secret.stamp'
|
||||
drop function db1_secret.db;
|
||||
ERROR 42000: alter routine command denied to user ''@'%' for routine 'db1_secret.db'
|
||||
select * from t1;
|
||||
u i
|
||||
test 0
|
||||
root@localhost 1
|
||||
user1@localhost 2
|
||||
anon@localhost 3
|
||||
@ -64,21 +80,22 @@ db1_secret db FUNCTION root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 IN
|
||||
call stamp(4);
|
||||
select * from t1;
|
||||
u i
|
||||
test 0
|
||||
root@localhost 1
|
||||
user1@localhost 2
|
||||
anon@localhost 3
|
||||
root@localhost 4
|
||||
select db();
|
||||
db()
|
||||
db1_secret
|
||||
test
|
||||
call db1_secret.stamp(5);
|
||||
ERROR 42000: Access denied for user 'user1'@'localhost' to database 'db1_secret'
|
||||
ERROR 42000: INSERT command denied to user 'user1'@'localhost' for table 't1'
|
||||
select db1_secret.db();
|
||||
ERROR 42000: Access denied for user 'user1'@'localhost' to database 'db1_secret'
|
||||
ERROR 42000: SELECT command denied to user 'user1'@'localhost' for table 't1'
|
||||
call db1_secret.stamp(6);
|
||||
ERROR 42000: Access denied for user ''@'%' to database 'db1_secret'
|
||||
ERROR 42000: INSERT command denied to user ''@'localhost' for table 't1'
|
||||
select db1_secret.db();
|
||||
ERROR 42000: Access denied for user ''@'%' to database 'db1_secret'
|
||||
ERROR 42000: SELECT command denied to user ''@'localhost' for table 't1'
|
||||
drop database if exists db2;
|
||||
create database db2;
|
||||
use db2;
|
||||
|
@ -5969,4 +5969,44 @@ SUM(f2) bug25373(f1)
|
||||
21.300000071526 NULL
|
||||
DROP FUNCTION bug25373|
|
||||
DROP TABLE t3|
|
||||
DROP DATABASE IF EXISTS mysqltest1|
|
||||
DROP DATABASE IF EXISTS mysqltest2|
|
||||
CREATE DATABASE mysqltest1|
|
||||
CREATE DATABASE mysqltest2|
|
||||
CREATE PROCEDURE mysqltest1.p1()
|
||||
DROP DATABASE mysqltest2|
|
||||
use mysqltest2|
|
||||
CALL mysqltest1.p1()|
|
||||
Warnings:
|
||||
Note 1049 Unknown database 'mysqltest2'
|
||||
SELECT DATABASE()|
|
||||
DATABASE()
|
||||
NULL
|
||||
DROP DATABASE mysqltest1|
|
||||
use test|
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1 (a int auto_increment primary key) engine=MyISAM;
|
||||
CREATE TABLE t2 (a int auto_increment primary key, b int) engine=innodb;
|
||||
set @a=0;
|
||||
CREATE function bug27354() RETURNS int deterministic
|
||||
begin
|
||||
insert into t1 values (null);
|
||||
set @a=@a+1;
|
||||
return @a;
|
||||
end|
|
||||
update t2 set b=1 where a=bug27354();
|
||||
select count(t_1.a),count(t_2.a) from t1 as t_1, t2 as t_2 /* must be 0,0 */;
|
||||
count(t_1.a) count(t_2.a)
|
||||
0 0
|
||||
insert into t2 values (1,1),(2,2),(3,3);
|
||||
update t2 set b=-b where a=bug27354();
|
||||
select * from t2 /* must return 1,-1 ... */;
|
||||
a b
|
||||
1 -1
|
||||
2 -2
|
||||
3 -3
|
||||
select count(*) from t1 /* must be 3 */;
|
||||
count(*)
|
||||
3
|
||||
drop table t1,t2;
|
||||
drop function bug27354;
|
||||
|
@ -530,3 +530,24 @@ count(*)
|
||||
drop table t3, t4|
|
||||
drop procedure bug14210|
|
||||
set @@session.max_heap_table_size=default|
|
||||
drop function if exists bug23333|
|
||||
drop table if exists t1,t2|
|
||||
CREATE TABLE t1 (a int NOT NULL auto_increment primary key) ENGINE=MyISAM|
|
||||
CREATE TABLE t2 (a int NOT NULL auto_increment, b int, PRIMARY KEY (a)) ENGINE=InnoDB|
|
||||
insert into t2 values (1,1)|
|
||||
create function bug23333()
|
||||
RETURNS int(11)
|
||||
DETERMINISTIC
|
||||
begin
|
||||
insert into t1 values (null);
|
||||
select count(*) from t1 into @a;
|
||||
return @a;
|
||||
end|
|
||||
reset master|
|
||||
insert into t2 values (bug23333(),1)|
|
||||
ERROR 23000: Duplicate entry '1' for key 1
|
||||
show binlog events from 98 /* with fixes for #23333 will show there is the query */|
|
||||
Log_name Pos Event_type Server_id End_log_pos Info
|
||||
select count(*),@a from t1 /* must be 1,1 */|
|
||||
count(*) @a
|
||||
1 1
|
||||
|
@ -282,15 +282,6 @@ create view mysqltest.v3 as select b from mysqltest.t2;
|
||||
grant create view, update on mysqltest.v3 to mysqltest_1@localhost;
|
||||
drop view mysqltest.v3;
|
||||
create view mysqltest.v3 as select b from mysqltest.t2;
|
||||
grant create view, update, insert on mysqltest.v3 to mysqltest_1@localhost;
|
||||
drop view mysqltest.v3;
|
||||
create view mysqltest.v3 as select b from mysqltest.t2;
|
||||
ERROR 42000: create view command denied to user 'mysqltest_1'@'localhost' for column 'b' in table 'v3'
|
||||
create table mysqltest.v3 (b int);
|
||||
grant select(b) on mysqltest.v3 to mysqltest_1@localhost;
|
||||
drop table mysqltest.v3;
|
||||
create view mysqltest.v3 as select b from mysqltest.t2;
|
||||
ERROR 42000: create view command denied to user 'mysqltest_1'@'localhost' for column 'b' in table 'v3'
|
||||
create view v4 as select b+1 from mysqltest.t2;
|
||||
ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for column 'b' in table 't2'
|
||||
grant create view,update,select on test.* to mysqltest_1@localhost;
|
||||
@ -794,4 +785,92 @@ View Create View
|
||||
v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `t1`.`f2` AS `f2` from `t1`
|
||||
DROP USER u26813@localhost;
|
||||
DROP DATABASE db26813;
|
||||
DROP DATABASE IF EXISTS mysqltest1;
|
||||
DROP DATABASE IF EXISTS mysqltest2;
|
||||
CREATE DATABASE mysqltest1;
|
||||
CREATE DATABASE mysqltest2;
|
||||
CREATE TABLE mysqltest1.t1(c1 INT);
|
||||
CREATE TABLE mysqltest1.t2(c2 INT);
|
||||
CREATE TABLE mysqltest1.t3(c3 INT);
|
||||
CREATE TABLE mysqltest1.t4(c4 INT);
|
||||
INSERT INTO mysqltest1.t1 VALUES (11), (12), (13), (14);
|
||||
INSERT INTO mysqltest1.t2 VALUES (21), (22), (23), (24);
|
||||
INSERT INTO mysqltest1.t3 VALUES (31), (32), (33), (34);
|
||||
INSERT INTO mysqltest1.t4 VALUES (41), (42), (43), (44);
|
||||
GRANT SELECT ON mysqltest1.t1 TO mysqltest_u1@localhost;
|
||||
GRANT INSERT ON mysqltest1.t2 TO mysqltest_u1@localhost;
|
||||
GRANT SELECT, UPDATE ON mysqltest1.t3 TO mysqltest_u1@localhost;
|
||||
GRANT SELECT, DELETE ON mysqltest1.t4 TO mysqltest_u1@localhost;
|
||||
GRANT ALL PRIVILEGES ON mysqltest2.* TO mysqltest_u1@localhost;
|
||||
|
||||
---> connection: bug24040_con
|
||||
SELECT * FROM mysqltest1.t1;
|
||||
c1
|
||||
11
|
||||
12
|
||||
13
|
||||
14
|
||||
INSERT INTO mysqltest1.t2 VALUES(25);
|
||||
UPDATE mysqltest1.t3 SET c3 = 331 WHERE c3 = 31;
|
||||
DELETE FROM mysqltest1.t4 WHERE c4 = 44;
|
||||
CREATE VIEW v1 AS SELECT * FROM mysqltest1.t1;
|
||||
CREATE VIEW v2 AS SELECT * FROM mysqltest1.t2;
|
||||
CREATE VIEW v3 AS SELECT * FROM mysqltest1.t3;
|
||||
CREATE VIEW v4 AS SELECT * FROM mysqltest1.t4;
|
||||
SELECT * FROM v1;
|
||||
c1
|
||||
11
|
||||
12
|
||||
13
|
||||
14
|
||||
INSERT INTO v2 VALUES(26);
|
||||
UPDATE v3 SET c3 = 332 WHERE c3 = 32;
|
||||
DELETE FROM v4 WHERE c4 = 43;
|
||||
CREATE VIEW v12 AS SELECT c1, c2 FROM mysqltest1.t1, mysqltest1.t2;
|
||||
ERROR 42000: create view command denied to user 'mysqltest_u1'@'localhost' for column 'c2' in table 'v12'
|
||||
CREATE VIEW v13 AS SELECT c1, c3 FROM mysqltest1.t1, mysqltest1.t3;
|
||||
CREATE VIEW v14 AS SELECT c1, c4 FROM mysqltest1.t1, mysqltest1.t4;
|
||||
CREATE VIEW v21 AS SELECT c2, c1 FROM mysqltest1.t2, mysqltest1.t1;
|
||||
ERROR 42000: create view command denied to user 'mysqltest_u1'@'localhost' for column 'c1' in table 'v21'
|
||||
CREATE VIEW v23 AS SELECT c2, c3 FROM mysqltest1.t2, mysqltest1.t3;
|
||||
ERROR 42000: create view command denied to user 'mysqltest_u1'@'localhost' for column 'c3' in table 'v23'
|
||||
CREATE VIEW v24 AS SELECT c2, c4 FROM mysqltest1.t2, mysqltest1.t4;
|
||||
ERROR 42000: create view command denied to user 'mysqltest_u1'@'localhost' for column 'c4' in table 'v24'
|
||||
CREATE VIEW v31 AS SELECT c3, c1 FROM mysqltest1.t3, mysqltest1.t1;
|
||||
CREATE VIEW v32 AS SELECT c3, c2 FROM mysqltest1.t3, mysqltest1.t2;
|
||||
ERROR 42000: create view command denied to user 'mysqltest_u1'@'localhost' for column 'c2' in table 'v32'
|
||||
CREATE VIEW v34 AS SELECT c3, c4 FROM mysqltest1.t3, mysqltest1.t4;
|
||||
CREATE VIEW v41 AS SELECT c4, c1 FROM mysqltest1.t4, mysqltest1.t1;
|
||||
CREATE VIEW v42 AS SELECT c4, c2 FROM mysqltest1.t4, mysqltest1.t2;
|
||||
ERROR 42000: create view command denied to user 'mysqltest_u1'@'localhost' for column 'c2' in table 'v42'
|
||||
CREATE VIEW v43 AS SELECT c4, c3 FROM mysqltest1.t4, mysqltest1.t3;
|
||||
|
||||
---> connection: default
|
||||
SELECT * FROM mysqltest1.t1;
|
||||
c1
|
||||
11
|
||||
12
|
||||
13
|
||||
14
|
||||
SELECT * FROM mysqltest1.t2;
|
||||
c2
|
||||
21
|
||||
22
|
||||
23
|
||||
24
|
||||
25
|
||||
26
|
||||
SELECT * FROM mysqltest1.t3;
|
||||
c3
|
||||
331
|
||||
332
|
||||
33
|
||||
34
|
||||
SELECT * FROM mysqltest1.t4;
|
||||
c4
|
||||
41
|
||||
42
|
||||
DROP DATABASE mysqltest1;
|
||||
DROP DATABASE mysqltest2;
|
||||
DROP USER mysqltest_u1@localhost;
|
||||
End of 5.0 tests.
|
||||
|
@ -875,4 +875,231 @@ GRANT PROCESS ON * TO user@localhost;
|
||||
disconnect con1;
|
||||
connection default;
|
||||
|
||||
|
||||
#
|
||||
# BUG#9504: Stored procedures: execute privilege doesn't make 'use database'
|
||||
# okay.
|
||||
#
|
||||
|
||||
# Prepare.
|
||||
|
||||
--disable_warnings
|
||||
DROP DATABASE IF EXISTS mysqltest1;
|
||||
DROP DATABASE IF EXISTS mysqltest2;
|
||||
DROP DATABASE IF EXISTS mysqltest3;
|
||||
DROP DATABASE IF EXISTS mysqltest4;
|
||||
--enable_warnings
|
||||
|
||||
CREATE DATABASE mysqltest1;
|
||||
CREATE DATABASE mysqltest2;
|
||||
CREATE DATABASE mysqltest3;
|
||||
CREATE DATABASE mysqltest4;
|
||||
|
||||
CREATE PROCEDURE mysqltest1.p_def() SQL SECURITY DEFINER
|
||||
SELECT 1;
|
||||
|
||||
CREATE PROCEDURE mysqltest2.p_inv() SQL SECURITY INVOKER
|
||||
SELECT 1;
|
||||
|
||||
CREATE FUNCTION mysqltest3.f_def() RETURNS INT SQL SECURITY DEFINER
|
||||
RETURN 1;
|
||||
|
||||
CREATE FUNCTION mysqltest4.f_inv() RETURNS INT SQL SECURITY INVOKER
|
||||
RETURN 1;
|
||||
|
||||
GRANT EXECUTE ON PROCEDURE mysqltest1.p_def TO mysqltest_1@localhost;
|
||||
GRANT EXECUTE ON PROCEDURE mysqltest2.p_inv TO mysqltest_1@localhost;
|
||||
GRANT EXECUTE ON FUNCTION mysqltest3.f_def TO mysqltest_1@localhost;
|
||||
GRANT EXECUTE ON FUNCTION mysqltest4.f_inv TO mysqltest_1@localhost;
|
||||
|
||||
GRANT ALL PRIVILEGES ON test.* TO mysqltest_1@localhost;
|
||||
|
||||
# Test.
|
||||
|
||||
--connect (bug9504_con1,localhost,mysqltest_1,,)
|
||||
--echo
|
||||
--echo ---> connection: bug9504_con1
|
||||
|
||||
# - Check that we can switch to the db;
|
||||
|
||||
use mysqltest1;
|
||||
|
||||
use mysqltest2;
|
||||
|
||||
use mysqltest3;
|
||||
|
||||
use mysqltest4;
|
||||
|
||||
# - Check that we can call stored routines;
|
||||
|
||||
use test;
|
||||
|
||||
CALL mysqltest1.p_def();
|
||||
|
||||
CALL mysqltest2.p_inv();
|
||||
|
||||
SELECT mysqltest3.f_def();
|
||||
|
||||
SELECT mysqltest4.f_inv();
|
||||
|
||||
# Cleanup.
|
||||
|
||||
--connection default
|
||||
--echo
|
||||
--echo ---> connection: default
|
||||
|
||||
--disconnect bug9504_con1
|
||||
|
||||
DROP DATABASE mysqltest1;
|
||||
DROP DATABASE mysqltest2;
|
||||
DROP DATABASE mysqltest3;
|
||||
DROP DATABASE mysqltest4;
|
||||
|
||||
DROP USER mysqltest_1@localhost;
|
||||
|
||||
|
||||
#
|
||||
# BUG#27337: Privileges are not restored properly.
|
||||
#
|
||||
# Actually, the patch for this bugs fixes two problems. So, here are two test
|
||||
# cases.
|
||||
|
||||
# Test case 1: privileges are not restored properly after calling a stored
|
||||
# routine defined with SQL SECURITY INVOKER clause.
|
||||
|
||||
# Prepare.
|
||||
|
||||
--disable_warnings
|
||||
DROP DATABASE IF EXISTS mysqltest1;
|
||||
DROP DATABASE IF EXISTS mysqltest2;
|
||||
--enable_warnings
|
||||
|
||||
CREATE DATABASE mysqltest1;
|
||||
CREATE DATABASE mysqltest2;
|
||||
|
||||
GRANT ALL PRIVILEGES ON mysqltest1.* TO mysqltest_1@localhost;
|
||||
GRANT SELECT ON mysqltest2.* TO mysqltest_1@localhost;
|
||||
|
||||
CREATE PROCEDURE mysqltest1.p1() SQL SECURITY INVOKER
|
||||
SELECT 1;
|
||||
|
||||
# Test.
|
||||
|
||||
--connect (bug27337_con1,localhost,mysqltest_1,,mysqltest2)
|
||||
--echo
|
||||
--echo ---> connection: bug27337_con1
|
||||
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
CREATE TABLE t1(c INT);
|
||||
|
||||
CALL mysqltest1.p1();
|
||||
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
CREATE TABLE t1(c INT);
|
||||
|
||||
--disconnect bug27337_con1
|
||||
|
||||
--connect (bug27337_con2,localhost,mysqltest_1,,mysqltest2)
|
||||
--echo
|
||||
--echo ---> connection: bug27337_con2
|
||||
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
CREATE TABLE t1(c INT);
|
||||
|
||||
SHOW TABLES;
|
||||
|
||||
# Cleanup.
|
||||
|
||||
--connection default
|
||||
--echo
|
||||
--echo ---> connection: default
|
||||
|
||||
--disconnect bug27337_con2
|
||||
|
||||
DROP DATABASE mysqltest1;
|
||||
DROP DATABASE mysqltest2;
|
||||
|
||||
DROP USER mysqltest_1@localhost;
|
||||
|
||||
# Test case 2: priveleges are not checked properly for prepared statements.
|
||||
|
||||
# Prepare.
|
||||
|
||||
--disable_warnings
|
||||
DROP DATABASE IF EXISTS mysqltest1;
|
||||
DROP DATABASE IF EXISTS mysqltest2;
|
||||
--enable_warnings
|
||||
|
||||
CREATE DATABASE mysqltest1;
|
||||
CREATE DATABASE mysqltest2;
|
||||
|
||||
CREATE TABLE mysqltest1.t1(c INT);
|
||||
CREATE TABLE mysqltest2.t2(c INT);
|
||||
|
||||
GRANT SELECT ON mysqltest1.t1 TO mysqltest_1@localhost;
|
||||
GRANT SELECT ON mysqltest2.t2 TO mysqltest_2@localhost;
|
||||
|
||||
# Test.
|
||||
|
||||
--connect (bug27337_con1,localhost,mysqltest_1,,mysqltest1)
|
||||
--echo
|
||||
--echo ---> connection: bug27337_con1
|
||||
|
||||
SHOW TABLES FROM mysqltest1;
|
||||
|
||||
PREPARE stmt1 FROM 'SHOW TABLES FROM mysqltest1';
|
||||
|
||||
EXECUTE stmt1;
|
||||
|
||||
--connect (bug27337_con2,localhost,mysqltest_2,,mysqltest2)
|
||||
--echo
|
||||
--echo ---> connection: bug27337_con2
|
||||
|
||||
SHOW COLUMNS FROM mysqltest2.t2;
|
||||
|
||||
PREPARE stmt2 FROM 'SHOW COLUMNS FROM mysqltest2.t2';
|
||||
|
||||
EXECUTE stmt2;
|
||||
|
||||
--connection default
|
||||
--echo
|
||||
--echo ---> connection: default
|
||||
|
||||
REVOKE SELECT ON mysqltest1.t1 FROM mysqltest_1@localhost;
|
||||
REVOKE SELECT ON mysqltest2.t2 FROM mysqltest_2@localhost;
|
||||
|
||||
--connection bug27337_con1
|
||||
--echo
|
||||
--echo ---> connection: bug27337_con1
|
||||
|
||||
--error ER_DBACCESS_DENIED_ERROR
|
||||
SHOW TABLES FROM mysqltest1;
|
||||
|
||||
--error ER_DBACCESS_DENIED_ERROR
|
||||
EXECUTE stmt1;
|
||||
|
||||
--connection bug27337_con2
|
||||
--echo
|
||||
--echo ---> connection: bug27337_con2
|
||||
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
SHOW COLUMNS FROM mysqltest2.t2;
|
||||
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
EXECUTE stmt2;
|
||||
|
||||
# Cleanup.
|
||||
|
||||
--connection default
|
||||
--echo
|
||||
--echo ---> connection: default
|
||||
|
||||
--disconnect bug27337_con2
|
||||
|
||||
DROP DATABASE mysqltest1;
|
||||
DROP DATABASE mysqltest2;
|
||||
|
||||
DROP USER mysqltest_1@localhost;
|
||||
|
||||
|
||||
--echo End of 5.0 tests
|
||||
|
@ -121,6 +121,28 @@ create table t1 (f1 char(4));
|
||||
create view v1 as select f1 from t1;
|
||||
grant insert on v1 to testdb_2@localhost;
|
||||
|
||||
create view v5 as select f1 from t1;
|
||||
grant show view on v5 to testdb_2@localhost;
|
||||
|
||||
--error 1227
|
||||
create definer=`no_such_user`@`no_such_host` view v6 as select f1 from t1;
|
||||
|
||||
connection default;
|
||||
use testdb_1;
|
||||
create view v6 as select f1 from t1;
|
||||
grant show view on v6 to testdb_2@localhost;
|
||||
|
||||
create table t2 (f1 char(4));
|
||||
create definer=`no_such_user`@`no_such_host` view v7 as select * from t2;
|
||||
|
||||
show fields from testdb_1.v6;
|
||||
show create view testdb_1.v6;
|
||||
|
||||
show create view testdb_1.v7;
|
||||
show fields from testdb_1.v7;
|
||||
|
||||
connection testdb_1;
|
||||
|
||||
create table t3 (f1 char(4), f2 char(4));
|
||||
create view v3 as select f1,f2 from t3;
|
||||
grant insert(f1), insert(f2) on v3 to testdb_2@localhost;
|
||||
@ -129,13 +151,41 @@ connect (testdb_2,localhost,testdb_2,,test);
|
||||
create view v2 as select f1 from testdb_1.v1;
|
||||
create view v4 as select f1,f2 from testdb_1.v3;
|
||||
|
||||
show fields from testdb_1.v5;
|
||||
show create view testdb_1.v5;
|
||||
|
||||
show fields from testdb_1.v6;
|
||||
show create view testdb_1.v6;
|
||||
|
||||
connection testdb_1;
|
||||
show fields from testdb_1.v7;
|
||||
show create view testdb_1.v7;
|
||||
|
||||
revoke insert(f1) on v3 from testdb_2@localhost;
|
||||
revoke show view on v5 from testdb_2@localhost;
|
||||
connection default;
|
||||
use testdb_1;
|
||||
revoke show view on v6 from testdb_2@localhost;
|
||||
connection testdb_2;
|
||||
|
||||
--error 1142
|
||||
show fields from testdb_1.v5;
|
||||
--error 1142
|
||||
show create view testdb_1.v5;
|
||||
|
||||
--error 1142
|
||||
show fields from testdb_1.v6;
|
||||
--error 1142
|
||||
show create view testdb_1.v6;
|
||||
|
||||
--error 1142
|
||||
show fields from testdb_1.v7;
|
||||
--error 1142
|
||||
show create view testdb_1.v7;
|
||||
|
||||
--error 1345
|
||||
show create view v4;
|
||||
--error 1345
|
||||
#--error 1345
|
||||
show fields from v4;
|
||||
|
||||
show fields from v2;
|
||||
@ -155,7 +205,8 @@ where a.table_name = 'testdb_1.v1';
|
||||
select * from v2;
|
||||
|
||||
connection default;
|
||||
drop view testdb_1.v1,v2, testdb_1.v3, v4;
|
||||
use test;
|
||||
drop view testdb_1.v1, v2, testdb_1.v3, v4;
|
||||
drop database testdb_1;
|
||||
drop user testdb_1@localhost;
|
||||
drop user testdb_2@localhost;
|
||||
|
@ -55,6 +55,10 @@ select "--- stop-position --" as "";
|
||||
--enable_query_log
|
||||
--exec $MYSQL_BINLOG --short-form --stop-position=600 $MYSQLTEST_VARDIR/log/master-bin.000001
|
||||
--disable_query_log
|
||||
select "--- start and stop positions ---" as "";
|
||||
--enable_query_log
|
||||
--exec $MYSQL_BINLOG --short-form --start-position=600 --stop-position 725 $MYSQLTEST_VARDIR/log/master-bin.000001
|
||||
--disable_query_log
|
||||
select "--- start-datetime --" as "";
|
||||
--enable_query_log
|
||||
--exec $MYSQL_BINLOG --short-form "--start-datetime=2020-01-21 15:32:24" $MYSQLTEST_VARDIR/log/master-bin.000001
|
||||
@ -111,6 +115,10 @@ select "--- stop-position --" as "";
|
||||
--enable_query_log
|
||||
--exec $MYSQL_BINLOG --short-form --stop-position=600 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
|
||||
--disable_query_log
|
||||
select "--- start and stop positions ---" as "";
|
||||
--enable_query_log
|
||||
--exec $MYSQL_BINLOG --short-form --start-position=600 --stop-position 725 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
|
||||
--disable_query_log
|
||||
select "--- start-datetime --" as "";
|
||||
--enable_query_log
|
||||
--exec $MYSQL_BINLOG --short-form "--start-datetime=2020-01-21 15:32:24" --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
|
||||
|
@ -28,6 +28,7 @@ drop procedure db1_secret.dummy;
|
||||
use db1_secret;
|
||||
|
||||
create table t1 ( u varchar(64), i int );
|
||||
insert into t1 values('test', 0);
|
||||
|
||||
# A test procedure and function
|
||||
create procedure stamp(i int)
|
||||
@ -35,7 +36,16 @@ create procedure stamp(i int)
|
||||
--replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00'
|
||||
show procedure status like 'stamp';
|
||||
|
||||
create function db() returns varchar(64) return database();
|
||||
delimiter |;
|
||||
create function db() returns varchar(64)
|
||||
begin
|
||||
declare v varchar(64);
|
||||
|
||||
select u into v from t1 limit 1;
|
||||
|
||||
return v;
|
||||
end|
|
||||
delimiter ;|
|
||||
--replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00'
|
||||
show function status like 'db';
|
||||
|
||||
@ -63,14 +73,18 @@ call db1_secret.stamp(2);
|
||||
select db1_secret.db();
|
||||
|
||||
# ...but not this
|
||||
--error 1142
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
select * from db1_secret.t1;
|
||||
|
||||
# ...and not this
|
||||
--error 1044
|
||||
--error ER_DBACCESS_DENIED_ERROR
|
||||
create procedure db1_secret.dummy() begin end;
|
||||
--error 1305
|
||||
--error ER_SP_DOES_NOT_EXIST
|
||||
drop procedure db1_secret.dummy;
|
||||
--error ER_PROCACCESS_DENIED_ERROR
|
||||
drop procedure db1_secret.stamp;
|
||||
--error ER_PROCACCESS_DENIED_ERROR
|
||||
drop function db1_secret.db;
|
||||
|
||||
|
||||
#
|
||||
@ -83,14 +97,18 @@ call db1_secret.stamp(3);
|
||||
select db1_secret.db();
|
||||
|
||||
# ...but not this
|
||||
--error 1142
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
select * from db1_secret.t1;
|
||||
|
||||
# ...and not this
|
||||
--error 1044
|
||||
--error ER_DBACCESS_DENIED_ERROR
|
||||
create procedure db1_secret.dummy() begin end;
|
||||
--error 1305
|
||||
--error ER_SP_DOES_NOT_EXIST
|
||||
drop procedure db1_secret.dummy;
|
||||
--error ER_PROCACCESS_DENIED_ERROR
|
||||
drop procedure db1_secret.stamp;
|
||||
--error ER_PROCACCESS_DENIED_ERROR
|
||||
drop function db1_secret.db;
|
||||
|
||||
|
||||
#
|
||||
@ -121,9 +139,9 @@ select db();
|
||||
connection con2user1;
|
||||
|
||||
# This should not work
|
||||
--error 1044
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
call db1_secret.stamp(5);
|
||||
--error 1044
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
select db1_secret.db();
|
||||
|
||||
#
|
||||
@ -132,9 +150,9 @@ select db1_secret.db();
|
||||
connection con3anon;
|
||||
|
||||
# This should not work
|
||||
--error 1044
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
call db1_secret.stamp(6);
|
||||
--error 1044
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
select db1_secret.db();
|
||||
|
||||
#
|
||||
@ -165,7 +183,7 @@ use db2;
|
||||
create procedure p () insert into t2 values (1);
|
||||
|
||||
# Check that this doesn't work.
|
||||
--error 1142
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
call p();
|
||||
|
||||
connect (con4user2,localhost,user2,,);
|
||||
@ -174,7 +192,7 @@ connection con4user2;
|
||||
use db2;
|
||||
|
||||
# This should not work, since p is executed with definer's (user1's) rights.
|
||||
--error 1370
|
||||
--error ER_PROCACCESS_DENIED_ERROR
|
||||
call p();
|
||||
select * from t2;
|
||||
|
||||
@ -207,9 +225,9 @@ alter procedure p modifies sql data;
|
||||
drop procedure p;
|
||||
|
||||
# This should NOT work
|
||||
--error 1370
|
||||
--error ER_PROCACCESS_DENIED_ERROR
|
||||
alter procedure q modifies sql data;
|
||||
--error 1370
|
||||
--error ER_PROCACCESS_DENIED_ERROR
|
||||
drop procedure q;
|
||||
|
||||
connection con1root;
|
||||
@ -260,30 +278,30 @@ connect (con4userc,localhost,userc,,);
|
||||
|
||||
connection con2usera;
|
||||
call sptest.p1(1);
|
||||
--error 1370
|
||||
--error ER_PROCACCESS_DENIED_ERROR
|
||||
grant execute on procedure sptest.p1 to userb@localhost;
|
||||
--error 1370
|
||||
--error ER_PROCACCESS_DENIED_ERROR
|
||||
drop procedure sptest.p1;
|
||||
|
||||
connection con3userb;
|
||||
--error 1370
|
||||
--error ER_PROCACCESS_DENIED_ERROR
|
||||
call sptest.p1(2);
|
||||
--error 1370
|
||||
--error ER_PROCACCESS_DENIED_ERROR
|
||||
grant execute on procedure sptest.p1 to userb@localhost;
|
||||
--error 1370
|
||||
--error ER_PROCACCESS_DENIED_ERROR
|
||||
drop procedure sptest.p1;
|
||||
|
||||
connection con4userc;
|
||||
call sptest.p1(3);
|
||||
grant execute on procedure sptest.p1 to userb@localhost;
|
||||
--error 1370
|
||||
--error ER_PROCACCESS_DENIED_ERROR
|
||||
drop procedure sptest.p1;
|
||||
|
||||
connection con3userb;
|
||||
call sptest.p1(4);
|
||||
--error 1370
|
||||
--error ER_PROCACCESS_DENIED_ERROR
|
||||
grant execute on procedure sptest.p1 to userb@localhost;
|
||||
--error 1370
|
||||
--error ER_PROCACCESS_DENIED_ERROR
|
||||
drop procedure sptest.p1;
|
||||
|
||||
connection con1root;
|
||||
@ -332,7 +350,7 @@ delimiter ;//
|
||||
connect (user1,localhost,user1,,test);
|
||||
connection user1;
|
||||
use mysqltest;
|
||||
-- error 1370
|
||||
-- error ER_PROCACCESS_DENIED_ERROR
|
||||
select bug_9503();
|
||||
|
||||
connection root;
|
||||
@ -401,13 +419,13 @@ grant usage on *.* to mysqltest_1@localhost;
|
||||
|
||||
connect (n1,localhost,mysqltest_1,,information_schema,$MASTER_MYPORT,$MASTER_MYSOCK);
|
||||
connection n1;
|
||||
--error 1370
|
||||
--error ER_PROCACCESS_DENIED_ERROR
|
||||
call mysqltest_1.p1();
|
||||
disconnect n1;
|
||||
# Test also without a current database
|
||||
connect (n2,localhost,mysqltest_1,,*NO-ONE*,$MASTER_MYPORT,$MASTER_MYSOCK);
|
||||
connection n2;
|
||||
--error 1370
|
||||
--error ER_PROCACCESS_DENIED_ERROR
|
||||
call mysqltest_1.p1();
|
||||
disconnect n2;
|
||||
|
||||
@ -433,9 +451,9 @@ end;
|
||||
create user user_bug12812@localhost IDENTIFIED BY 'ABC'|
|
||||
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
|
||||
connect (test_user_12812,localhost,user_bug12812,ABC,test)|
|
||||
--error 1370
|
||||
--error ER_PROCACCESS_DENIED_ERROR
|
||||
SELECT test.bug12812()|
|
||||
--error 1370
|
||||
--error ER_PROCACCESS_DENIED_ERROR
|
||||
CREATE VIEW v1 AS SELECT test.bug12812()|
|
||||
# Cleanup
|
||||
connection default|
|
||||
@ -489,7 +507,8 @@ drop database db_bug14834;
|
||||
|
||||
|
||||
#
|
||||
# BUG#14533: 'desc tbl' in stored procedure causes error 1142
|
||||
# BUG#14533: 'desc tbl' in stored procedure causes error
|
||||
# ER_TABLEACCESS_DENIED_ERROR
|
||||
#
|
||||
create database db_bug14533;
|
||||
use db_bug14533;
|
||||
|
@ -6929,6 +6929,47 @@ INSERT INTO t3 VALUES (1, 3.4), (1, 2), (1, 0.9), (2, 8), (2, 7)|
|
||||
SELECT SUM(f2), bug25373(f1) FROM t3 GROUP BY bug25373(f1) WITH ROLLUP|
|
||||
DROP FUNCTION bug25373|
|
||||
DROP TABLE t3|
|
||||
|
||||
|
||||
#
|
||||
# BUG#25082: Default database change on trigger execution breaks replication.
|
||||
#
|
||||
# As it turned out, this bug has actually two bugs. So, here we have two test
|
||||
# cases -- one in sp.test, the other in sp-security.test.
|
||||
#
|
||||
|
||||
#
|
||||
# Test case 1: error on dropping the current database.
|
||||
#
|
||||
|
||||
# Prepare.
|
||||
|
||||
--disable_warnings
|
||||
DROP DATABASE IF EXISTS mysqltest1|
|
||||
DROP DATABASE IF EXISTS mysqltest2|
|
||||
--enable_warnings
|
||||
|
||||
CREATE DATABASE mysqltest1|
|
||||
CREATE DATABASE mysqltest2|
|
||||
|
||||
# Test.
|
||||
|
||||
CREATE PROCEDURE mysqltest1.p1()
|
||||
DROP DATABASE mysqltest2|
|
||||
|
||||
use mysqltest2|
|
||||
|
||||
CALL mysqltest1.p1()|
|
||||
|
||||
SELECT DATABASE()|
|
||||
|
||||
# Cleanup.
|
||||
|
||||
DROP DATABASE mysqltest1|
|
||||
|
||||
use test|
|
||||
|
||||
|
||||
#
|
||||
# NOTE: The delimiter is `|`, and not `;`. It is changed to `;`
|
||||
# at the end of the file!
|
||||
@ -6946,3 +6987,27 @@ DROP TABLE t3|
|
||||
# practical, or create table t3, t4 etc temporarily (and drop them).
|
||||
delimiter ;|
|
||||
drop table t1,t2;
|
||||
|
||||
CREATE TABLE t1 (a int auto_increment primary key) engine=MyISAM;
|
||||
CREATE TABLE t2 (a int auto_increment primary key, b int) engine=innodb;
|
||||
set @a=0;
|
||||
|
||||
delimiter |;
|
||||
CREATE function bug27354() RETURNS int deterministic
|
||||
begin
|
||||
insert into t1 values (null);
|
||||
set @a=@a+1;
|
||||
return @a;
|
||||
end|
|
||||
|
||||
delimiter ;|
|
||||
update t2 set b=1 where a=bug27354();
|
||||
select count(t_1.a),count(t_2.a) from t1 as t_1, t2 as t_2 /* must be 0,0 */;
|
||||
insert into t2 values (1,1),(2,2),(3,3);
|
||||
update t2 set b=-b where a=bug27354();
|
||||
select * from t2 /* must return 1,-1 ... */;
|
||||
select count(*) from t1 /* must be 3 */;
|
||||
|
||||
|
||||
drop table t1,t2;
|
||||
drop function bug27354;
|
||||
|
@ -553,6 +553,37 @@ drop procedure bug14210|
|
||||
set @@session.max_heap_table_size=default|
|
||||
|
||||
|
||||
#
|
||||
# Bug #13270 INSERT,UPDATE,etc that calls func with side-effect does not binlog
|
||||
# Bug #23333 stored function + non-transac table + transac table =
|
||||
# breaks stmt-based binlog
|
||||
# Bug #27395 OPTION_STATUS_NO_TRANS_UPDATE is not preserved at the end of SF()
|
||||
#
|
||||
--disable_warnings
|
||||
drop function if exists bug23333|
|
||||
drop table if exists t1,t2|
|
||||
--enable_warnings
|
||||
CREATE TABLE t1 (a int NOT NULL auto_increment primary key) ENGINE=MyISAM|
|
||||
CREATE TABLE t2 (a int NOT NULL auto_increment, b int, PRIMARY KEY (a)) ENGINE=InnoDB|
|
||||
|
||||
insert into t2 values (1,1)|
|
||||
|
||||
create function bug23333()
|
||||
RETURNS int(11)
|
||||
DETERMINISTIC
|
||||
begin
|
||||
insert into t1 values (null);
|
||||
select count(*) from t1 into @a;
|
||||
return @a;
|
||||
end|
|
||||
|
||||
reset master|
|
||||
--error ER_DUP_ENTRY
|
||||
insert into t2 values (bug23333(),1)|
|
||||
--replace_column 2 # 5 # 6 #
|
||||
show binlog events from 98 /* with fixes for #23333 will show there is the query */|
|
||||
select count(*),@a from t1 /* must be 1,1 */|
|
||||
|
||||
#
|
||||
# BUG#NNNN: New bug synopsis
|
||||
#
|
||||
|
@ -350,25 +350,6 @@ drop view mysqltest.v3;
|
||||
connection user1;
|
||||
create view mysqltest.v3 as select b from mysqltest.t2;
|
||||
|
||||
# give UPDATE and INSERT privilege (to get more privileges then underlying
|
||||
# table)
|
||||
connection root;
|
||||
grant create view, update, insert on mysqltest.v3 to mysqltest_1@localhost;
|
||||
drop view mysqltest.v3;
|
||||
connection user1;
|
||||
-- error 1143
|
||||
create view mysqltest.v3 as select b from mysqltest.t2;
|
||||
|
||||
|
||||
# If we would get more privileges on VIEW then we have on
|
||||
# underlying tables => creation prohibited
|
||||
connection root;
|
||||
create table mysqltest.v3 (b int);
|
||||
grant select(b) on mysqltest.v3 to mysqltest_1@localhost;
|
||||
drop table mysqltest.v3;
|
||||
connection user1;
|
||||
-- error 1143
|
||||
create view mysqltest.v3 as select b from mysqltest.t2;
|
||||
|
||||
# Expression need select privileges
|
||||
-- error 1143
|
||||
@ -1066,4 +1047,95 @@ DROP USER u26813@localhost;
|
||||
DROP DATABASE db26813;
|
||||
disconnect u1;
|
||||
|
||||
#
|
||||
# BUG#24040: Create View don't succed with "all privileges" on a database.
|
||||
#
|
||||
|
||||
# Prepare.
|
||||
|
||||
--disable_warnings
|
||||
DROP DATABASE IF EXISTS mysqltest1;
|
||||
DROP DATABASE IF EXISTS mysqltest2;
|
||||
--enable_warnings
|
||||
|
||||
CREATE DATABASE mysqltest1;
|
||||
CREATE DATABASE mysqltest2;
|
||||
|
||||
# Test.
|
||||
|
||||
CREATE TABLE mysqltest1.t1(c1 INT);
|
||||
CREATE TABLE mysqltest1.t2(c2 INT);
|
||||
CREATE TABLE mysqltest1.t3(c3 INT);
|
||||
CREATE TABLE mysqltest1.t4(c4 INT);
|
||||
|
||||
INSERT INTO mysqltest1.t1 VALUES (11), (12), (13), (14);
|
||||
INSERT INTO mysqltest1.t2 VALUES (21), (22), (23), (24);
|
||||
INSERT INTO mysqltest1.t3 VALUES (31), (32), (33), (34);
|
||||
INSERT INTO mysqltest1.t4 VALUES (41), (42), (43), (44);
|
||||
|
||||
GRANT SELECT ON mysqltest1.t1 TO mysqltest_u1@localhost;
|
||||
GRANT INSERT ON mysqltest1.t2 TO mysqltest_u1@localhost;
|
||||
GRANT SELECT, UPDATE ON mysqltest1.t3 TO mysqltest_u1@localhost;
|
||||
GRANT SELECT, DELETE ON mysqltest1.t4 TO mysqltest_u1@localhost;
|
||||
|
||||
GRANT ALL PRIVILEGES ON mysqltest2.* TO mysqltest_u1@localhost;
|
||||
|
||||
--connect (bug24040_con,localhost,mysqltest_u1,,mysqltest2)
|
||||
--echo
|
||||
--echo ---> connection: bug24040_con
|
||||
|
||||
SELECT * FROM mysqltest1.t1;
|
||||
INSERT INTO mysqltest1.t2 VALUES(25);
|
||||
UPDATE mysqltest1.t3 SET c3 = 331 WHERE c3 = 31;
|
||||
DELETE FROM mysqltest1.t4 WHERE c4 = 44;
|
||||
|
||||
CREATE VIEW v1 AS SELECT * FROM mysqltest1.t1;
|
||||
CREATE VIEW v2 AS SELECT * FROM mysqltest1.t2;
|
||||
CREATE VIEW v3 AS SELECT * FROM mysqltest1.t3;
|
||||
CREATE VIEW v4 AS SELECT * FROM mysqltest1.t4;
|
||||
|
||||
SELECT * FROM v1;
|
||||
INSERT INTO v2 VALUES(26);
|
||||
UPDATE v3 SET c3 = 332 WHERE c3 = 32;
|
||||
DELETE FROM v4 WHERE c4 = 43;
|
||||
|
||||
--error ER_COLUMNACCESS_DENIED_ERROR
|
||||
CREATE VIEW v12 AS SELECT c1, c2 FROM mysqltest1.t1, mysqltest1.t2;
|
||||
CREATE VIEW v13 AS SELECT c1, c3 FROM mysqltest1.t1, mysqltest1.t3;
|
||||
CREATE VIEW v14 AS SELECT c1, c4 FROM mysqltest1.t1, mysqltest1.t4;
|
||||
|
||||
--error ER_COLUMNACCESS_DENIED_ERROR
|
||||
CREATE VIEW v21 AS SELECT c2, c1 FROM mysqltest1.t2, mysqltest1.t1;
|
||||
--error ER_COLUMNACCESS_DENIED_ERROR
|
||||
CREATE VIEW v23 AS SELECT c2, c3 FROM mysqltest1.t2, mysqltest1.t3;
|
||||
--error ER_COLUMNACCESS_DENIED_ERROR
|
||||
CREATE VIEW v24 AS SELECT c2, c4 FROM mysqltest1.t2, mysqltest1.t4;
|
||||
|
||||
CREATE VIEW v31 AS SELECT c3, c1 FROM mysqltest1.t3, mysqltest1.t1;
|
||||
--error ER_COLUMNACCESS_DENIED_ERROR
|
||||
CREATE VIEW v32 AS SELECT c3, c2 FROM mysqltest1.t3, mysqltest1.t2;
|
||||
CREATE VIEW v34 AS SELECT c3, c4 FROM mysqltest1.t3, mysqltest1.t4;
|
||||
|
||||
CREATE VIEW v41 AS SELECT c4, c1 FROM mysqltest1.t4, mysqltest1.t1;
|
||||
--error ER_COLUMNACCESS_DENIED_ERROR
|
||||
CREATE VIEW v42 AS SELECT c4, c2 FROM mysqltest1.t4, mysqltest1.t2;
|
||||
CREATE VIEW v43 AS SELECT c4, c3 FROM mysqltest1.t4, mysqltest1.t3;
|
||||
|
||||
--connection default
|
||||
--echo
|
||||
--echo ---> connection: default
|
||||
|
||||
SELECT * FROM mysqltest1.t1;
|
||||
SELECT * FROM mysqltest1.t2;
|
||||
SELECT * FROM mysqltest1.t3;
|
||||
SELECT * FROM mysqltest1.t4;
|
||||
|
||||
# Cleanup.
|
||||
|
||||
-- disconnect bug24040_con
|
||||
|
||||
DROP DATABASE mysqltest1;
|
||||
DROP DATABASE mysqltest2;
|
||||
DROP USER mysqltest_u1@localhost;
|
||||
|
||||
--echo End of 5.0 tests.
|
||||
|
Reference in New Issue
Block a user