2006-05-30 10:45:23 +05:00
|
|
|
drop table if exists t1,t2;
|
|
|
|
drop view if exists v1,v2;
|
|
|
|
drop function if exists f1;
|
|
|
|
drop function if exists f2;
|
2005-05-06 19:06:10 +00:00
|
|
|
use INFORMATION_SCHEMA;
|
|
|
|
show tables;
|
2005-05-24 14:35:23 +04:00
|
|
|
Tables_in_information_schema
|
2005-05-06 19:06:10 +00:00
|
|
|
CHARACTER_SETS
|
|
|
|
COLLATIONS
|
|
|
|
COLLATION_CHARACTER_SET_APPLICABILITY
|
2005-08-05 11:01:29 +02:00
|
|
|
COLUMNS
|
|
|
|
COLUMN_PRIVILEGES
|
2005-12-22 01:07:47 -08:00
|
|
|
ENGINES
|
fix for bug#16642 (Events: No INFORMATION_SCHEMA.EVENTS table)
post-review change - use pointer instead of copy on the stack.
WL#1034 (Internal CRON)
This patch adds INFORMATION_SCHEMA.EVENTS table with the following format:
EVENT_CATALOG - MYSQL_TYPE_STRING (Always NULL)
EVENT_SCHEMA - MYSQL_TYPE_STRING (the database)
EVENT_NAME - MYSQL_TYPE_STRING (the name)
DEFINER - MYSQL_TYPE_STRING (user@host)
EVENT_BODY - MYSQL_TYPE_STRING (the body from mysql.event)
EVENT_TYPE - MYSQL_TYPE_STRING ("ONE TIME" | "RECURRING")
EXECUTE_AT - MYSQL_TYPE_TIMESTAMP (set for "ONE TIME" otherwise NULL)
INTERVAL_VALUE - MYSQL_TYPE_LONG (set for RECURRING otherwise NULL)
INTERVAL_FIELD - MYSQL_TYPE_STRING (set for RECURRING otherwise NULL)
SQL_MODE - MYSQL_TYPE_STRING (for now NULL)
STARTS - MYSQL_TYPE_TIMESTAMP (starts from mysql.event)
ENDS - MYSQL_TYPE_TIMESTAMP (ends from mysql.event)
STATUS - MYSQL_TYPE_STRING (ENABLED | DISABLED)
ON_COMPLETION - MYSQL_TYPE_STRING (NOT PRESERVE | PRESERVE)
CREATED - MYSQL_TYPE_TIMESTAMP
LAST_ALTERED - MYSQL_TYPE_TIMESTAMP
LAST_EXECUTED - MYSQL_TYPE_TIMESTAMP
EVENT_COMMENT - MYSQL_TYPE_STRING
SQL_MODE is NULL for now, because the value is still not stored in mysql.event .
Support will be added as a fix for another bug.
This patch also adds SHOW [FULL] EVENTS [FROM db] [LIKE pattern]
1. SHOW EVENTS shows always only the events on the same user,
because the PK of mysql.event is (definer, db, name) several
users may have event with the same name -> no information disclosure.
2. SHOW FULL EVENTS - shows the events (in the current db as SHOW EVENTS)
of all users. The user has to have PROCESS privilege, if not then
SHOW FULL EVENTS behave like SHOW EVENTS.
3. If [FROM db] is specified then this db is considered.
4. Event names can be filtered with LIKE pattern.
SHOW EVENTS returns table with the following columns, which are subset of
the data which is returned by SELECT * FROM I_S.EVENTS
Db
Name
Definer
Type
Execute at
Interval value
Interval field
Starts
Ends
Status
mysql-test/lib/init_db.sql:
change the PK - (definer, db, name)
quicker searches when SHOW EVENTS;
allow also different users to have events with the same name ->
no information disclosure
mysql-test/r/events.result:
result of new tests
mysql-test/r/information_schema.result:
result of new tests
mysql-test/r/information_schema_db.result:
result of new tests
mysql-test/r/system_mysql_db.result:
result of new tests
mysql-test/t/events.test:
new tests for information_schema.events
scripts/mysql_create_system_tables.sh:
change the PK of mysql.event to (definer, db, name)
scripts/mysql_fix_privilege_tables.sql:
change the PK of mysql.event to (definer, db, name)
sql/event.cc:
pass around the definer of the event because of the new PK
which is (definer, db, name). It's needed for index searching.
sql/event.h:
- make enum evex_table_field again public so it can be used
in sql_show.cc
- make created and modified ulonglong, because they should be such
- make public evex_open_event_table so it can be used in sql_show.cc
sql/event_executor.cc:
- cosmetics
sql/event_priv.h:
- moved enum evex_table_field and evex_open_event_table()
to event.h (made them therefore public)
sql/event_timed.cc:
- in event_timed::init_definer() always fill this.definer with
the concatenated value of definer_user@definer_host. Makes
later the work easier.
- pass around the definer wherever is needed for searching
(new prototype of evex_db_find_evex_aux)
sql/mysqld.cc:
- add counter for SHOW EVENTS
sql/sql_lex.h:
- register SHOW EVENTS as command
sql/sql_parse.cc:
- handle SCH_EVENTS (I_S.EVENTS like SCH_TRIGGERS)
- make additional check in case of SHOW EVENTS (check for EVENT on
the current database. if it is null check_access() gives appropriate
message back.
sql/sql_show.cc:
- add INFORMATION_SCHEMA.EVENTS and SHOW EVENTS
- I_S.EVENTS.SQL_MODE is NULL for now -> not implemented. Trudy
asked to be added so bug #16642 can be completely closed. There
is another bug report which will fix the lack of storage of
SQL_MODE during event creation.
sql/sql_yacc.yy:
- always call event_timed::init_definer() when CREATE/ALTER/DROP
EVENT but not when just compiling the body of the event because
in this case this operation is not needed, it takes memory and
CPU time and at the end the result is not used. event_timed::definer
is used only on SQLCOM_CREATE/ALTER/DROP_EVENT execution not on
statement compilation.
- add SHOW [FULL] EVENTS [FROM db] [LIKE pattern]
in case of FULL and the user has PROCESS privilege then he will see
also others' events in the current database, otherwise the output
is the same as of SHOW EVENTS. Because the events are per DB only
the events from the current database are shown. pattern is applied
against event name. FROM db is self explanatory.
sql/table.h:
add SCH_EVENTS as part of INFORMATION_SCHEMA
2006-01-30 13:15:23 +01:00
|
|
|
EVENTS
|
2006-02-02 00:47:08 +11:00
|
|
|
FILES
|
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
mysql-test/r/information_schema.result:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Fixed test cases result (changes are due to the new tables added).
mysql-test/r/information_schema_db.result:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Fixed test cases result (changes are due to the new tables added).
mysql-test/r/status.result:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Fixed results for added testcases.
mysql-test/r/variables.result:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Fixed results for added test cases.
mysql-test/t/status.test:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Added test cases.
mysql-test/t/variables.test:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Added test cases.
sql/sql_show.cc:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Implementation of the new I_S tables.
Also, show_status_array(): argument 'ucase_names' is added (true means that
all variable names are to be converted to upper case).
sql/table.h:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Implementation of the new I_S tables.
2006-09-14 03:37:40 +04:00
|
|
|
GLOBAL_STATUS
|
|
|
|
GLOBAL_VARIABLES
|
2005-08-05 11:01:29 +02:00
|
|
|
KEY_COLUMN_USAGE
|
2006-01-10 19:44:04 +04:00
|
|
|
PARTITIONS
|
2005-12-21 10:18:40 -08:00
|
|
|
PLUGINS
|
2006-02-16 16:45:05 +03:00
|
|
|
PROCESSLIST
|
2006-05-02 16:31:39 +05:00
|
|
|
REFERENTIAL_CONSTRAINTS
|
2005-05-06 19:06:10 +00:00
|
|
|
ROUTINES
|
2005-08-05 11:01:29 +02:00
|
|
|
SCHEMATA
|
2005-05-06 19:06:10 +00:00
|
|
|
SCHEMA_PRIVILEGES
|
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
mysql-test/r/information_schema.result:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Fixed test cases result (changes are due to the new tables added).
mysql-test/r/information_schema_db.result:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Fixed test cases result (changes are due to the new tables added).
mysql-test/r/status.result:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Fixed results for added testcases.
mysql-test/r/variables.result:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Fixed results for added test cases.
mysql-test/t/status.test:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Added test cases.
mysql-test/t/variables.test:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Added test cases.
sql/sql_show.cc:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Implementation of the new I_S tables.
Also, show_status_array(): argument 'ucase_names' is added (true means that
all variable names are to be converted to upper case).
sql/table.h:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Implementation of the new I_S tables.
2006-09-14 03:37:40 +04:00
|
|
|
SESSION_STATUS
|
|
|
|
SESSION_VARIABLES
|
2005-08-05 11:01:29 +02:00
|
|
|
STATISTICS
|
|
|
|
TABLES
|
2005-05-06 19:06:10 +00:00
|
|
|
TABLE_CONSTRAINTS
|
2005-08-05 11:01:29 +02:00
|
|
|
TABLE_PRIVILEGES
|
2005-07-19 20:06:49 +04:00
|
|
|
TRIGGERS
|
2005-08-05 11:01:29 +02:00
|
|
|
USER_PRIVILEGES
|
2006-01-28 19:44:51 -06:00
|
|
|
VIEWS
|
2005-05-06 19:06:10 +00:00
|
|
|
show tables from INFORMATION_SCHEMA like 'T%';
|
2005-05-24 14:35:23 +04:00
|
|
|
Tables_in_information_schema (T%)
|
2005-05-06 19:06:10 +00:00
|
|
|
TABLES
|
|
|
|
TABLE_CONSTRAINTS
|
2005-08-05 11:01:29 +02:00
|
|
|
TABLE_PRIVILEGES
|
2005-07-19 20:06:49 +04:00
|
|
|
TRIGGERS
|
2005-05-06 19:06:10 +00:00
|
|
|
create database `inf%`;
|
2006-05-30 10:45:23 +05:00
|
|
|
create database mbase;
|
2005-05-06 19:06:10 +00:00
|
|
|
use `inf%`;
|
|
|
|
show tables;
|
|
|
|
Tables_in_inf%
|
2006-03-20 13:42:02 +04:00
|
|
|
grant all privileges on `inf%`.* to 'mysqltest_1'@'localhost';
|
2006-05-30 10:45:23 +05:00
|
|
|
grant all privileges on `mbase`.* to 'mysqltest_1'@'localhost';
|
2006-03-20 13:42:02 +04:00
|
|
|
create table t1 (f1 int);
|
|
|
|
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|
|
|
|
|
create view v1 as select f1 from t1 where f1 = func1(f1);
|
2006-05-30 10:45:23 +05:00
|
|
|
create function func2() returns int return 1;
|
|
|
|
use mbase;
|
|
|
|
create procedure p1 ()
|
|
|
|
begin
|
|
|
|
select table_name from information_schema.key_column_usage
|
|
|
|
order by table_name;
|
|
|
|
end|
|
|
|
|
create table t1
|
|
|
|
(f1 int(10) unsigned not null,
|
|
|
|
f2 varchar(100) not null,
|
|
|
|
primary key (f1), unique key (f2));
|
2006-03-20 13:42:02 +04:00
|
|
|
select * from information_schema.tables;
|
2006-05-30 10:45:23 +05:00
|
|
|
call mbase.p1();
|
|
|
|
call mbase.p1();
|
|
|
|
call mbase.p1();
|
|
|
|
use `inf%`;
|
2006-03-20 13:42:02 +04:00
|
|
|
drop user mysqltest_1@localhost;
|
2006-05-30 10:45:23 +05:00
|
|
|
drop table t1;
|
|
|
|
select table_name, table_type, table_comment from information_schema.tables
|
|
|
|
where table_schema='inf%' and func2();
|
|
|
|
table_name table_type table_comment
|
|
|
|
v1 VIEW View 'inf%.v1' references invalid table(s) or column(s) or function(s) or define
|
|
|
|
select table_name, table_type, table_comment from information_schema.tables
|
|
|
|
where table_schema='inf%' and func2();
|
|
|
|
table_name table_type table_comment
|
|
|
|
v1 VIEW View 'inf%.v1' references invalid table(s) or column(s) or function(s) or define
|
2006-03-20 13:42:02 +04:00
|
|
|
drop view v1;
|
|
|
|
drop function func1;
|
2006-05-30 10:45:23 +05:00
|
|
|
drop function func2;
|
2005-05-06 19:06:10 +00:00
|
|
|
drop database `inf%`;
|
2006-05-30 10:45:23 +05:00
|
|
|
drop procedure mbase.p1;
|
|
|
|
drop database mbase;
|
|
|
|
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
|
|
|
|
where table_schema='test';
|
|
|
|
table_name table_type table_comment
|
|
|
|
t1 BASE TABLE
|
|
|
|
v1 VIEW VIEW
|
|
|
|
v2 VIEW View 'test.v2' references invalid table(s) or column(s) or function(s) or define
|
|
|
|
drop table t1;
|
|
|
|
select table_name, table_type, table_comment from information_schema.tables
|
|
|
|
where table_schema='test';
|
|
|
|
table_name table_type table_comment
|
|
|
|
v1 VIEW View 'test.v1' references invalid table(s) or column(s) or function(s) or define
|
|
|
|
v2 VIEW View 'test.v2' references invalid table(s) or column(s) or function(s) or define
|
|
|
|
drop function f1;
|
|
|
|
drop function f2;
|
|
|
|
drop view v1, v2;
|
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 17:23:25 +05: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;
|
|
|
|
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 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;
|
|
|
|
revoke insert(f1) on v3 from testdb_2@localhost;
|
|
|
|
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
|
|
|
|
show fields from v2;
|
|
|
|
Field Type Null Key Default Extra
|
|
|
|
f1 char(4) YES NULL
|
|
|
|
show fields from testdb_1.v1;
|
|
|
|
Field Type Null Key Default Extra
|
|
|
|
f1 char(4) YES NULL
|
|
|
|
show create view v2;
|
|
|
|
View Create View
|
|
|
|
v2 CREATE ALGORITHM=UNDEFINED DEFINER=`testdb_2`@`localhost` SQL SECURITY DEFINER VIEW `test`.`v2` AS select `v1`.`f1` AS `f1` from `testdb_1`.`v1`
|
|
|
|
show create view testdb_1.v1;
|
|
|
|
ERROR 42000: SHOW VIEW command denied to user 'testdb_2'@'localhost' for table 'v1'
|
|
|
|
select table_name from information_schema.columns a
|
|
|
|
where a.table_name = 'v2';
|
|
|
|
table_name
|
|
|
|
v2
|
|
|
|
select view_definition from information_schema.views a
|
|
|
|
where a.table_name = 'v2';
|
|
|
|
view_definition
|
|
|
|
/* ALGORITHM=UNDEFINED */ select `v1`.`f1` AS `f1` from `testdb_1`.`v1`
|
|
|
|
select view_definition from information_schema.views a
|
|
|
|
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;
|
|
|
|
drop database testdb_1;
|
|
|
|
drop user testdb_1@localhost;
|
2006-08-08 12:50:05 +05:00
|
|
|
drop user testdb_2@localhost;
|