2005-09-22 02:23:07 +02:00
DROP TABLE IF EXISTS t0,t1,t2,t3,t4,t5;
DROP VIEW IF EXISTS v1;
2005-01-24 16:44:54 +01:00
show variables where variable_name like "skip_show_database";
Variable_name Value
skip_show_database OFF
2005-03-05 12:35:32 +01:00
grant select, update, execute on test.* to mysqltest_2@localhost;
grant select, update on test.* to mysqltest_1@localhost;
2005-05-07 15:55:46 +02:00
create user mysqltest_3@localhost;
create user mysqltest_3;
2004-11-13 11:56:39 +01:00
select * from information_schema.SCHEMATA where schema_name > 'm';
2005-05-06 22:14:22 +02:00
CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME DEFAULT_COLLATION_NAME SQL_PATH
NULL mysql latin1 latin1_swedish_ci NULL
NULL test latin1 latin1_swedish_ci NULL
2004-11-13 11:56:39 +01:00
select schema_name from information_schema.schemata;
schema_name
2004-12-10 10:07:11 +01:00
information_schema
2006-01-12 19:51:02 +01:00
cluster_replication
2004-11-13 11:56:39 +01:00
mysql
test
show databases like 't%';
Database (t%)
test
show databases;
Database
2004-12-10 10:07:11 +01:00
information_schema
2006-01-12 19:51:02 +01:00
cluster_replication
2004-11-13 11:56:39 +01:00
mysql
test
2005-01-24 16:44:54 +01:00
show databases where `database` = 't%';
Database
2005-04-05 12:12:15 +02:00
create database mysqltest;
create table mysqltest.t1(a int, b VARCHAR(30), KEY string_data (b));
2004-11-13 11:56:39 +01:00
create table test.t2(a int);
create table t3(a int, KEY a_data (a));
2005-04-05 12:12:15 +02:00
create table mysqltest.t4(a int);
2005-08-08 15:46:06 +02:00
create table t5 (id int auto_increment primary key);
insert into t5 values (10);
2004-11-13 11:56:39 +01:00
create view v1 (c) as select table_name from information_schema.TABLES;
select * from v1;
c
2004-12-10 10:07:11 +01:00
CHARACTER_SETS
COLLATIONS
COLLATION_CHARACTER_SET_APPLICABILITY
2005-08-05 11:01:29 +02:00
COLUMNS
COLUMN_PRIVILEGES
2005-12-22 10:07:47 +01: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
2005-08-05 11:01:29 +02:00
KEY_COLUMN_USAGE
2006-01-10 16:44:04 +01:00
PARTITIONS
2005-12-21 19:18:40 +01:00
PLUGINS
2004-12-10 10:07:11 +01:00
ROUTINES
2005-08-05 11:01:29 +02:00
SCHEMATA
2004-12-10 10:07:11 +01:00
SCHEMA_PRIVILEGES
2005-08-05 11:01:29 +02:00
STATISTICS
TABLES
2004-12-10 10:07:11 +01:00
TABLE_CONSTRAINTS
2005-08-05 11:01:29 +02:00
TABLE_PRIVILEGES
2005-07-19 18:06:49 +02:00
TRIGGERS
2005-08-05 11:01:29 +02:00
VIEWS
USER_PRIVILEGES
2006-01-12 19:51:02 +01:00
binlog_index
2004-11-13 11:56:39 +01:00
columns_priv
db
2006-01-10 19:16:58 +01:00
event
2004-11-13 11:56:39 +01:00
func
2006-01-19 03:56:06 +01:00
general_log
2004-11-13 11:56:39 +01:00
help_category
help_keyword
help_relation
help_topic
host
2005-11-06 13:13:06 +01:00
plugin
2004-11-13 11:56:39 +01:00
proc
2004-12-23 11:46:24 +01:00
procs_priv
2006-01-19 03:56:06 +01:00
slow_log
2004-11-13 11:56:39 +01:00
tables_priv
time_zone
time_zone_leap_second
time_zone_name
time_zone_transition
time_zone_transition_type
user
2005-04-05 12:12:15 +02:00
t1
t4
2004-11-13 11:56:39 +01:00
t2
t3
2005-08-08 15:46:06 +02:00
t5
2004-11-13 11:56:39 +01:00
v1
select c,table_name from v1
2005-04-14 08:06:37 +02:00
inner join information_schema.TABLES v2 on (v1.c=v2.table_name)
where v1.c like "t%";
c table_name
TABLES TABLES
TABLE_CONSTRAINTS TABLE_CONSTRAINTS
2005-08-05 11:01:29 +02:00
TABLE_PRIVILEGES TABLE_PRIVILEGES
2005-07-19 18:06:49 +02:00
TRIGGERS TRIGGERS
2005-04-14 08:06:37 +02:00
tables_priv tables_priv
time_zone time_zone
time_zone_leap_second time_zone_leap_second
time_zone_name time_zone_name
time_zone_transition time_zone_transition
time_zone_transition_type time_zone_transition_type
t1 t1
t4 t4
t2 t2
t3 t3
2005-08-08 15:46:06 +02:00
t5 t5
2005-04-14 08:06:37 +02:00
select c,table_name from v1
2004-11-13 11:56:39 +01:00
left join information_schema.TABLES v2 on (v1.c=v2.table_name)
where v1.c like "t%";
c table_name
2004-12-10 10:07:11 +01:00
TABLES TABLES
TABLE_CONSTRAINTS TABLE_CONSTRAINTS
2005-08-05 11:01:29 +02:00
TABLE_PRIVILEGES TABLE_PRIVILEGES
2005-07-19 18:06:49 +02:00
TRIGGERS TRIGGERS
2004-11-13 11:56:39 +01:00
tables_priv tables_priv
time_zone time_zone
time_zone_leap_second time_zone_leap_second
time_zone_name time_zone_name
time_zone_transition time_zone_transition
time_zone_transition_type time_zone_transition_type
t1 t1
t4 t4
2005-04-05 12:12:15 +02:00
t2 t2
t3 t3
2005-08-08 15:46:06 +02:00
t5 t5
2004-11-13 11:56:39 +01:00
select c, v2.table_name from v1
right join information_schema.TABLES v2 on (v1.c=v2.table_name)
where v1.c like "t%";
c table_name
2004-12-10 10:07:11 +01:00
TABLES TABLES
TABLE_CONSTRAINTS TABLE_CONSTRAINTS
2005-08-05 11:01:29 +02:00
TABLE_PRIVILEGES TABLE_PRIVILEGES
2005-07-19 18:06:49 +02:00
TRIGGERS TRIGGERS
2004-11-13 11:56:39 +01:00
tables_priv tables_priv
time_zone time_zone
time_zone_leap_second time_zone_leap_second
time_zone_name time_zone_name
time_zone_transition time_zone_transition
time_zone_transition_type time_zone_transition_type
t1 t1
t4 t4
2005-04-05 12:12:15 +02:00
t2 t2
t3 t3
2005-08-08 15:46:06 +02:00
t5 t5
2004-11-13 11:56:39 +01:00
select table_name from information_schema.TABLES
2005-04-05 12:12:15 +02:00
where table_schema = "mysqltest" and table_name like "t%";
2004-11-13 11:56:39 +01:00
table_name
t1
t4
2005-04-05 12:12:15 +02:00
select * from information_schema.STATISTICS where TABLE_SCHEMA = "mysqltest";
2004-11-13 11:56:39 +01:00
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT
2005-04-05 12:12:15 +02:00
NULL mysqltest t1 1 mysqltest string_data 1 b A NULL NULL NULL YES BTREE
2005-01-24 16:44:54 +01:00
show keys from t3 where Key_name = "a_data";
2004-11-13 11:56:39 +01:00
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t3 1 a_data 1 a A NULL NULL NULL YES BTREE
show tables like 't%';
Tables_in_test (t%)
t2
t3
2005-08-08 15:46:06 +02:00
t5
2004-11-13 11:56:39 +01:00
show table status;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
2005-03-22 14:48:06 +01:00
t2 MyISAM 10 Fixed 0 0 0 # 1024 0 NULL # # NULL latin1_swedish_ci NULL
t3 MyISAM 10 Fixed 0 0 0 # 1024 0 NULL # # NULL latin1_swedish_ci NULL
2005-08-08 15:46:06 +02:00
t5 MyISAM 10 Fixed 1 7 7 # 2048 0 11 # # NULL latin1_swedish_ci NULL
2005-08-24 12:51:00 +02:00
v1 NULL NULL NULL NULL NULL NULL # NULL NULL NULL # # NULL NULL NULL NULL VIEW
2004-11-13 11:56:39 +01:00
show full columns from t3 like "a%";
Field Type Collation Null Key Default Extra Privileges Comment
a int(11) NULL YES MUL NULL select,insert,update,references
show full columns from mysql.db like "Insert%";
Field Type Collation Null Key Default Extra Privileges Comment
2005-02-18 03:07:14 +01:00
Insert_priv enum('N','Y') utf8_general_ci NO N select,insert,update,references
2004-11-13 11:56:39 +01:00
show full columns from v1;
Field Type Collation Null Key Default Extra Privileges Comment
2004-12-10 10:07:11 +01:00
c varchar(64) utf8_general_ci NO select,insert,update,references
2004-11-13 11:56:39 +01:00
select * from information_schema.COLUMNS where table_name="t1"
and column_name= "a";
2004-11-19 23:17:18 +01:00
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
2005-08-16 21:11:04 +02:00
NULL mysqltest t1 a 1 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
2005-04-05 12:12:15 +02:00
show columns from mysqltest.t1 where field like "%a%";
Field Type Null Key Default Extra
a int(11) YES NULL
2005-05-07 15:55:46 +02:00
create view mysqltest.v1 (c) as select a from mysqltest.t1;
2005-04-05 12:12:15 +02:00
grant select (a) on mysqltest.t1 to mysqltest_2@localhost;
2005-05-07 15:55:46 +02:00
grant select on mysqltest.v1 to mysqltest_3;
2005-04-05 12:12:15 +02:00
select table_name, column_name, privileges from information_schema.columns
where table_schema = 'mysqltest' and table_name = 't1';
table_name column_name privileges
t1 a select
show columns from mysqltest.t1;
2005-01-24 16:44:54 +01:00
Field Type Null Key Default Extra
a int(11) YES NULL
2005-04-05 12:12:15 +02:00
b varchar(30) YES MUL NULL
2005-05-07 15:55:46 +02:00
select table_name, column_name, privileges from information_schema.columns
where table_schema = 'mysqltest' and table_name = 'v1';
table_name column_name privileges
v1 c select
drop view v1, mysqltest.v1;
2005-08-08 15:46:06 +02:00
drop tables mysqltest.t4, mysqltest.t1, t2, t3, t5;
2005-04-05 12:12:15 +02:00
drop database mysqltest;
2004-11-13 11:56:39 +01:00
select * from information_schema.CHARACTER_SETS
where CHARACTER_SET_NAME like 'latin1%';
2004-12-14 14:18:59 +01:00
CHARACTER_SET_NAME DEFAULT_COLLATE_NAME DESCRIPTION MAXLEN
2005-07-21 15:43:55 +02:00
latin1 latin1_swedish_ci cp1252 West European 1
2004-11-13 11:56:39 +01:00
SHOW CHARACTER SET LIKE 'latin1%';
Charset Description Default collation Maxlen
2005-07-21 15:43:55 +02:00
latin1 cp1252 West European latin1_swedish_ci 1
2005-01-24 16:44:54 +01:00
SHOW CHARACTER SET WHERE charset like 'latin1%';
2004-11-13 11:56:39 +01:00
Charset Description Default collation Maxlen
2005-07-21 15:43:55 +02:00
latin1 cp1252 West European latin1_swedish_ci 1
2004-11-13 11:56:39 +01:00
select * from information_schema.COLLATIONS
where COLLATION_NAME like 'latin1%';
2004-12-23 11:35:34 +01:00
COLLATION_NAME CHARACTER_SET_NAME ID IS_DEFAULT IS_COMPILED SORTLEN
2004-11-13 11:56:39 +01:00
latin1_german1_ci latin1 5 0
latin1_swedish_ci latin1 8 Yes Yes 1
latin1_danish_ci latin1 15 0
latin1_german2_ci latin1 31 Yes 2
latin1_bin latin1 47 Yes 1
latin1_general_ci latin1 48 0
latin1_general_cs latin1 49 0
latin1_spanish_ci latin1 94 0
SHOW COLLATION LIKE 'latin1%';
Collation Charset Id Default Compiled Sortlen
latin1_german1_ci latin1 5 0
latin1_swedish_ci latin1 8 Yes Yes 1
latin1_danish_ci latin1 15 0
latin1_german2_ci latin1 31 Yes 2
latin1_bin latin1 47 Yes 1
latin1_general_ci latin1 48 0
latin1_general_cs latin1 49 0
latin1_spanish_ci latin1 94 0
2005-01-24 16:44:54 +01:00
SHOW COLLATION WHERE collation like 'latin1%';
2004-11-13 11:56:39 +01:00
Collation Charset Id Default Compiled Sortlen
latin1_german1_ci latin1 5 0
latin1_swedish_ci latin1 8 Yes Yes 1
latin1_danish_ci latin1 15 0
latin1_german2_ci latin1 31 Yes 2
latin1_bin latin1 47 Yes 1
latin1_general_ci latin1 48 0
latin1_general_cs latin1 49 0
latin1_spanish_ci latin1 94 0
select * from information_schema.COLLATION_CHARACTER_SET_APPLICABILITY
where COLLATION_NAME like 'latin1%';
COLLATION_NAME CHARACTER_SET_NAME
latin1_german1_ci latin1
latin1_swedish_ci latin1
latin1_danish_ci latin1
latin1_german2_ci latin1
latin1_bin latin1
latin1_general_ci latin1
latin1_general_cs latin1
latin1_spanish_ci latin1
2005-07-04 02:42:33 +02:00
drop procedure if exists sel2;
drop function if exists sub1;
drop function if exists sub2;
2004-11-13 11:56:39 +01:00
create function sub1(i int) returns int
return i+1;
create procedure sel2()
begin
select * from t1;
select * from t2;
end|
2004-12-14 12:55:28 +01:00
select parameter_style, sql_data_access, dtd_identifier
from information_schema.routines;
parameter_style sql_data_access dtd_identifier
SQL CONTAINS SQL NULL
2005-03-04 22:14:35 +01:00
SQL CONTAINS SQL int(11)
2004-11-13 11:56:39 +01:00
show procedure status;
Db Name Type Definer Modified Created Security_type Comment
test sel2 PROCEDURE root@localhost # # DEFINER
show function status;
Db Name Type Definer Modified Created Security_type Comment
test sub1 FUNCTION root@localhost # # DEFINER
select a.ROUTINE_NAME from information_schema.ROUTINES a,
information_schema.SCHEMATA b where
a.ROUTINE_SCHEMA = b.SCHEMA_NAME;
ROUTINE_NAME
sel2
sub1
explain select a.ROUTINE_NAME from information_schema.ROUTINES a,
information_schema.SCHEMATA b where
a.ROUTINE_SCHEMA = b.SCHEMA_NAME;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE # ALL NULL NULL NULL NULL 2
1 SIMPLE # ALL NULL NULL NULL NULL 2 Using where
select a.ROUTINE_NAME, b.name from information_schema.ROUTINES a,
2005-08-25 11:03:19 +02:00
mysql.proc b where a.ROUTINE_NAME = convert(b.name using utf8) order by 1;
2004-11-13 11:56:39 +01:00
ROUTINE_NAME name
sel2 sel2
2005-08-25 11:03:19 +02:00
sub1 sub1
2004-11-13 11:56:39 +01:00
select count(*) from information_schema.ROUTINES;
count(*)
2
2005-03-05 12:35:32 +01:00
select ROUTINE_NAME, ROUTINE_DEFINITION from information_schema.ROUTINES;
ROUTINE_NAME ROUTINE_DEFINITION
show create function sub1;
ERROR 42000: FUNCTION sub1 does not exist
select ROUTINE_NAME, ROUTINE_DEFINITION from information_schema.ROUTINES;
ROUTINE_NAME ROUTINE_DEFINITION
sel2
sub1
grant all privileges on test.* to mysqltest_1@localhost;
select ROUTINE_NAME, ROUTINE_DEFINITION from information_schema.ROUTINES;
ROUTINE_NAME ROUTINE_DEFINITION
sel2
sub1
create function sub2(i int) returns int
return i+1;
select ROUTINE_NAME, ROUTINE_DEFINITION from information_schema.ROUTINES;
ROUTINE_NAME ROUTINE_DEFINITION
sel2
sub1
sub2 return i+1
show create procedure sel2;
Procedure sql_mode Create Procedure
sel2
show create function sub1;
Function sql_mode Create Function
sub1
show create function sub2;
Function sql_mode Create Function
2005-08-27 12:29:36 +02:00
sub2 CREATE FUNCTION `sub2`(i int) RETURNS int(11)
2005-03-05 12:35:32 +01:00
return i+1
2005-07-19 10:49:43 +02:00
show function status like "sub2";
Db Name Type Definer Modified Created Security_type Comment
test sub2 FUNCTION mysqltest_1@localhost # # DEFINER
2005-03-05 12:35:32 +01:00
drop function sub2;
show create procedure sel2;
Procedure sql_mode Create Procedure
2005-08-27 12:29:36 +02:00
sel2 CREATE PROCEDURE `sel2`()
2005-03-05 12:35:32 +01:00
begin
select * from t1;
select * from t2;
end
2004-11-26 16:26:52 +01:00
create view v0 (c) as select schema_name from information_schema.schemata;
2004-11-13 11:56:39 +01:00
select * from v0;
c
2004-12-10 10:07:11 +01:00
information_schema
2006-01-12 19:51:02 +01:00
cluster_replication
2004-11-13 11:56:39 +01:00
mysql
test
explain select * from v0;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY # ALL NULL NULL NULL NULL 2
2004-11-26 16:26:52 +01:00
create view v1 (c) as select table_name from information_schema.tables
2004-11-13 11:56:39 +01:00
where table_name="v1";
select * from v1;
c
v1
2004-11-26 16:26:52 +01:00
create view v2 (c) as select column_name from information_schema.columns
2004-11-13 11:56:39 +01:00
where table_name="v2";
select * from v2;
c
c
2004-11-26 16:26:52 +01:00
create view v3 (c) as select CHARACTER_SET_NAME from information_schema.character_sets
2004-11-13 11:56:39 +01:00
where CHARACTER_SET_NAME like "latin1%";
select * from v3;
c
latin1
2004-11-26 16:26:52 +01:00
create view v4 (c) as select COLLATION_NAME from information_schema.collations
2004-11-13 11:56:39 +01:00
where COLLATION_NAME like "latin1%";
select * from v4;
c
latin1_german1_ci
latin1_swedish_ci
latin1_danish_ci
latin1_german2_ci
latin1_bin
latin1_general_ci
latin1_general_cs
latin1_spanish_ci
show keys from v4;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
2004-11-26 16:26:52 +01:00
select * from information_schema.views where TABLE_NAME like "v%";
2005-09-15 10:56:06 +02:00
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE
2005-09-16 08:15:45 +02:00
NULL test v0 select sql_no_cache `schemata`.`SCHEMA_NAME` AS `c` from `information_schema`.`schemata` NONE NO root@localhost DEFINER
NULL test v1 select sql_no_cache `tables`.`TABLE_NAME` AS `c` from `information_schema`.`tables` where (`tables`.`TABLE_NAME` = _utf8'v1') NONE NO root@localhost DEFINER
NULL test v2 select sql_no_cache `columns`.`COLUMN_NAME` AS `c` from `information_schema`.`columns` where (`columns`.`TABLE_NAME` = _utf8'v2') NONE NO root@localhost DEFINER
NULL test v3 select sql_no_cache `character_sets`.`CHARACTER_SET_NAME` AS `c` from `information_schema`.`character_sets` where (`character_sets`.`CHARACTER_SET_NAME` like _utf8'latin1%') NONE NO root@localhost DEFINER
NULL test v4 select sql_no_cache `collations`.`COLLATION_NAME` AS `c` from `information_schema`.`collations` where (`collations`.`COLLATION_NAME` like _utf8'latin1%') NONE NO root@localhost DEFINER
2004-11-13 11:56:39 +01:00
drop view v0, v1, v2, v3, v4;
create table t1 (a int);
grant select,update,insert on t1 to mysqltest_1@localhost;
grant select (a), update (a),insert(a), references(a) on t1 to mysqltest_1@localhost;
grant all on test.* to mysqltest_1@localhost with grant option;
select * from information_schema.USER_PRIVILEGES where grantee like '%mysqltest_1%';
GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE
'mysqltest_1'@'localhost' NULL USAGE NO
select * from information_schema.SCHEMA_PRIVILEGES where grantee like '%mysqltest_1%';
GRANTEE TABLE_CATALOG TABLE_SCHEMA PRIVILEGE_TYPE IS_GRANTABLE
'mysqltest_1'@'localhost' NULL test SELECT YES
'mysqltest_1'@'localhost' NULL test INSERT YES
'mysqltest_1'@'localhost' NULL test UPDATE YES
'mysqltest_1'@'localhost' NULL test DELETE YES
'mysqltest_1'@'localhost' NULL test CREATE YES
'mysqltest_1'@'localhost' NULL test DROP YES
'mysqltest_1'@'localhost' NULL test REFERENCES YES
'mysqltest_1'@'localhost' NULL test INDEX YES
'mysqltest_1'@'localhost' NULL test ALTER YES
'mysqltest_1'@'localhost' NULL test CREATE TEMPORARY TABLES YES
'mysqltest_1'@'localhost' NULL test LOCK TABLES YES
2004-12-23 11:46:24 +01:00
'mysqltest_1'@'localhost' NULL test EXECUTE YES
2004-11-13 11:56:39 +01:00
'mysqltest_1'@'localhost' NULL test CREATE VIEW YES
'mysqltest_1'@'localhost' NULL test SHOW VIEW YES
2004-12-23 11:46:24 +01:00
'mysqltest_1'@'localhost' NULL test CREATE ROUTINE YES
'mysqltest_1'@'localhost' NULL test ALTER ROUTINE YES
2006-01-10 19:16:58 +01:00
'mysqltest_1'@'localhost' NULL test EVENT YES
2004-11-13 11:56:39 +01:00
select * from information_schema.TABLE_PRIVILEGES where grantee like '%mysqltest_1%';
GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE
'mysqltest_1'@'localhost' NULL test t1 SELECT NO
'mysqltest_1'@'localhost' NULL test t1 INSERT NO
'mysqltest_1'@'localhost' NULL test t1 UPDATE NO
select * from information_schema.COLUMN_PRIVILEGES where grantee like '%mysqltest_1%';
GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME PRIVILEGE_TYPE IS_GRANTABLE
'mysqltest_1'@'localhost' NULL test t1 a SELECT NO
'mysqltest_1'@'localhost' NULL test t1 a INSERT NO
'mysqltest_1'@'localhost' NULL test t1 a UPDATE NO
'mysqltest_1'@'localhost' NULL test t1 a REFERENCES NO
2005-05-07 15:55:46 +02:00
delete from mysql.user where user like 'mysqltest%';
delete from mysql.db where user like 'mysqltest%';
delete from mysql.tables_priv where user like 'mysqltest%';
delete from mysql.columns_priv where user like 'mysqltest%';
2004-11-13 11:56:39 +01:00
flush privileges;
drop table t1;
create table t1 (a int null, primary key(a));
alter table t1 add constraint constraint_1 unique (a);
alter table t1 add constraint unique key_1(a);
alter table t1 add constraint constraint_2 unique key_2(a);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL default '0',
PRIMARY KEY (`a`),
UNIQUE KEY `constraint_1` (`a`),
UNIQUE KEY `key_1` (`a`),
UNIQUE KEY `key_2` (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select * from information_schema.TABLE_CONSTRAINTS where
TABLE_SCHEMA= "test";
2004-12-10 10:07:11 +01:00
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE
NULL test PRIMARY test t1 PRIMARY KEY
NULL test constraint_1 test t1 UNIQUE
NULL test key_1 test t1 UNIQUE
NULL test key_2 test t1 UNIQUE
2004-11-13 11:56:39 +01:00
select * from information_schema.KEY_COLUMN_USAGE where
TABLE_SCHEMA= "test";
2005-05-20 14:39:28 +02:00
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION POSITION_IN_UNIQUE_CONSTRAINT REFERENCED_TABLE_SCHEMA REFERENCED_TABLE_NAME REFERENCED_COLUMN_NAME
NULL test PRIMARY NULL test t1 a 1 NULL NULL NULL NULL
NULL test constraint_1 NULL test t1 a 1 NULL NULL NULL NULL
NULL test key_1 NULL test t1 a 1 NULL NULL NULL NULL
NULL test key_2 NULL test t1 a 1 NULL NULL NULL NULL
2004-11-13 11:56:39 +01:00
select table_name from information_schema.TABLES where table_schema like "test%";
table_name
t1
select table_name,column_name from information_schema.COLUMNS where table_schema like "test%";
table_name column_name
2004-11-24 17:32:10 +01:00
t1 a
2004-11-13 11:56:39 +01:00
select ROUTINE_NAME from information_schema.ROUTINES;
ROUTINE_NAME
sel2
sub1
delete from mysql.user where user='mysqltest_1';
drop table t1;
drop procedure sel2;
drop function sub1;
2004-11-15 17:20:45 +01:00
create table t1(a int);
create view v1 (c) as select a from t1 with check option;
create view v2 (c) as select a from t1 WITH LOCAL CHECK OPTION;
create view v3 (c) as select a from t1 WITH CASCADED CHECK OPTION;
select * from information_schema.views;
2005-09-15 10:56:06 +02:00
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE
2005-09-16 08:15:45 +02:00
NULL test v1 select `test`.`t1`.`a` AS `c` from `test`.`t1` CASCADED YES root@localhost DEFINER
NULL test v2 select `test`.`t1`.`a` AS `c` from `test`.`t1` LOCAL YES root@localhost DEFINER
NULL test v3 select `test`.`t1`.`a` AS `c` from `test`.`t1` CASCADED YES root@localhost DEFINER
2004-11-15 17:20:45 +01:00
grant select (a) on test.t1 to joe@localhost with grant option;
select * from INFORMATION_SCHEMA.COLUMN_PRIVILEGES;
GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME PRIVILEGE_TYPE IS_GRANTABLE
'joe'@'localhost' NULL test t1 a SELECT YES
select * from INFORMATION_SCHEMA.TABLE_PRIVILEGES;
GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE
drop view v1, v2, v3;
drop table t1;
delete from mysql.user where user='joe';
delete from mysql.db where user='joe';
delete from mysql.tables_priv where user='joe';
delete from mysql.columns_priv where user='joe';
flush privileges;
2004-11-17 16:48:12 +01:00
create table t1 (a int not null auto_increment,b int, primary key (a));
insert into t1 values (1,1),(NULL,3),(NULL,4);
select AUTO_INCREMENT from information_schema.tables where table_name = 't1';
AUTO_INCREMENT
4
drop table t1;
2004-11-18 10:16:06 +01:00
create table t1 (s1 int);
insert into t1 values (0),(9),(0);
select s1 from t1 where s1 in (select version from
information_schema.tables) union select version from
information_schema.tables;
s1
2004-12-07 14:47:00 +01:00
10
2004-11-18 10:16:06 +01:00
drop table t1;
2004-11-26 16:26:52 +01:00
SHOW CREATE TABLE INFORMATION_SCHEMA.character_sets;
2004-11-18 10:16:06 +01:00
Table Create Table
2005-05-31 10:15:23 +02:00
CHARACTER_SETS CREATE TEMPORARY TABLE `CHARACTER_SETS` (
2004-12-23 11:35:34 +01:00
`CHARACTER_SET_NAME` varchar(64) NOT NULL default '',
`DEFAULT_COLLATE_NAME` varchar(64) NOT NULL default '',
2004-12-14 14:18:59 +01:00
`DESCRIPTION` varchar(60) NOT NULL default '',
2004-11-19 23:17:18 +01:00
`MAXLEN` bigint(3) NOT NULL default '0'
2005-03-25 10:19:11 +01:00
) ENGINE=MEMORY DEFAULT CHARSET=utf8
2004-11-18 10:16:06 +01:00
set names latin2;
2004-11-26 16:26:52 +01:00
SHOW CREATE TABLE INFORMATION_SCHEMA.character_sets;
2004-11-18 10:16:06 +01:00
Table Create Table
2005-05-31 10:15:23 +02:00
CHARACTER_SETS CREATE TEMPORARY TABLE `CHARACTER_SETS` (
2004-12-23 11:35:34 +01:00
`CHARACTER_SET_NAME` varchar(64) NOT NULL default '',
`DEFAULT_COLLATE_NAME` varchar(64) NOT NULL default '',
2004-12-14 14:18:59 +01:00
`DESCRIPTION` varchar(60) NOT NULL default '',
2004-11-19 23:17:18 +01:00
`MAXLEN` bigint(3) NOT NULL default '0'
2005-03-25 10:19:11 +01:00
) ENGINE=MEMORY DEFAULT CHARSET=utf8
2004-11-18 10:16:06 +01:00
set names latin1;
create table t1 select * from information_schema.CHARACTER_SETS
where CHARACTER_SET_NAME like "latin1";
select * from t1;
2004-12-14 14:18:59 +01:00
CHARACTER_SET_NAME DEFAULT_COLLATE_NAME DESCRIPTION MAXLEN
2005-07-21 15:43:55 +02:00
latin1 latin1_swedish_ci cp1252 West European 1
2004-11-18 10:16:06 +01:00
alter table t1 default character set utf8;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
2004-12-23 11:35:34 +01:00
`CHARACTER_SET_NAME` varchar(64) NOT NULL default '',
`DEFAULT_COLLATE_NAME` varchar(64) NOT NULL default '',
2004-12-14 14:18:59 +01:00
`DESCRIPTION` varchar(60) NOT NULL default '',
2004-11-19 23:17:18 +01:00
`MAXLEN` bigint(3) NOT NULL default '0'
2004-11-18 10:16:06 +01:00
) ENGINE=MyISAM DEFAULT CHARSET=utf8
drop table t1;
2004-11-19 23:17:18 +01:00
create view v1 as select * from information_schema.TABLES;
drop view v1;
create table t1(a NUMERIC(5,3), b NUMERIC(5,1), c float(5,2),
d NUMERIC(6,4), e float, f DECIMAL(6,3), g int(11), h DOUBLE(10,3),
i DOUBLE);
select COLUMN_NAME,COLUMN_TYPE, CHARACTER_MAXIMUM_LENGTH,
CHARACTER_OCTET_LENGTH, NUMERIC_PRECISION, NUMERIC_SCALE
from information_schema.columns where table_name= 't1';
COLUMN_NAME COLUMN_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE
2005-03-31 10:44:42 +02:00
a decimal(5,3) NULL NULL 5 3
b decimal(5,1) NULL NULL 5 1
c float(5,2) NULL NULL 5 2
d decimal(6,4) NULL NULL 6 4
e float NULL NULL 12 NULL
f decimal(6,3) NULL NULL 6 3
2005-08-16 21:11:04 +02:00
g int(11) NULL NULL 10 0
2005-03-31 10:44:42 +02:00
h double(10,3) NULL NULL 10 3
i double NULL NULL 22 NULL
2004-11-19 23:17:18 +01:00
drop table t1;
2004-11-23 15:41:39 +01:00
create table t115 as select table_name, column_name, column_type
from information_schema.columns where table_name = 'proc';
select * from t115;
table_name column_name column_type
2004-12-07 14:47:00 +01:00
proc db char(64)
proc name char(64)
2004-11-23 15:41:39 +01:00
proc type enum('FUNCTION','PROCEDURE')
2004-12-07 14:47:00 +01:00
proc specific_name char(64)
2004-11-23 15:41:39 +01:00
proc language enum('SQL')
proc sql_data_access enum('CONTAINS_SQL','NO_SQL','READS_SQL_DATA','MODIFIES_SQL_DATA')
proc is_deterministic enum('YES','NO')
proc security_type enum('INVOKER','DEFINER')
proc param_list blob
2004-12-07 14:47:00 +01:00
proc returns char(64)
2005-08-03 03:27:05 +02:00
proc body longblob
2004-12-07 14:47:00 +01:00
proc definer char(77)
2004-11-23 15:41:39 +01:00
proc created timestamp
proc modified timestamp
2005-03-12 00:06:03 +01:00
proc sql_mode set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE')
2004-12-07 14:47:00 +01:00
proc comment char(64)
2004-11-23 15:41:39 +01:00
drop table t115;
create procedure p108 () begin declare c cursor for select data_type
from information_schema.columns; open c; open c; end;//
call p108()//
ERROR 24000: Cursor is already open
drop procedure p108;
2004-11-26 16:26:52 +01:00
create view v1 as select A1.table_name from information_schema.TABLES A1
where table_name= "user";
select * from v1;
table_name
user
drop view v1;
create view vo as select 'a' union select 'a';
show index from vo;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
select * from information_schema.TABLE_CONSTRAINTS where
TABLE_NAME= "vo";
2004-12-10 10:07:11 +01:00
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE
2004-11-26 16:26:52 +01:00
select * from information_schema.KEY_COLUMN_USAGE where
TABLE_NAME= "vo";
2005-05-20 14:39:28 +02:00
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION POSITION_IN_UNIQUE_CONSTRAINT REFERENCED_TABLE_SCHEMA REFERENCED_TABLE_NAME REFERENCED_COLUMN_NAME
2004-11-26 16:26:52 +01:00
drop view vo;
2004-12-10 10:07:11 +01:00
select TABLE_NAME,TABLE_TYPE,ENGINE
from information_schema.tables
where table_schema='information_schema' limit 2;
TABLE_NAME TABLE_TYPE ENGINE
2005-08-19 20:40:39 +02:00
CHARACTER_SETS SYSTEM VIEW MEMORY
COLLATIONS SYSTEM VIEW MEMORY
2005-01-27 11:16:51 +01:00
show tables from information_schema like "T%";
Tables_in_information_schema (T%)
TABLES
TABLE_CONSTRAINTS
2005-08-05 11:01:29 +02:00
TABLE_PRIVILEGES
2005-07-19 18:06:49 +02:00
TRIGGERS
2004-12-10 10:07:11 +01:00
create database information_schema;
2005-09-13 13:07:38 +02:00
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
2004-12-10 10:07:11 +01:00
use information_schema;
show full tables like "T%";
Tables_in_information_schema (T%) Table_type
2005-08-08 21:59:04 +02:00
TABLES SYSTEM VIEW
TABLE_CONSTRAINTS SYSTEM VIEW
2005-08-19 20:40:39 +02:00
TABLE_PRIVILEGES SYSTEM VIEW
2005-08-08 21:59:04 +02:00
TRIGGERS SYSTEM VIEW
2004-12-10 10:07:11 +01:00
create table t1(a int);
ERROR 42S02: Unknown table 't1' in information_schema
use test;
show tables;
Tables_in_test
use information_schema;
show tables like "T%";
Tables_in_information_schema (T%)
TABLES
TABLE_CONSTRAINTS
2005-08-05 11:01:29 +02:00
TABLE_PRIVILEGES
2005-07-19 18:06:49 +02:00
TRIGGERS
2004-12-18 10:48:01 +01:00
select table_name from tables where table_name='user';
table_name
user
select column_name, privileges from columns
where table_name='user' and column_name like '%o%';
column_name privileges
Host select,insert,update,references
Password select,insert,update,references
Drop_priv select,insert,update,references
Reload_priv select,insert,update,references
Shutdown_priv select,insert,update,references
Process_priv select,insert,update,references
Show_db_priv select,insert,update,references
Lock_tables_priv select,insert,update,references
Show_view_priv select,insert,update,references
2004-12-23 11:46:24 +01:00
Create_routine_priv select,insert,update,references
Alter_routine_priv select,insert,update,references
2004-12-18 10:48:01 +01:00
max_questions select,insert,update,references
max_connections select,insert,update,references
2004-12-29 21:39:44 +01:00
max_user_connections select,insert,update,references
2004-12-16 14:31:36 +01:00
use test;
create function sub1(i int) returns int
return i+1;
create table t1(f1 int);
2005-09-22 02:23:07 +02:00
create view v2 (c) as select f1 from t1;
create view v3 (c) as select sub1(1);
2004-12-16 14:31:36 +01:00
create table t4(f1 int, KEY f1_key (f1));
drop table t1;
drop function sub1;
2004-12-16 15:44:36 +01:00
select table_name from information_schema.views
where table_schema='test';
table_name
2005-11-11 10:39:46 +01:00
v2
v3
2004-12-16 15:44:36 +01:00
Warnings:
2005-10-27 23:18:23 +02:00
Warning 1356 View 'test.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
Warning 1356 View 'test.v3' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
2004-12-16 15:44:36 +01:00
select table_name from information_schema.views
where table_schema='test';
table_name
2005-11-11 10:39:46 +01:00
v2
v3
2004-12-16 15:44:36 +01:00
Warnings:
2005-10-27 23:18:23 +02:00
Warning 1356 View 'test.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
Warning 1356 View 'test.v3' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
2004-12-16 14:31:36 +01:00
select column_name from information_schema.columns
where table_schema='test';
column_name
f1
Warnings:
2005-10-27 23:18:23 +02:00
Warning 1356 View 'test.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
Warning 1356 View 'test.v3' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
2004-12-16 14:31:36 +01:00
select index_name from information_schema.statistics where table_schema='test';
index_name
f1_key
select constraint_name from information_schema.table_constraints
where table_schema='test';
constraint_name
2005-11-11 10:39:46 +01:00
show create view v2;
View Create View
v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `test`.`t1`.`f1` AS `c` from `t1`
Warnings:
Warning 1356 View 'test.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
show create table v3;
View Create View
v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select sql_no_cache `test`.`sub1`(1) AS `c`
Warnings:
Warning 1356 View 'test.v3' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
2005-09-22 02:23:07 +02:00
drop view v2;
drop view v3;
2004-12-16 14:31:36 +01:00
drop table t4;
2004-12-18 11:49:13 +01:00
select * from information_schema.table_names;
ERROR 42S02: Unknown table 'table_names' in information_schema
2004-12-23 11:35:34 +01:00
select column_type from information_schema.columns
where table_schema="information_schema" and table_name="COLUMNS" and
(column_name="character_set_name" or column_name="collation_name");
column_type
varchar(64)
varchar(64)
2004-12-24 10:16:47 +01:00
select TABLE_ROWS from information_schema.tables where
table_schema="information_schema" and table_name="COLUMNS";
TABLE_ROWS
NULL
select table_type from information_schema.tables
where table_schema="mysql" and table_name="user";
table_type
BASE TABLE
wl#1629 SHOW with WHERE(final part, after review)
added syntax:
'show variables where', 'show status where', 'show open tables where'
mysql-test/r/grant_cache.result:
wl#1629 SHOW with WHERE(final part,after review)
mysql-test/r/information_schema.result:
wl#1629 SHOW with WHERE(final part,after review)
mysql-test/r/query_cache.result:
wl#1629 SHOW with WHERE(final part,after review)
mysql-test/r/temp_table.result:
wl#1629 SHOW with WHERE(final part,after review)
mysql-test/r/union.result:
wl#1629 SHOW with WHERE(final part,after review)
mysql-test/t/information_schema.test:
wl#1629 SHOW with WHERE(final part,after review)
mysql-test/t/query_cache.test:
wl#1629 SHOW with WHERE(final part,after review)
sql/item.cc:
wl#1629 SHOW with WHERE(final part,after review)
sql/mysql_priv.h:
wl#1629 SHOW with WHERE(final part,after review)
sql/sql_parse.cc:
wl#1629 SHOW with WHERE(final part,after review)
sql/sql_select.cc:
wl#1629 SHOW with WHERE(final part,after review)
sql/sql_show.cc:
wl#1629 SHOW with WHERE(final part,after review)
sql/sql_yacc.yy:
wl#1629 SHOW with WHERE(final part,after review)
sql/table.h:
wl#1629 SHOW with WHERE(final part,after review)
2004-12-30 13:20:40 +01:00
show open tables where `table` like "user";
Database Table In_use Name_locked
mysql user 0 0
2005-01-24 16:44:54 +01:00
show status where variable_name like "%database%";
Variable_name Value
2005-07-13 10:30:39 +02:00
Com_show_databases 3
2005-01-24 16:44:54 +01:00
show variables where variable_name like "skip_show_databas";
Variable_name Value
2005-01-18 15:37:45 +01:00
show global status like "Threads_running";
Variable_name Value
2005-08-03 01:50:10 +02:00
Threads_running #
2005-02-16 11:00:03 +01:00
create table t1(f1 int);
create table t2(f2 int);
create view v1 as select * from t1, t2;
set @got_val= (select count(*) from information_schema.columns);
drop view v1;
drop table t1, t2;
2005-02-22 12:42:44 +01:00
CREATE TABLE t_crashme ( f1 BIGINT);
CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
2005-03-24 14:32:11 +01:00
count(*)
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
110
2005-02-22 12:42:44 +01:00
drop view a2, a1;
drop table t_crashme;
2005-02-23 13:15:36 +01:00
select table_schema,table_name, column_name from
information_schema.columns
where data_type = 'longtext';
table_schema table_name column_name
information_schema COLUMNS COLUMN_TYPE
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
information_schema EVENTS EVENT_BODY
information_schema EVENTS SQL_MODE
2006-01-10 16:44:04 +01:00
information_schema PARTITIONS PARTITION_EXPRESSION
information_schema PARTITIONS SUBPARTITION_EXPRESSION
information_schema PARTITIONS PARTITION_DESCRIPTION
2005-12-21 19:18:40 +01:00
information_schema PLUGINS PLUGIN_DESCRIPTION
2005-02-23 13:15:36 +01:00
information_schema ROUTINES ROUTINE_DEFINITION
information_schema ROUTINES SQL_MODE
2005-07-19 18:06:49 +02:00
information_schema TRIGGERS ACTION_CONDITION
information_schema TRIGGERS ACTION_STATEMENT
2005-07-28 21:39:11 +02:00
information_schema TRIGGERS SQL_MODE
2005-11-10 20:25:03 +01:00
information_schema TRIGGERS DEFINER
2005-08-05 11:01:29 +02:00
information_schema VIEWS VIEW_DEFINITION
2005-02-23 13:15:36 +01:00
select table_name, column_name, data_type from information_schema.columns
where data_type = 'datetime';
table_name column_name data_type
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 EXECUTE_AT datetime
EVENTS STARTS datetime
EVENTS ENDS datetime
EVENTS CREATED datetime
EVENTS LAST_ALTERED datetime
EVENTS LAST_EXECUTED datetime
2006-01-10 16:44:04 +01:00
PARTITIONS CREATE_TIME datetime
PARTITIONS UPDATE_TIME datetime
PARTITIONS CHECK_TIME datetime
2005-08-05 11:01:29 +02:00
ROUTINES CREATED datetime
ROUTINES LAST_ALTERED datetime
2005-02-23 13:15:36 +01:00
TABLES CREATE_TIME datetime
TABLES UPDATE_TIME datetime
TABLES CHECK_TIME datetime
2005-07-19 18:06:49 +02:00
TRIGGERS CREATED datetime
2006-01-10 19:16:58 +01:00
event execute_at datetime
event last_executed datetime
event starts datetime
event ends datetime
2005-03-03 17:20:16 +01:00
SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES A
WHERE NOT EXISTS
(SELECT * FROM INFORMATION_SCHEMA.COLUMNS B
WHERE A.TABLE_SCHEMA = B.TABLE_SCHEMA
AND A.TABLE_NAME = B.TABLE_NAME);
COUNT(*)
0
2005-03-31 10:44:42 +02:00
create table t1
( x_bigint BIGINT,
x_integer INTEGER,
x_smallint SMALLINT,
x_decimal DECIMAL(5,3),
x_numeric NUMERIC(5,3),
x_real REAL,
x_float FLOAT,
x_double_precision DOUBLE PRECISION );
SELECT COLUMN_NAME, CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME= 't1';
COLUMN_NAME CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH
x_bigint NULL NULL
x_integer NULL NULL
x_smallint NULL NULL
x_decimal NULL NULL
x_numeric NULL NULL
x_real NULL NULL
x_float NULL NULL
x_double_precision NULL NULL
drop table t1;
2005-06-18 03:02:27 +02:00
grant select on test.* to mysqltest_4@localhost;
2005-05-07 17:14:34 +02:00
SELECT TABLE_NAME, COLUMN_NAME, PRIVILEGES FROM INFORMATION_SCHEMA.COLUMNS
where COLUMN_NAME='TABLE_NAME';
TABLE_NAME COLUMN_NAME PRIVILEGES
COLUMNS TABLE_NAME select
COLUMN_PRIVILEGES TABLE_NAME select
KEY_COLUMN_USAGE TABLE_NAME select
2006-01-10 16:44:04 +01:00
PARTITIONS TABLE_NAME select
2005-08-05 11:01:29 +02:00
STATISTICS TABLE_NAME select
TABLES TABLE_NAME select
TABLE_CONSTRAINTS TABLE_NAME select
TABLE_PRIVILEGES TABLE_NAME select
VIEWS TABLE_NAME select
2005-05-07 17:14:34 +02:00
delete from mysql.user where user='mysqltest_4';
2005-06-18 03:02:27 +02:00
delete from mysql.db where user='mysqltest_4';
2005-05-07 17:14:34 +02:00
flush privileges;
2005-05-09 18:22:49 +02:00
SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
2005-05-09 20:18:59 +02:00
table_schema count(*)
2006-01-12 19:51:02 +01:00
cluster_replication 1
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
information_schema 20
2006-01-19 03:56:06 +01:00
mysql 21
2005-07-19 18:06:49 +02:00
create table t1 (i int, j int);
create trigger trg1 before insert on t1 for each row
begin
if new.j > 10 then
set new.j := 10;
end if;
end|
create trigger trg2 before update on t1 for each row
begin
if old.i % 2 = 0 then
set new.j := -1;
end if;
end|
create trigger trg3 after update on t1 for each row
begin
if new.j = -1 then
set @fired:= "Yes";
end if;
end|
show triggers;
2005-11-10 20:25:03 +01:00
Trigger Event Table Statement Timing Created sql_mode Definer
2006-01-12 01:02:52 +01:00
trg1 INSERT t1 begin
2005-07-19 18:06:49 +02:00
if new.j > 10 then
set new.j := 10;
end if;
2005-11-10 20:25:03 +01:00
end BEFORE NULL root@localhost
2006-01-12 01:02:52 +01:00
trg2 UPDATE t1 begin
2005-07-19 18:06:49 +02:00
if old.i % 2 = 0 then
set new.j := -1;
end if;
2005-11-10 20:25:03 +01:00
end BEFORE NULL root@localhost
2006-01-12 01:02:52 +01:00
trg3 UPDATE t1 begin
2005-07-19 18:06:49 +02:00
if new.j = -1 then
set @fired:= "Yes";
end if;
2005-11-10 20:25:03 +01:00
end AFTER NULL root@localhost
2005-07-19 18:06:49 +02:00
select * from information_schema.triggers;
2005-11-10 20:25:03 +01:00
TRIGGER_CATALOG TRIGGER_SCHEMA TRIGGER_NAME EVENT_MANIPULATION EVENT_OBJECT_CATALOG EVENT_OBJECT_SCHEMA EVENT_OBJECT_TABLE ACTION_ORDER ACTION_CONDITION ACTION_STATEMENT ACTION_ORIENTATION ACTION_TIMING ACTION_REFERENCE_OLD_TABLE ACTION_REFERENCE_NEW_TABLE ACTION_REFERENCE_OLD_ROW ACTION_REFERENCE_NEW_ROW CREATED SQL_MODE DEFINER
2006-01-12 01:02:52 +01:00
NULL test trg1 INSERT NULL test t1 0 NULL begin
2005-07-19 18:06:49 +02:00
if new.j > 10 then
set new.j := 10;
end if;
2005-11-10 20:25:03 +01:00
end ROW BEFORE NULL NULL OLD NEW NULL root@localhost
2006-01-12 01:02:52 +01:00
NULL test trg2 UPDATE NULL test t1 0 NULL begin
2005-07-19 18:06:49 +02:00
if old.i % 2 = 0 then
set new.j := -1;
end if;
2005-11-10 20:25:03 +01:00
end ROW BEFORE NULL NULL OLD NEW NULL root@localhost
2006-01-12 01:02:52 +01:00
NULL test trg3 UPDATE NULL test t1 0 NULL begin
2005-07-19 18:06:49 +02:00
if new.j = -1 then
set @fired:= "Yes";
end if;
2005-11-10 20:25:03 +01:00
end ROW AFTER NULL NULL OLD NEW NULL root@localhost
2005-07-19 18:06:49 +02:00
drop trigger trg1;
drop trigger trg2;
drop trigger trg3;
drop table t1;
2005-06-02 12:33:53 +02:00
create database mysqltest;
create table mysqltest.t1 (f1 int, f2 int);
create table mysqltest.t2 (f1 int);
grant select (f1) on mysqltest.t1 to user1@localhost;
grant select on mysqltest.t2 to user2@localhost;
grant select on mysqltest.* to user3@localhost;
grant select on *.* to user4@localhost;
select * from information_schema.column_privileges;
GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME PRIVILEGE_TYPE IS_GRANTABLE
'user1'@'localhost' NULL mysqltest t1 f1 SELECT NO
select * from information_schema.table_privileges;
GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE
select * from information_schema.schema_privileges;
GRANTEE TABLE_CATALOG TABLE_SCHEMA PRIVILEGE_TYPE IS_GRANTABLE
select * from information_schema.user_privileges;
GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE
'user1'@'localhost' NULL USAGE NO
show grants;
Grants for user1@localhost
GRANT USAGE ON *.* TO 'user1'@'localhost'
GRANT SELECT (f1) ON `mysqltest`.`t1` TO 'user1'@'localhost'
select * from information_schema.column_privileges;
GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME PRIVILEGE_TYPE IS_GRANTABLE
select * from information_schema.table_privileges;
GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE
'user2'@'localhost' NULL mysqltest t2 SELECT NO
select * from information_schema.schema_privileges;
GRANTEE TABLE_CATALOG TABLE_SCHEMA PRIVILEGE_TYPE IS_GRANTABLE
select * from information_schema.user_privileges;
GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE
'user2'@'localhost' NULL USAGE NO
show grants;
Grants for user2@localhost
GRANT USAGE ON *.* TO 'user2'@'localhost'
GRANT SELECT ON `mysqltest`.`t2` TO 'user2'@'localhost'
select * from information_schema.column_privileges;
GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME PRIVILEGE_TYPE IS_GRANTABLE
select * from information_schema.table_privileges;
GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE
select * from information_schema.schema_privileges;
GRANTEE TABLE_CATALOG TABLE_SCHEMA PRIVILEGE_TYPE IS_GRANTABLE
'user3'@'localhost' NULL mysqltest SELECT NO
select * from information_schema.user_privileges;
GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE
'user3'@'localhost' NULL USAGE NO
show grants;
Grants for user3@localhost
GRANT USAGE ON *.* TO 'user3'@'localhost'
GRANT SELECT ON `mysqltest`.* TO 'user3'@'localhost'
select * from information_schema.column_privileges where grantee like '%user%';
GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME PRIVILEGE_TYPE IS_GRANTABLE
'user1'@'localhost' NULL mysqltest t1 f1 SELECT NO
select * from information_schema.table_privileges where grantee like '%user%';
GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE
'user2'@'localhost' NULL mysqltest t2 SELECT NO
select * from information_schema.schema_privileges where grantee like '%user%';
GRANTEE TABLE_CATALOG TABLE_SCHEMA PRIVILEGE_TYPE IS_GRANTABLE
'user3'@'localhost' NULL mysqltest SELECT NO
select * from information_schema.user_privileges where grantee like '%user%';
GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE
'user1'@'localhost' NULL USAGE NO
'user2'@'localhost' NULL USAGE NO
'user3'@'localhost' NULL USAGE NO
'user4'@'localhost' NULL SELECT NO
show grants;
Grants for user4@localhost
GRANT SELECT ON *.* TO 'user4'@'localhost'
drop user user1@localhost, user2@localhost, user3@localhost, user4@localhost;
use test;
drop database mysqltest;
2005-07-04 02:42:33 +02:00
drop procedure if exists p1;
drop procedure if exists p2;
2005-06-16 09:12:47 +02:00
create procedure p1 () modifies sql data set @a = 5;
create procedure p2 () set @a = 5;
select sql_data_access from information_schema.routines
where specific_name like 'p%';
sql_data_access
MODIFIES SQL DATA
CONTAINS SQL
drop procedure p1;
drop procedure p2;
2005-06-16 10:27:22 +02:00
show create database information_schema;
Database Create Database
information_schema CREATE DATABASE `information_schema` /*!40100 DEFAULT CHARACTER SET utf8 */
2005-07-19 11:30:32 +02:00
create table t1(f1 LONGBLOB, f2 LONGTEXT);
select column_name,data_type,CHARACTER_OCTET_LENGTH,
CHARACTER_MAXIMUM_LENGTH
from information_schema.columns
where table_name='t1';
column_name data_type CHARACTER_OCTET_LENGTH CHARACTER_MAXIMUM_LENGTH
f1 longblob 4294967295 4294967295
f2 longtext 4294967295 4294967295
drop table t1;
create table t1(f1 tinyint, f2 SMALLINT, f3 mediumint, f4 int,
f5 BIGINT, f6 BIT, f7 bit(64));
select column_name, NUMERIC_PRECISION, NUMERIC_SCALE
from information_schema.columns
where table_name='t1';
column_name NUMERIC_PRECISION NUMERIC_SCALE
2005-08-16 21:11:04 +02:00
f1 3 0
f2 5 0
f3 7 0
f4 10 0
f5 19 0
2005-07-19 11:30:32 +02:00
f6 1 NULL
f7 64 NULL
drop table t1;
2005-07-27 13:17:05 +02:00
create table t1 (f1 integer);
create trigger tr1 after insert on t1 for each row set @test_var=42;
use information_schema;
select trigger_schema, trigger_name from triggers where
trigger_name='tr1';
trigger_schema trigger_name
test tr1
use test;
drop table t1;
2005-08-15 18:14:55 +02:00
create table t1 (a int not null, b int);
use information_schema;
select column_name, column_default from columns
where table_schema='test' and table_name='t1';
column_name column_default
a NULL
b NULL
use test;
2005-08-20 10:00:00 +02:00
show columns from t1;
Field Type Null Key Default Extra
a int(11) NO
b int(11) YES NULL
2005-08-15 18:14:55 +02:00
drop table t1;
2005-08-23 02:32:02 +02:00
CREATE TABLE t1 (a int);
CREATE TABLE t2 (b int);
SHOW TABLE STATUS FROM test
WHERE name IN ( SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA='test' AND TABLE_TYPE='BASE TABLE');
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 MyISAM 10 Fixed 0 0 0 # 1024 0 NULL # # NULL latin1_swedish_ci NULL
t2 MyISAM 10 Fixed 0 0 0 # 1024 0 NULL # # NULL latin1_swedish_ci NULL
2005-09-07 13:11:53 +02:00
DROP TABLE t1,t2;
create table t1(f1 int);
create view v1 (c) as select f1 from t1;
select database();
database()
NULL
show fields from test.v1;
Field Type Null Key Default Extra
c int(11) YES NULL
drop view v1;
drop table t1;
2005-09-13 13:07:38 +02:00
alter database information_schema;
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
drop database information_schema;
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
drop table information_schema.tables;
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
alter table information_schema.tables;
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
use information_schema;
create temporary table schemata(f1 char(10));
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
CREATE PROCEDURE p1 ()
BEGIN
SELECT 'foo' FROM DUAL;
END |
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
select ROUTINE_NAME from routines;
ROUTINE_NAME
grant all on information_schema.* to 'user1'@'localhost';
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
grant select on information_schema.* to 'user1'@'localhost';
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
2005-10-21 10:14:54 +02:00
use test;
create table t1(id int);
insert into t1(id) values (1);
select 1 from (select 1 from test.t1) a;
1
1
use information_schema;
select 1 from (select 1 from test.t1) a;
1
1
use test;
drop table t1;
2005-10-25 14:22:58 +02:00
create table t1(a blob, b text charset utf8, c text charset ucs2);
select data_type, character_octet_length, character_maximum_length
from information_schema.columns where table_name='t1';
data_type character_octet_length character_maximum_length
blob 65535 65535
text 65535 65535
text 65535 32767
drop table t1;
2005-12-01 08:00:33 +01:00
create table t1 (f1 int(11));
create view v1 as select * from t1;
drop table t1;
select table_type from information_schema.tables
where table_name="v1";
table_type
VIEW
drop view v1;
2005-12-19 11:46:54 +01:00
create temporary table t1(f1 int, index(f1));
show columns from t1;
Field Type Null Key Default Extra
f1 int(11) YES MUL NULL
describe t1;
Field Type Null Key Default Extra
f1 int(11) YES MUL NULL
show indexes from t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t1 1 f1 1 f1 A NULL NULL NULL YES BTREE
drop table t1;
2005-12-19 13:21:02 +01:00
create table t1(f1 binary(32), f2 varbinary(64));
select character_maximum_length, character_octet_length
from information_schema.columns where table_name='t1';
character_maximum_length character_octet_length
32 32
64 64
drop table t1;
2006-01-03 11:25:19 +01:00
CREATE TABLE t1 (f1 BIGINT, f2 VARCHAR(20), f3 BIGINT);
INSERT INTO t1 SET f1 = 1, f2 = 'Schoenenbourg', f3 = 1;
CREATE FUNCTION func2() RETURNS BIGINT RETURN 1;
CREATE FUNCTION func1() RETURNS BIGINT
BEGIN
RETURN ( SELECT COUNT(*) FROM INFORMATION_SCHEMA.VIEWS);
END//
CREATE VIEW v1 AS SELECT 1 FROM t1
WHERE f3 = (SELECT func2 ());
SELECT func1();
func1()
1
DROP TABLE t1;
DROP VIEW v1;
DROP FUNCTION func1;
DROP FUNCTION func2;
2005-12-22 10:07:47 +01:00
select * from information_schema.engines WHERE ENGINE="MyISAM";
ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS
MyISAM ENABLED Default engine as of MySQL 3.23 with great performance NO NO NO