2006-11-13 17:06:45 +01:00
|
|
|
# this test mostly test privilege control (what doesn't work
|
2009-10-19 14:58:13 +02:00
|
|
|
# in the embedded server by default). So skip the test in embedded-server mode.
|
2006-11-13 17:06:45 +01:00
|
|
|
-- source include/not_embedded.inc
|
2023-10-19 17:02:37 +02:00
|
|
|
-- source include/have_innodb.inc
|
2005-05-06 21:06:10 +02:00
|
|
|
-- source include/testdb_only.inc
|
|
|
|
|
2015-08-11 18:45:38 +02:00
|
|
|
set local sql_mode="";
|
|
|
|
set global sql_mode="";
|
|
|
|
|
2005-05-24 12:35:23 +02:00
|
|
|
--replace_result 'Tables_in_INFORMATION_SCHEMA (T%)' 'Tables_in_information_schema (T%)'
|
2014-08-25 19:08:55 +02:00
|
|
|
--sorted_result
|
2005-05-06 21:06:10 +02:00
|
|
|
show tables from INFORMATION_SCHEMA like 'T%';
|
|
|
|
create database `inf%`;
|
2006-05-30 07:45:23 +02:00
|
|
|
create database mbase;
|
2005-05-06 21:06:10 +02:00
|
|
|
use `inf%`;
|
|
|
|
show tables;
|
2006-03-20 10:42:02 +01:00
|
|
|
|
2023-10-19 16:55:16 +02:00
|
|
|
--echo #
|
|
|
|
--echo # Bug#18113 SELECT * FROM information_schema.xxx crashes server
|
|
|
|
--echo # Bug#17204 second CALL to procedure crashes Server
|
|
|
|
--echo #
|
2006-03-20 10:42:02 +01:00
|
|
|
# Crash happened when one selected data from one of INFORMATION_SCHEMA
|
|
|
|
# tables and in order to build its contents server had to open view which
|
|
|
|
# used stored function and table or view on which one had not global or
|
|
|
|
# database-level privileges (e.g. had only table-level or had no
|
|
|
|
# privileges at all).
|
|
|
|
#
|
2022-06-09 05:32:51 +02:00
|
|
|
--disable_view_protocol
|
2006-03-20 10:42:02 +01:00
|
|
|
grant all privileges on `inf%`.* to 'mysqltest_1'@'localhost';
|
2006-05-30 07:45:23 +02:00
|
|
|
grant all privileges on `mbase`.* to 'mysqltest_1'@'localhost';
|
2006-03-20 10:42:02 +01:00
|
|
|
create table t1 (f1 int);
|
|
|
|
delimiter |;
|
2021-06-06 19:39:15 +02:00
|
|
|
--enable_prepare_warnings
|
2006-03-20 10:42:02 +01:00
|
|
|
create function func1(curr_int int) returns int
|
|
|
|
begin
|
|
|
|
declare ret_val int;
|
|
|
|
select max(f1) from t1 into ret_val;
|
|
|
|
return ret_val;
|
|
|
|
end|
|
2021-06-06 19:39:15 +02:00
|
|
|
--disable_prepare_warnings
|
2006-03-20 10:42:02 +01:00
|
|
|
delimiter ;|
|
|
|
|
create view v1 as select f1 from t1 where f1 = func1(f1);
|
2006-05-30 07:45:23 +02:00
|
|
|
create function func2() returns int return 1;
|
|
|
|
|
|
|
|
use mbase;
|
|
|
|
delimiter |;
|
|
|
|
create procedure p1 ()
|
|
|
|
begin
|
|
|
|
select table_name from information_schema.key_column_usage
|
|
|
|
order by table_name;
|
|
|
|
end|
|
|
|
|
delimiter ;|
|
|
|
|
|
2009-05-15 11:59:31 +02:00
|
|
|
create table t1
|
2006-05-30 07:45:23 +02:00
|
|
|
(f1 int(10) unsigned not null,
|
|
|
|
f2 varchar(100) not null,
|
|
|
|
primary key (f1), unique key (f2));
|
|
|
|
|
2022-06-13 14:37:59 +02:00
|
|
|
connect (user1,localhost,mysqltest_1,,"*NO-ONE*");
|
2006-03-20 10:42:02 +01:00
|
|
|
connection user1;
|
|
|
|
--disable_result_log
|
|
|
|
select * from information_schema.tables;
|
2006-05-30 07:45:23 +02:00
|
|
|
call mbase.p1();
|
|
|
|
call mbase.p1();
|
|
|
|
call mbase.p1();
|
2006-03-20 10:42:02 +01:00
|
|
|
--enable_result_log
|
2006-05-30 07:45:23 +02:00
|
|
|
|
2006-03-20 10:42:02 +01:00
|
|
|
connection default;
|
2006-05-30 07:45:23 +02:00
|
|
|
use `inf%`;
|
2006-03-20 10:42:02 +01:00
|
|
|
drop user mysqltest_1@localhost;
|
2006-05-30 07:45:23 +02:00
|
|
|
drop table t1;
|
|
|
|
select table_name, table_type, table_comment from information_schema.tables
|
|
|
|
where table_schema='inf%' and func2();
|
|
|
|
select table_name, table_type, table_comment from information_schema.tables
|
|
|
|
where table_schema='inf%' and func2();
|
2006-03-20 10:42:02 +01:00
|
|
|
drop view v1;
|
|
|
|
drop function func1;
|
2006-05-30 07:45:23 +02:00
|
|
|
drop function func2;
|
2006-03-20 10:42:02 +01:00
|
|
|
|
2005-05-06 21:06:10 +02:00
|
|
|
drop database `inf%`;
|
2006-05-30 07:45:23 +02:00
|
|
|
drop procedure mbase.p1;
|
|
|
|
drop database mbase;
|
2008-10-02 11:37:07 +02:00
|
|
|
disconnect user1;
|
2006-05-30 07:45:23 +02:00
|
|
|
|
2023-10-19 16:55:16 +02:00
|
|
|
--echo #
|
|
|
|
--echo # Bug#18282 INFORMATION_SCHEMA.TABLES provides inconsistent info about invalid views
|
|
|
|
--echo #
|
2006-05-30 07:45:23 +02:00
|
|
|
use test;
|
|
|
|
create table t1 (i int);
|
|
|
|
create function f1 () returns int return (select max(i) from t1);
|
|
|
|
create view v1 as select f1();
|
|
|
|
create table t2 (id int);
|
|
|
|
create function f2 () returns int return (select max(i) from t2);
|
|
|
|
create view v2 as select f2();
|
|
|
|
drop table t2;
|
|
|
|
select table_name, table_type, table_comment from information_schema.tables
|
2017-10-31 10:00:20 +01:00
|
|
|
where table_schema='test' order by table_name;
|
2006-05-30 07:45:23 +02:00
|
|
|
drop table t1;
|
|
|
|
select table_name, table_type, table_comment from information_schema.tables
|
2017-10-31 10:00:20 +01:00
|
|
|
where table_schema='test' order by table_name;
|
2006-05-30 07:45:23 +02:00
|
|
|
drop function f1;
|
|
|
|
drop function f2;
|
|
|
|
drop view v1, v2;
|
2022-06-09 05:32:51 +02:00
|
|
|
--enable_view_protocol
|
Bug#20543 select on information_schema strange warnings, view, different schemas/users
The fix is: if user has privileges to view fields and user has any
(insert,select,delete,update) privileges on underlying view
then 'show fields' and select from I_S.COLUMNS table are sucsessful.
mysql-test/r/information_schema_db.result:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
test result
mysql-test/t/information_schema_db.test:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
test case
sql/sql_acl.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
checked that user has privileges on underlying view and if it's true
set allowed_show to true for top view.
sql/sql_show.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
removed unnecessary rights check.'tables->allowed_show' check is used instead
sql/sql_view.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
skip the check of SHOW_VIEW_ACL privilege on underlying view. It is done later during
execution of find_field_in_table_ref function.
sql/table.h:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
'allowed_show' is set during rights check for view. If true then user has privileges
for 'show create view', etc
2006-07-25 14:23:25 +02:00
|
|
|
|
2023-10-19 16:55:16 +02:00
|
|
|
--echo #
|
|
|
|
--echo # Bug#20543 select on information_schema strange warnings, view, different
|
|
|
|
--echo # schemas/users
|
|
|
|
--echo #
|
2022-06-09 05:32:51 +02:00
|
|
|
--disable_service_connection
|
Bug#20543 select on information_schema strange warnings, view, different schemas/users
The fix is: if user has privileges to view fields and user has any
(insert,select,delete,update) privileges on underlying view
then 'show fields' and select from I_S.COLUMNS table are sucsessful.
mysql-test/r/information_schema_db.result:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
test result
mysql-test/t/information_schema_db.test:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
test case
sql/sql_acl.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
checked that user has privileges on underlying view and if it's true
set allowed_show to true for top view.
sql/sql_show.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
removed unnecessary rights check.'tables->allowed_show' check is used instead
sql/sql_view.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
skip the check of SHOW_VIEW_ACL privilege on underlying view. It is done later during
execution of find_field_in_table_ref function.
sql/table.h:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
'allowed_show' is set during rights check for view. If true then user has privileges
for 'show create view', etc
2006-07-25 14:23:25 +02:00
|
|
|
create database testdb_1;
|
|
|
|
create user testdb_1@localhost;
|
|
|
|
grant all on testdb_1.* to testdb_1@localhost with grant option;
|
|
|
|
|
|
|
|
create user testdb_2@localhost;
|
|
|
|
grant all on test.* to testdb_2@localhost with grant option;
|
|
|
|
|
2022-06-13 14:37:59 +02:00
|
|
|
connect (testdb_1,localhost,testdb_1,,testdb_1);
|
Bug#20543 select on information_schema strange warnings, view, different schemas/users
The fix is: if user has privileges to view fields and user has any
(insert,select,delete,update) privileges on underlying view
then 'show fields' and select from I_S.COLUMNS table are sucsessful.
mysql-test/r/information_schema_db.result:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
test result
mysql-test/t/information_schema_db.test:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
test case
sql/sql_acl.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
checked that user has privileges on underlying view and if it's true
set allowed_show to true for top view.
sql/sql_show.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
removed unnecessary rights check.'tables->allowed_show' check is used instead
sql/sql_view.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
skip the check of SHOW_VIEW_ACL privilege on underlying view. It is done later during
execution of find_field_in_table_ref function.
sql/table.h:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
'allowed_show' is set during rights check for view. If true then user has privileges
for 'show create view', etc
2006-07-25 14:23:25 +02:00
|
|
|
create table t1 (f1 char(4));
|
|
|
|
create view v1 as select f1 from t1;
|
|
|
|
grant insert on v1 to testdb_2@localhost;
|
|
|
|
|
2007-03-23 19:24:03 +01:00
|
|
|
create view v5 as select f1 from t1;
|
2009-10-19 14:58:13 +02:00
|
|
|
grant select, show view on v5 to testdb_2@localhost;
|
2007-03-23 19:24:03 +01:00
|
|
|
|
2009-05-15 11:59:31 +02:00
|
|
|
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
|
2007-03-23 19:24:03 +01:00
|
|
|
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;
|
2009-10-19 14:58:13 +02:00
|
|
|
grant select, show view on v6 to testdb_2@localhost;
|
2007-03-23 19:24:03 +01:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
Bug#20543 select on information_schema strange warnings, view, different schemas/users
The fix is: if user has privileges to view fields and user has any
(insert,select,delete,update) privileges on underlying view
then 'show fields' and select from I_S.COLUMNS table are sucsessful.
mysql-test/r/information_schema_db.result:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
test result
mysql-test/t/information_schema_db.test:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
test case
sql/sql_acl.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
checked that user has privileges on underlying view and if it's true
set allowed_show to true for top view.
sql/sql_show.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
removed unnecessary rights check.'tables->allowed_show' check is used instead
sql/sql_view.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
skip the check of SHOW_VIEW_ACL privilege on underlying view. It is done later during
execution of find_field_in_table_ref function.
sql/table.h:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
'allowed_show' is set during rights check for view. If true then user has privileges
for 'show create view', etc
2006-07-25 14:23:25 +02:00
|
|
|
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;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2007-03-23 19:24:03 +01:00
|
|
|
show fields from testdb_1.v5;
|
|
|
|
show create view testdb_1.v5;
|
|
|
|
|
|
|
|
show fields from testdb_1.v6;
|
|
|
|
show create view testdb_1.v6;
|
|
|
|
|
Bug#20543 select on information_schema strange warnings, view, different schemas/users
The fix is: if user has privileges to view fields and user has any
(insert,select,delete,update) privileges on underlying view
then 'show fields' and select from I_S.COLUMNS table are sucsessful.
mysql-test/r/information_schema_db.result:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
test result
mysql-test/t/information_schema_db.test:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
test case
sql/sql_acl.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
checked that user has privileges on underlying view and if it's true
set allowed_show to true for top view.
sql/sql_show.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
removed unnecessary rights check.'tables->allowed_show' check is used instead
sql/sql_view.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
skip the check of SHOW_VIEW_ACL privilege on underlying view. It is done later during
execution of find_field_in_table_ref function.
sql/table.h:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
'allowed_show' is set during rights check for view. If true then user has privileges
for 'show create view', etc
2006-07-25 14:23:25 +02:00
|
|
|
connection testdb_1;
|
2007-03-23 19:24:03 +01:00
|
|
|
show fields from testdb_1.v7;
|
|
|
|
show create view testdb_1.v7;
|
|
|
|
|
Bug#20543 select on information_schema strange warnings, view, different schemas/users
The fix is: if user has privileges to view fields and user has any
(insert,select,delete,update) privileges on underlying view
then 'show fields' and select from I_S.COLUMNS table are sucsessful.
mysql-test/r/information_schema_db.result:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
test result
mysql-test/t/information_schema_db.test:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
test case
sql/sql_acl.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
checked that user has privileges on underlying view and if it's true
set allowed_show to true for top view.
sql/sql_show.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
removed unnecessary rights check.'tables->allowed_show' check is used instead
sql/sql_view.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
skip the check of SHOW_VIEW_ACL privilege on underlying view. It is done later during
execution of find_field_in_table_ref function.
sql/table.h:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
'allowed_show' is set during rights check for view. If true then user has privileges
for 'show create view', etc
2006-07-25 14:23:25 +02:00
|
|
|
revoke insert(f1) on v3 from testdb_2@localhost;
|
2009-10-19 14:58:13 +02:00
|
|
|
revoke select,show view on v5 from testdb_2@localhost;
|
2007-03-23 19:24:03 +01:00
|
|
|
connection default;
|
|
|
|
use testdb_1;
|
2009-10-19 14:58:13 +02:00
|
|
|
revoke select,show view on v6 from testdb_2@localhost;
|
Bug#20543 select on information_schema strange warnings, view, different schemas/users
The fix is: if user has privileges to view fields and user has any
(insert,select,delete,update) privileges on underlying view
then 'show fields' and select from I_S.COLUMNS table are sucsessful.
mysql-test/r/information_schema_db.result:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
test result
mysql-test/t/information_schema_db.test:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
test case
sql/sql_acl.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
checked that user has privileges on underlying view and if it's true
set allowed_show to true for top view.
sql/sql_show.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
removed unnecessary rights check.'tables->allowed_show' check is used instead
sql/sql_view.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
skip the check of SHOW_VIEW_ACL privilege on underlying view. It is done later during
execution of find_field_in_table_ref function.
sql/table.h:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
'allowed_show' is set during rights check for view. If true then user has privileges
for 'show create view', etc
2006-07-25 14:23:25 +02:00
|
|
|
connection testdb_2;
|
|
|
|
|
2009-05-15 11:59:31 +02:00
|
|
|
--error ER_TABLEACCESS_DENIED_ERROR
|
2007-03-23 19:24:03 +01:00
|
|
|
show fields from testdb_1.v5;
|
2009-05-15 11:59:31 +02:00
|
|
|
--error ER_TABLEACCESS_DENIED_ERROR
|
2007-03-23 19:24:03 +01:00
|
|
|
show create view testdb_1.v5;
|
|
|
|
|
2009-05-15 11:59:31 +02:00
|
|
|
--error ER_TABLEACCESS_DENIED_ERROR
|
2007-03-23 19:24:03 +01:00
|
|
|
show fields from testdb_1.v6;
|
2009-05-15 11:59:31 +02:00
|
|
|
--error ER_TABLEACCESS_DENIED_ERROR
|
2007-03-23 19:24:03 +01:00
|
|
|
show create view testdb_1.v6;
|
|
|
|
|
2009-05-15 11:59:31 +02:00
|
|
|
--error ER_TABLEACCESS_DENIED_ERROR
|
2007-03-23 19:24:03 +01:00
|
|
|
show fields from testdb_1.v7;
|
2009-05-15 11:59:31 +02:00
|
|
|
--error ER_TABLEACCESS_DENIED_ERROR
|
2007-03-23 19:24:03 +01:00
|
|
|
show create view testdb_1.v7;
|
|
|
|
|
Bug#20543 select on information_schema strange warnings, view, different schemas/users
The fix is: if user has privileges to view fields and user has any
(insert,select,delete,update) privileges on underlying view
then 'show fields' and select from I_S.COLUMNS table are sucsessful.
mysql-test/r/information_schema_db.result:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
test result
mysql-test/t/information_schema_db.test:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
test case
sql/sql_acl.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
checked that user has privileges on underlying view and if it's true
set allowed_show to true for top view.
sql/sql_show.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
removed unnecessary rights check.'tables->allowed_show' check is used instead
sql/sql_view.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
skip the check of SHOW_VIEW_ACL privilege on underlying view. It is done later during
execution of find_field_in_table_ref function.
sql/table.h:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
'allowed_show' is set during rights check for view. If true then user has privileges
for 'show create view', etc
2006-07-25 14:23:25 +02:00
|
|
|
show create view v4;
|
2009-05-15 11:59:31 +02:00
|
|
|
#--error ER_VIEW_NO_EXPLAIN
|
Bug#20543 select on information_schema strange warnings, view, different schemas/users
The fix is: if user has privileges to view fields and user has any
(insert,select,delete,update) privileges on underlying view
then 'show fields' and select from I_S.COLUMNS table are sucsessful.
mysql-test/r/information_schema_db.result:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
test result
mysql-test/t/information_schema_db.test:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
test case
sql/sql_acl.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
checked that user has privileges on underlying view and if it's true
set allowed_show to true for top view.
sql/sql_show.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
removed unnecessary rights check.'tables->allowed_show' check is used instead
sql/sql_view.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
skip the check of SHOW_VIEW_ACL privilege on underlying view. It is done later during
execution of find_field_in_table_ref function.
sql/table.h:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
'allowed_show' is set during rights check for view. If true then user has privileges
for 'show create view', etc
2006-07-25 14:23:25 +02:00
|
|
|
show fields from v4;
|
|
|
|
|
|
|
|
show fields from v2;
|
|
|
|
show fields from testdb_1.v1;
|
|
|
|
show create view v2;
|
2009-05-15 11:59:31 +02:00
|
|
|
--error ER_TABLEACCESS_DENIED_ERROR
|
Bug#20543 select on information_schema strange warnings, view, different schemas/users
The fix is: if user has privileges to view fields and user has any
(insert,select,delete,update) privileges on underlying view
then 'show fields' and select from I_S.COLUMNS table are sucsessful.
mysql-test/r/information_schema_db.result:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
test result
mysql-test/t/information_schema_db.test:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
test case
sql/sql_acl.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
checked that user has privileges on underlying view and if it's true
set allowed_show to true for top view.
sql/sql_show.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
removed unnecessary rights check.'tables->allowed_show' check is used instead
sql/sql_view.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
skip the check of SHOW_VIEW_ACL privilege on underlying view. It is done later during
execution of find_field_in_table_ref function.
sql/table.h:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
'allowed_show' is set during rights check for view. If true then user has privileges
for 'show create view', etc
2006-07-25 14:23:25 +02:00
|
|
|
show create view testdb_1.v1;
|
|
|
|
|
2009-05-15 11:59:31 +02:00
|
|
|
select table_name from information_schema.columns a
|
Bug#20543 select on information_schema strange warnings, view, different schemas/users
The fix is: if user has privileges to view fields and user has any
(insert,select,delete,update) privileges on underlying view
then 'show fields' and select from I_S.COLUMNS table are sucsessful.
mysql-test/r/information_schema_db.result:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
test result
mysql-test/t/information_schema_db.test:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
test case
sql/sql_acl.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
checked that user has privileges on underlying view and if it's true
set allowed_show to true for top view.
sql/sql_show.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
removed unnecessary rights check.'tables->allowed_show' check is used instead
sql/sql_view.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
skip the check of SHOW_VIEW_ACL privilege on underlying view. It is done later during
execution of find_field_in_table_ref function.
sql/table.h:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
'allowed_show' is set during rights check for view. If true then user has privileges
for 'show create view', etc
2006-07-25 14:23:25 +02:00
|
|
|
where a.table_name = 'v2';
|
2009-05-15 11:59:31 +02:00
|
|
|
select view_definition from information_schema.views a
|
Bug#20543 select on information_schema strange warnings, view, different schemas/users
The fix is: if user has privileges to view fields and user has any
(insert,select,delete,update) privileges on underlying view
then 'show fields' and select from I_S.COLUMNS table are sucsessful.
mysql-test/r/information_schema_db.result:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
test result
mysql-test/t/information_schema_db.test:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
test case
sql/sql_acl.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
checked that user has privileges on underlying view and if it's true
set allowed_show to true for top view.
sql/sql_show.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
removed unnecessary rights check.'tables->allowed_show' check is used instead
sql/sql_view.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
skip the check of SHOW_VIEW_ACL privilege on underlying view. It is done later during
execution of find_field_in_table_ref function.
sql/table.h:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
'allowed_show' is set during rights check for view. If true then user has privileges
for 'show create view', etc
2006-07-25 14:23:25 +02:00
|
|
|
where a.table_name = 'v2';
|
2009-05-15 11:59:31 +02:00
|
|
|
select view_definition from information_schema.views a
|
Bug#20543 select on information_schema strange warnings, view, different schemas/users
The fix is: if user has privileges to view fields and user has any
(insert,select,delete,update) privileges on underlying view
then 'show fields' and select from I_S.COLUMNS table are sucsessful.
mysql-test/r/information_schema_db.result:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
test result
mysql-test/t/information_schema_db.test:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
test case
sql/sql_acl.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
checked that user has privileges on underlying view and if it's true
set allowed_show to true for top view.
sql/sql_show.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
removed unnecessary rights check.'tables->allowed_show' check is used instead
sql/sql_view.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
skip the check of SHOW_VIEW_ACL privilege on underlying view. It is done later during
execution of find_field_in_table_ref function.
sql/table.h:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
'allowed_show' is set during rights check for view. If true then user has privileges
for 'show create view', etc
2006-07-25 14:23:25 +02:00
|
|
|
where a.table_name = 'testdb_1.v1';
|
|
|
|
|
2009-05-15 11:59:31 +02:00
|
|
|
--error ER_VIEW_INVALID
|
Bug#20543 select on information_schema strange warnings, view, different schemas/users
The fix is: if user has privileges to view fields and user has any
(insert,select,delete,update) privileges on underlying view
then 'show fields' and select from I_S.COLUMNS table are sucsessful.
mysql-test/r/information_schema_db.result:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
test result
mysql-test/t/information_schema_db.test:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
test case
sql/sql_acl.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
checked that user has privileges on underlying view and if it's true
set allowed_show to true for top view.
sql/sql_show.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
removed unnecessary rights check.'tables->allowed_show' check is used instead
sql/sql_view.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
skip the check of SHOW_VIEW_ACL privilege on underlying view. It is done later during
execution of find_field_in_table_ref function.
sql/table.h:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
'allowed_show' is set during rights check for view. If true then user has privileges
for 'show create view', etc
2006-07-25 14:23:25 +02:00
|
|
|
select * from v2;
|
|
|
|
|
|
|
|
connection default;
|
2007-03-23 19:24:03 +01:00
|
|
|
use test;
|
|
|
|
drop view testdb_1.v1, v2, testdb_1.v3, v4;
|
Bug#20543 select on information_schema strange warnings, view, different schemas/users
The fix is: if user has privileges to view fields and user has any
(insert,select,delete,update) privileges on underlying view
then 'show fields' and select from I_S.COLUMNS table are sucsessful.
mysql-test/r/information_schema_db.result:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
test result
mysql-test/t/information_schema_db.test:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
test case
sql/sql_acl.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
checked that user has privileges on underlying view and if it's true
set allowed_show to true for top view.
sql/sql_show.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
removed unnecessary rights check.'tables->allowed_show' check is used instead
sql/sql_view.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
skip the check of SHOW_VIEW_ACL privilege on underlying view. It is done later during
execution of find_field_in_table_ref function.
sql/table.h:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
'allowed_show' is set during rights check for view. If true then user has privileges
for 'show create view', etc
2006-07-25 14:23:25 +02:00
|
|
|
drop database testdb_1;
|
2009-05-15 11:59:31 +02:00
|
|
|
connection testdb_1;
|
|
|
|
disconnect testdb_1;
|
|
|
|
--source include/wait_until_disconnected.inc
|
|
|
|
connection testdb_2;
|
|
|
|
disconnect testdb_2;
|
|
|
|
--source include/wait_until_disconnected.inc
|
|
|
|
connection default;
|
Bug#20543 select on information_schema strange warnings, view, different schemas/users
The fix is: if user has privileges to view fields and user has any
(insert,select,delete,update) privileges on underlying view
then 'show fields' and select from I_S.COLUMNS table are sucsessful.
mysql-test/r/information_schema_db.result:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
test result
mysql-test/t/information_schema_db.test:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
test case
sql/sql_acl.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
checked that user has privileges on underlying view and if it's true
set allowed_show to true for top view.
sql/sql_show.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
removed unnecessary rights check.'tables->allowed_show' check is used instead
sql/sql_view.cc:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
skip the check of SHOW_VIEW_ACL privilege on underlying view. It is done later during
execution of find_field_in_table_ref function.
sql/table.h:
Bug#20543 select on information_schema strange warnings, view, different schemas/users
'allowed_show' is set during rights check for view. If true then user has privileges
for 'show create view', etc
2006-07-25 14:23:25 +02:00
|
|
|
drop user testdb_1@localhost;
|
2006-08-07 08:56:22 +02:00
|
|
|
drop user testdb_2@localhost;
|
2008-10-02 11:37:07 +02:00
|
|
|
|
2023-10-19 16:55:16 +02:00
|
|
|
--echo #
|
|
|
|
--echo # Bug#22763 Disrepancy between SHOW CREATE VIEW and I_S.VIEWS
|
|
|
|
--echo #
|
2008-10-02 11:37:07 +02:00
|
|
|
create database testdb_1;
|
|
|
|
create table testdb_1.t1 (a int);
|
|
|
|
create view testdb_1.v1 as select * from testdb_1.t1;
|
|
|
|
|
|
|
|
grant show view on testdb_1.* to mysqltest_1@localhost;
|
|
|
|
grant select on testdb_1.v1 to mysqltest_1@localhost;
|
|
|
|
|
2022-06-13 14:37:59 +02:00
|
|
|
connect (user1,localhost,mysqltest_1,,"*NO-ONE*");
|
2008-10-02 11:37:07 +02:00
|
|
|
connection user1;
|
|
|
|
select table_schema, table_name, view_definition from information_schema.views
|
|
|
|
where table_name='v1';
|
|
|
|
show create view testdb_1.v1;
|
|
|
|
|
|
|
|
connection default;
|
|
|
|
revoke select on testdb_1.v1 from mysqltest_1@localhost;
|
|
|
|
connection user1;
|
|
|
|
select table_schema, table_name, view_definition from information_schema.views
|
|
|
|
where table_name='v1';
|
|
|
|
--error ER_TABLEACCESS_DENIED_ERROR
|
|
|
|
show create view testdb_1.v1;
|
|
|
|
|
|
|
|
connection default;
|
|
|
|
drop user mysqltest_1@localhost;
|
|
|
|
drop database testdb_1;
|
2009-05-15 11:59:31 +02:00
|
|
|
connection user1;
|
2008-10-02 11:37:07 +02:00
|
|
|
disconnect user1;
|
2009-05-15 11:59:31 +02:00
|
|
|
--source include/wait_until_disconnected.inc
|
|
|
|
connection default;
|
2015-08-11 18:45:38 +02:00
|
|
|
|
|
|
|
set global sql_mode=default;
|
2019-09-10 17:31:10 +02:00
|
|
|
|
2023-10-19 16:55:16 +02:00
|
|
|
--echo #
|
|
|
|
--echo # MDEV-20549 SQL SECURITY DEFINER does not work for INFORMATION_SCHEMA tables
|
|
|
|
--echo #
|
2019-09-10 17:31:10 +02:00
|
|
|
|
|
|
|
create user foo@localhost;
|
|
|
|
grant select on test.* to foo@localhost;
|
|
|
|
create procedure rootonly() select 1;
|
2023-10-19 17:02:37 +02:00
|
|
|
create sql security definer view v1d as select current_user(),user from information_schema.processlist where command!='daemon';
|
|
|
|
create sql security invoker view v1i as select current_user(),user from information_schema.processlist where command!='daemon';
|
2019-09-10 17:31:10 +02:00
|
|
|
create sql security definer view v2d as select table_name from information_schema.tables where table_schema='mysql' and table_name like '%user%';
|
|
|
|
create sql security invoker view v2i as select table_name from information_schema.tables where table_schema='mysql' and table_name like '%user%';
|
|
|
|
create sql security definer view v3d as select schema_name from information_schema.schemata where schema_name like '%mysql%';
|
|
|
|
create sql security invoker view v3i as select schema_name from information_schema.schemata where schema_name like '%mysql%';
|
|
|
|
create sql security definer view v4d as select routine_name from information_schema.routines where routine_schema='test';
|
|
|
|
create sql security invoker view v4i as select routine_name from information_schema.routines where routine_schema='test';
|
|
|
|
create sql security definer view v5d as select view_definition > '' from information_schema.views where table_name='v1d';
|
|
|
|
create sql security invoker view v5i as select view_definition > '' from information_schema.views where table_name='v1d';
|
|
|
|
connect foo,localhost,foo;
|
|
|
|
select * from v1d;
|
|
|
|
select * from v1i;
|
|
|
|
select * from v2d;
|
|
|
|
select * from v2i;
|
|
|
|
select * from v3d;
|
|
|
|
select * from v3i;
|
|
|
|
select * from v4d;
|
|
|
|
select * from v4i;
|
|
|
|
select * from v5d;
|
|
|
|
select * from v5i;
|
|
|
|
connection default;
|
|
|
|
select * from v1d;
|
|
|
|
select * from v1i;
|
|
|
|
select * from v2d;
|
|
|
|
select * from v2i;
|
|
|
|
select * from v3d;
|
|
|
|
select * from v3i;
|
|
|
|
select * from v4d;
|
|
|
|
select * from v4i;
|
|
|
|
select * from v5d;
|
|
|
|
select * from v5i;
|
|
|
|
disconnect foo;
|
|
|
|
drop view v1d, v1i, v2d, v2i, v3d, v3i, v4d, v4i, v5d, v5i;
|
|
|
|
drop user foo@localhost;
|
|
|
|
drop procedure rootonly;
|
2022-06-09 05:32:51 +02:00
|
|
|
--enable_service_connection
|
2023-10-19 16:55:16 +02:00
|
|
|
|
|
|
|
--echo #
|
|
|
|
--echo # End of 10.2 tests
|
|
|
|
--echo #
|
2023-10-19 17:02:37 +02:00
|
|
|
|
|
|
|
--echo #
|
|
|
|
--echo # MDEV-32500 Information schema leaks table names and structure to unauthorized users
|
|
|
|
--echo #
|
|
|
|
create database db;
|
|
|
|
create table db.t1 (x int, key(x)) engine=InnoDB;
|
|
|
|
create table db.t2 (a int, b int, c int, unique(b), check(c>b), foreign key(c) references db.t1(x)) engine=InnoDB;
|
|
|
|
create table db.t3 (d int, e int, f int, unique(e), check(f>e), foreign key(f) references db.t1(x),
|
|
|
|
foreign key(e) references db.t2(b),
|
|
|
|
foreign key(d) references db.t3(f)
|
|
|
|
) engine=InnoDB;
|
|
|
|
|
|
|
|
create user u@localhost;
|
|
|
|
grant select (a) on db.t2 to u@localhost;
|
|
|
|
grant update (d) on db.t3 to u@localhost;
|
|
|
|
|
|
|
|
--connect con1,localhost,u,,db
|
|
|
|
--sorted_result
|
|
|
|
select table_name, column_name from information_schema.columns where table_name like 't_';
|
|
|
|
select table_name, column_name from information_schema.key_column_usage where table_name like 't_';
|
|
|
|
select table_name, unique_constraint_name, referenced_table_name from information_schema.referential_constraints where table_name like 't_';
|
|
|
|
select table_name, constraint_name, constraint_type from information_schema.table_constraints where table_name like 't_';
|
|
|
|
show index in t2;
|
|
|
|
show index in t3;
|
|
|
|
|
|
|
|
--disconnect con1
|
|
|
|
--connection default
|
|
|
|
drop user u@localhost;
|
|
|
|
drop database db;
|
|
|
|
|
|
|
|
--echo #
|
|
|
|
--echo # End of 10.4 tests
|
|
|
|
--echo #
|
2024-03-15 22:12:30 +01:00
|
|
|
|
|
|
|
--echo #
|
|
|
|
--echo # MDEV-23729 INFORMATION_SCHEMA Table info. about user locked due to
|
|
|
|
--echo # max_password_errors
|
|
|
|
--echo #
|
|
|
|
--echo # MDEV-32218 message to notify end-user N-days prior the password get
|
|
|
|
--echo # expired
|
|
|
|
--echo #
|
|
|
|
|
|
|
|
--disable_service_connection
|
|
|
|
set @old_max_password_errors=@@max_password_errors;
|
|
|
|
set global max_password_errors=2;
|
|
|
|
|
|
|
|
# must use replace_regex for case insenstive replacement
|
|
|
|
let $hostname_re= `select concat('/@\'', @@hostname, '\'/@HOSTNAME/i')`;
|
|
|
|
|
|
|
|
# set the password_last_changed value
|
|
|
|
set timestamp= unix_timestamp('2020-01-02 2:3:4');
|
|
|
|
|
|
|
|
create user nice_user;
|
|
|
|
create user naughty_user identified by 'naughty_user_passwd';
|
|
|
|
|
|
|
|
alter user naughty_user password expire interval 10 day;
|
|
|
|
|
|
|
|
--sorted_result
|
|
|
|
--replace_regex $hostname_re
|
|
|
|
eval select * from information_schema.users;
|
|
|
|
|
|
|
|
alter user nice_user password expire interval 10 day;
|
|
|
|
--sorted_result
|
|
|
|
--replace_regex $hostname_re
|
|
|
|
select * from information_schema.users;
|
|
|
|
|
|
|
|
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
|
|
|
|
--error ER_ACCESS_DENIED_ERROR
|
|
|
|
connect(con1, localhost, naughty_user, wrong_passwd);
|
|
|
|
|
|
|
|
--sorted_result
|
|
|
|
--replace_regex $hostname_re
|
|
|
|
select * from information_schema.users;
|
|
|
|
|
|
|
|
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
|
|
|
|
--error ER_ACCESS_DENIED_ERROR
|
|
|
|
connect(con1, localhost, naughty_user, wrong_passwd);
|
|
|
|
|
|
|
|
--sorted_result
|
|
|
|
--replace_regex $hostname_re
|
|
|
|
select * from information_schema.users;
|
|
|
|
|
|
|
|
|
|
|
|
--echo # Show all users that are blocked due to max_password_errors reached.
|
|
|
|
select user from information_schema.users
|
|
|
|
where password_errors >= @@global.max_password_errors;
|
|
|
|
|
|
|
|
|
|
|
|
set global max_password_errors=3;
|
|
|
|
|
|
|
|
connect(con1, localhost, naughty_user, naughty_user_passwd);
|
|
|
|
connection default;
|
|
|
|
|
|
|
|
--sorted_result
|
|
|
|
--replace_regex $hostname_re
|
|
|
|
select * from information_schema.users;
|
|
|
|
disconnect con1;
|
|
|
|
|
|
|
|
--echo # test FLUSH PRIVILEGES
|
|
|
|
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
|
|
|
|
--error ER_ACCESS_DENIED_ERROR
|
|
|
|
connect(con1, localhost, naughty_user, wrong_passwd);
|
|
|
|
select * from information_schema.users where user like '''naughty%';
|
|
|
|
flush privileges;
|
|
|
|
select * from information_schema.users where user like '''naughty%';
|
|
|
|
|
|
|
|
--echo # Test unprivileged output
|
|
|
|
|
|
|
|
connect(con2, localhost, nice_user);
|
|
|
|
set timestamp= unix_timestamp('2020-01-02 2:3:4');
|
|
|
|
# timestamp was normal at the login moment, so the password was expired
|
|
|
|
set password= password('nice_passwd');
|
|
|
|
|
|
|
|
--sorted_result
|
|
|
|
--replace_regex $hostname_re
|
|
|
|
select * from information_schema.users;
|
|
|
|
|
|
|
|
--echo # Delete user while some connection is still alive, then select.
|
|
|
|
connection default;
|
|
|
|
drop user nice_user;
|
|
|
|
connection con2;
|
|
|
|
# and here you are, select from your table
|
|
|
|
--error ER_INVALID_CURRENT_USER
|
|
|
|
select * from information_schema.users;
|
|
|
|
|
|
|
|
disconnect con2;
|
|
|
|
connection default;
|
|
|
|
drop user naughty_user;
|
|
|
|
set global max_password_errors=@old_max_password_errors;
|
|
|
|
|
|
|
|
--echo # more password expiration tests
|
|
|
|
set global default_password_lifetime= 2;
|
|
|
|
create user u1@localhost password expire;
|
|
|
|
create user u2@localhost password expire default;
|
|
|
|
create user u3@localhost password expire interval 10 day;
|
|
|
|
create user u4@localhost password expire interval 20 day;
|
|
|
|
create user u5@localhost password expire never;
|
|
|
|
set timestamp= unix_timestamp('2020-01-17 2:3:4');
|
|
|
|
|
|
|
|
select * from information_schema.users where user like '''u_''%';
|
|
|
|
set global default_password_lifetime= default;
|
|
|
|
select * from information_schema.users where user like '''u_''%';
|
|
|
|
|
|
|
|
drop user u1@localhost;
|
|
|
|
drop user u2@localhost;
|
|
|
|
drop user u3@localhost;
|
|
|
|
drop user u4@localhost;
|
|
|
|
drop user u5@localhost;
|
|
|
|
--enable_service_connection
|
|
|
|
|
|
|
|
--echo # End of 10.0 tests
|