2005-05-09 18:22:49 +02:00
# This test uses grants, which can't get tested for embedded server
2005-04-04 21:43:58 +02:00
-- source include/not_embedded.inc
2004-11-13 11:56:39 +01:00
2006-04-30 22:27:38 +02:00
# check that CSV engine was compiled in, as the result of the test depends
# on the presence of the log tables (which are CSV-based).
2006-01-19 03:56:06 +01:00
--source include/have_csv.inc
2009-02-09 22:00:15 +01:00
# Save the initial number of concurrent sessions
--source include/count_sessions.inc
2004-11-13 11:56:39 +01:00
# Test for information_schema.schemata &
# show databases
2005-06-01 15:35:09 +02:00
--disable_warnings
2005-09-22 02:23:07 +02:00
DROP TABLE IF EXISTS t0,t1,t2,t3,t4,t5;
DROP VIEW IF EXISTS v1;
2005-06-01 15:35:09 +02:00
--enable_warnings
2005-01-24 16:44:54 +01:00
show variables where variable_name like "skip_show_database";
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';
select schema_name from information_schema.schemata;
show databases like 't%';
show databases;
2005-01-24 16:44:54 +01:00
show databases where `database` = 't%';
2004-11-13 11:56:39 +01:00
# Test for information_schema.tables &
# show tables
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);
2008-04-08 16:51:26 +02:00
create view v1 (c) as
SELECT table_name FROM information_schema.TABLES
WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test', 'mysqltest') AND
table_name<>'ndb_binlog_index' AND
table_name<>'ndb_apply_status';
2004-11-13 11:56:39 +01:00
select * from v1;
2005-04-14 08:06:37 +02:00
2009-02-05 21:47:23 +01:00
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%";
2009-02-05 21:47:23 +01: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%";
select c, v2.table_name from v1
right join information_schema.TABLES v2 on (v1.c=v2.table_name)
where v1.c like "t%";
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
2005-04-05 12:12:15 +02:00
select * from information_schema.STATISTICS where TABLE_SCHEMA = "mysqltest";
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
show tables like 't%';
2005-03-15 18:54:44 +01:00
--replace_column 8 # 12 # 13 #
2004-11-13 11:56:39 +01:00
show table status;
show full columns from t3 like "a%";
show full columns from mysql.db like "Insert%";
show full columns from v1;
select * from information_schema.COLUMNS where table_name="t1"
and column_name= "a";
2005-04-05 12:12:15 +02:00
show columns from mysqltest.t1 where field like "%a%";
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
connect (user3,localhost,mysqltest_2,,);
connection user3;
2009-02-05 21:47:23 +01:00
select table_name, column_name, privileges from information_schema.columns
2005-04-05 12:12:15 +02:00
where table_schema = 'mysqltest' and table_name = 't1';
show columns from mysqltest.t1;
2005-05-07 15:55:46 +02:00
connect (user4,localhost,mysqltest_3,,mysqltest);
connection user4;
select table_name, column_name, privileges from information_schema.columns
where table_schema = 'mysqltest' and table_name = 'v1';
2009-02-09 22:00:15 +01:00
--error ER_VIEW_NO_EXPLAIN
2006-06-20 12:20:32 +02:00
explain select * from v1;
2005-04-05 12:12:15 +02:00
connection default;
2009-02-05 21:47:23 +01:00
disconnect user4;
2004-11-13 11:56:39 +01:00
2005-05-07 15:55:46 +02:00
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
# Test for information_schema.CHARACTER_SETS &
# SHOW CHARACTER SET
select * from information_schema.CHARACTER_SETS
where CHARACTER_SET_NAME like 'latin1%';
SHOW CHARACTER SET LIKE 'latin1%';
2005-01-24 16:44:54 +01:00
SHOW CHARACTER SET WHERE charset like 'latin1%';
2004-11-13 11:56:39 +01:00
# Test for information_schema.COLLATIONS &
# SHOW COLLATION
2006-04-04 12:40:42 +02:00
--replace_column 5 #
2004-11-13 11:56:39 +01:00
select * from information_schema.COLLATIONS
where COLLATION_NAME like 'latin1%';
2006-04-04 12:40:42 +02:00
--replace_column 5 #
2004-11-13 11:56:39 +01:00
SHOW COLLATION LIKE 'latin1%';
2006-04-04 12:40:42 +02:00
--replace_column 5 #
2005-01-24 16:44:54 +01:00
SHOW COLLATION WHERE collation like 'latin1%';
2004-11-13 11:56:39 +01:00
select * from information_schema.COLLATION_CHARACTER_SET_APPLICABILITY
where COLLATION_NAME like 'latin1%';
# Test for information_schema.ROUTINES &
#
2005-07-04 02:42:33 +02:00
--disable_warnings
drop procedure if exists sel2;
drop function if exists sub1;
drop function if exists sub2;
--enable_warnings
2004-11-13 11:56:39 +01:00
create function sub1(i int) returns int
return i+1;
delimiter |;
create procedure sel2()
begin
select * from t1;
select * from t2;
end|
delimiter ;|
2004-12-14 12:55:28 +01:00
#
# Bug#7222 information_schema: errors in "routines"
#
2009-02-05 21:47:23 +01:00
select parameter_style, sql_data_access, dtd_identifier
2008-04-08 16:51:26 +02:00
from information_schema.routines where routine_schema='test';
2004-12-14 12:55:28 +01:00
2004-11-13 11:56:39 +01:00
--replace_column 5 # 6 #
2008-04-08 16:51:26 +02:00
show procedure status where db='test';
2004-11-13 11:56:39 +01:00
--replace_column 5 # 6 #
2008-04-08 16:51:26 +02:00
show function status where db='test';
2004-11-13 11:56:39 +01:00
select a.ROUTINE_NAME from information_schema.ROUTINES a,
information_schema.SCHEMATA b where
2008-04-08 16:51:26 +02:00
a.ROUTINE_SCHEMA = b.SCHEMA_NAME AND b.SCHEMA_NAME='test';
2004-11-13 11:56:39 +01:00
--replace_column 3 #
explain select a.ROUTINE_NAME from information_schema.ROUTINES a,
information_schema.SCHEMATA b where
a.ROUTINE_SCHEMA = b.SCHEMA_NAME;
select a.ROUTINE_NAME, b.name from information_schema.ROUTINES a,
2008-04-08 16:51:26 +02:00
mysql.proc b where a.ROUTINE_NAME = convert(b.name using utf8) AND a.ROUTINE_SCHEMA='test' order by 1;
select count(*) from information_schema.ROUTINES where routine_schema='test';
2004-11-13 11:56:39 +01:00
2008-04-08 16:51:26 +02:00
create view v1 as select routine_schema, routine_name from information_schema.routines where routine_schema='test'
2006-03-20 11:17:47 +01:00
order by routine_schema, routine_name;
select * from v1;
drop view v1;
2005-03-05 12:35:32 +01:00
connect (user1,localhost,mysqltest_1,,);
connection user1;
select ROUTINE_NAME, ROUTINE_DEFINITION from information_schema.ROUTINES;
2009-02-05 21:47:23 +01:00
--error ER_SP_DOES_NOT_EXIST
2005-03-05 12:35:32 +01:00
show create function sub1;
connection user3;
select ROUTINE_NAME, ROUTINE_DEFINITION from information_schema.ROUTINES;
connection default;
grant all privileges on test.* to mysqltest_1@localhost;
connect (user2,localhost,mysqltest_1,,);
connection user2;
select ROUTINE_NAME, ROUTINE_DEFINITION from information_schema.ROUTINES;
create function sub2(i int) returns int
return i+1;
select ROUTINE_NAME, ROUTINE_DEFINITION from information_schema.ROUTINES;
show create procedure sel2;
show create function sub1;
show create function sub2;
2005-07-19 10:49:43 +02:00
--replace_column 5 # 6 #
show function status like "sub2";
2005-03-05 12:35:32 +01:00
connection default;
disconnect user1;
2009-02-05 21:47:23 +01:00
disconnect user3;
2005-03-05 12:35:32 +01:00
drop function sub2;
show create procedure sel2;
2004-11-13 11:56:39 +01:00
#
# Test for views
#
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;
--replace_column 3 #
explain select * from v0;
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;
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;
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;
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;
show keys from v4;
2004-11-26 16:26:52 +01:00
select * from information_schema.views where TABLE_NAME like "v%";
2004-11-13 11:56:39 +01:00
drop view v0, v1, v2, v3, v4;
#
# Test for privileges tables
#
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%';
select * from information_schema.SCHEMA_PRIVILEGES where grantee like '%mysqltest_1%';
select * from information_schema.TABLE_PRIVILEGES where grantee like '%mysqltest_1%';
select * from information_schema.COLUMN_PRIVILEGES where grantee like '%mysqltest_1%';
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;
#
# Test for KEY_COLUMN_USAGE & TABLE_CONSTRAINTS tables
#
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;
select * from information_schema.TABLE_CONSTRAINTS where
TABLE_SCHEMA= "test";
select * from information_schema.KEY_COLUMN_USAGE where
TABLE_SCHEMA= "test";
2005-03-05 12:35:32 +01:00
connection user2;
2004-11-13 11:56:39 +01:00
select table_name from information_schema.TABLES where table_schema like "test%";
select table_name,column_name from information_schema.COLUMNS where table_schema like "test%";
select ROUTINE_NAME from information_schema.ROUTINES;
2005-03-05 12:35:32 +01:00
disconnect user2;
2004-11-13 11:56:39 +01:00
connection default;
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;
grant select (a) on test.t1 to joe@localhost with grant option;
select * from INFORMATION_SCHEMA.COLUMN_PRIVILEGES;
select * from INFORMATION_SCHEMA.TABLE_PRIVILEGES;
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;
2005-02-08 20:52:50 +01:00
# QQ This results in NULLs instead of the version numbers when
# QQ a LOCK TABLES is in effect when selecting from
2005-07-31 11:49:55 +02:00
# QQ information_schema.tables.
2005-09-01 20:02:08 +02:00
--disable_parsing # until bug is fixed
2005-07-31 11:49:55 +02:00
delimiter //;
create procedure px5 ()
begin
declare v int;
declare c cursor for select version from
information_schema.tables where table_schema <> 'information_schema';
open c;
fetch c into v;
select v;
close c;
end;//
call px5()//
call px5()//
delimiter ;//
select sql_mode from information_schema.ROUTINES;
drop procedure px5;
--enable_parsing
2004-11-15 17:20:45 +01:00
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';
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;
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
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
set names latin1;
create table t1 select * from information_schema.CHARACTER_SETS
where CHARACTER_SET_NAME like "latin1";
select * from t1;
alter table t1 default character set utf8;
show create table t1;
2004-11-19 23:17:18 +01:00
drop table t1;
2004-11-18 10:16:06 +01:00
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);
2009-02-05 21:47:23 +01:00
select COLUMN_NAME,COLUMN_TYPE, CHARACTER_MAXIMUM_LENGTH,
2004-11-19 23:17:18 +01:00
CHARACTER_OCTET_LENGTH, NUMERIC_PRECISION, NUMERIC_SCALE
from information_schema.columns where table_name= 't1';
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;
drop table t115;
delimiter //;
create procedure p108 () begin declare c cursor for select data_type
from information_schema.columns; open c; open c; end;//
2009-02-05 21:47:23 +01:00
--error ER_SP_CURSOR_ALREADY_OPEN
2004-11-23 15:41:39 +01:00
call p108()//
delimiter ;//
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;
drop view v1;
2009-02-05 21:47:23 +01:00
create view vo as select 'a' union select 'a';
2004-11-26 16:26:52 +01:00
show index from vo;
select * from information_schema.TABLE_CONSTRAINTS where
TABLE_NAME= "vo";
select * from information_schema.KEY_COLUMN_USAGE where
2009-02-05 21:47:23 +01:00
TABLE_NAME= "vo";
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
2009-02-05 21:47:23 +01:00
from information_schema.tables
2004-12-10 10:07:11 +01:00
where table_schema='information_schema' limit 2;
2005-01-27 11:16:51 +01:00
show tables from information_schema like "T%";
2004-12-10 10:07:11 +01:00
2009-02-05 21:47:23 +01:00
--error ER_DBACCESS_DENIED_ERROR
2004-12-10 10:07:11 +01:00
create database information_schema;
use information_schema;
show full tables like "T%";
2009-02-05 21:47:23 +01:00
--error ER_UNKNOWN_TABLE
2004-12-10 10:07:11 +01:00
create table t1(a int);
use test;
show tables;
use information_schema;
show tables like "T%";
2004-12-16 14:31:36 +01:00
2004-12-18 10:48:01 +01:00
#
2009-02-05 21:47:23 +01:00
# Bug#7210 information_schema: can't access when table-name = reserved word
2004-12-18 10:48:01 +01:00
#
select table_name from tables where table_name='user';
select column_name, privileges from columns
where table_name='user' and column_name like '%o%';
2004-12-16 14:31:36 +01:00
#
2009-02-05 21:47:23 +01:00
# Bug#7212 information_schema: "Can't find file" errors if storage engine gone
# Bug#7211 information_schema: crash if bad view
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';
select table_name from information_schema.views
where table_schema='test';
2004-12-16 14:31:36 +01:00
select column_name from information_schema.columns
where table_schema='test';
select index_name from information_schema.statistics where table_schema='test';
select constraint_name from information_schema.table_constraints
where table_schema='test';
2005-11-11 10:39:46 +01:00
show create view v2;
show create table v3;
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
#
2009-02-05 21:47:23 +01:00
# Bug#7213 information_schema: redundant non-standard TABLE_NAMES table
2004-12-18 11:49:13 +01:00
#
2009-02-05 21:47:23 +01:00
--error ER_UNKNOWN_TABLE
2004-12-18 11:49:13 +01:00
select * from information_schema.table_names;
2004-12-23 11:35:34 +01:00
#
# Bug#2719 information_schema: errors in "columns"
#
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");
2004-12-24 10:16:47 +01:00
#
# Bug#2718 information_schema: errors in "tables"
#
2009-02-05 21:47:23 +01:00
select TABLE_ROWS from information_schema.tables where
2004-12-24 10:16:47 +01:00
table_schema="information_schema" and table_name="COLUMNS";
select table_type from information_schema.tables
where table_schema="mysql" and table_name="user";
2004-12-30 13:20:40 +01:00
# test for 'show open tables ... where'
show open tables where `table` like "user";
# test for 'show status ... where'
2005-01-24 16:44:54 +01:00
show status where variable_name like "%database%";
2004-12-30 13:20:40 +01:00
# test for 'show variables ... where'
2005-01-24 16:44:54 +01:00
show variables where variable_name like "skip_show_databas";
2005-01-18 15:37:45 +01:00
#
2009-02-05 21:47:23 +01:00
# Bug#7981 SHOW GLOBAL STATUS crashes server
2005-01-18 15:37:45 +01:00
#
2005-08-03 01:50:10 +02:00
# We don't actually care about the value, just that it doesn't crash.
--replace_column 2 #
2005-01-18 15:37:45 +01:00
show global status like "Threads_running";
2005-02-16 11:00:03 +01:00
#
2009-02-05 21:47:23 +01:00
# Bug#7915 crash,JOIN VIEW, subquery,
2005-02-16 11:00:03 +01:00
# SELECT .. FROM INFORMATION_SCHEMA.COLUMNS
#
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
#
2009-02-05 21:47:23 +01:00
# Bug#7476 crash on SELECT * FROM INFORMATION_SCHEMA.TABLES
2005-02-22 12:42:44 +01:00
#
2006-08-15 09:16:21 +02:00
use test;
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;
let $tab_count= 65;
--disable_query_log
while ($tab_count)
{
EVAL CREATE TABLE t_$tab_count (f1 BIGINT);
dec $tab_count ;
}
--disable_result_log
SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES;
--enable_result_log
2006-08-15 09:16:21 +02:00
SELECT count(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test';
2005-02-22 12:42:44 +01:00
let $tab_count= 65;
while ($tab_count)
{
EVAL DROP TABLE t_$tab_count;
dec $tab_count ;
}
--enable_query_log
drop view a2, a1;
drop table t_crashme;
2005-02-23 13:15:36 +01:00
#
2009-02-05 21:47:23 +01:00
# Bug#7215 information_schema: columns are longtext instead of varchar
# Bug#7217 information_schema: columns are varbinary() instead of timestamp
2005-02-23 13:15:36 +01:00
#
select table_schema,table_name, column_name from
2009-02-05 21:47:23 +01:00
information_schema.columns
2005-02-23 13:15:36 +01:00
where data_type = 'longtext';
select table_name, column_name, data_type from information_schema.columns
where data_type = 'datetime';
2005-03-03 17:20:16 +01:00
#
2009-02-05 21:47:23 +01:00
# Bug#8164 subquery with INFORMATION_SCHEMA.COLUMNS, 100 % CPU
2005-03-03 17:20:16 +01:00
#
SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES A
2009-02-05 21:47:23 +01:00
WHERE NOT EXISTS
2005-03-03 17:20:16 +01:00
(SELECT * FROM INFORMATION_SCHEMA.COLUMNS B
WHERE A.TABLE_SCHEMA = B.TABLE_SCHEMA
AND A.TABLE_NAME = B.TABLE_NAME);
2005-03-31 10:44:42 +02:00
#
2009-02-05 21:47:23 +01:00
# Bug#9344 INFORMATION_SCHEMA, wrong content, numeric columns
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';
drop table t1;
2005-05-07 17:14:34 +02:00
#
2009-02-05 21:47:23 +01:00
# Bug#10261 INFORMATION_SCHEMA.COLUMNS, incomplete result for non root user
2005-05-07 17:14:34 +02:00
#
2005-06-18 03:02:27 +02:00
grant select on test.* to mysqltest_4@localhost;
2005-10-12 13:56:07 +02:00
connect (user10261,localhost,mysqltest_4,,);
connection user10261;
2009-02-05 21:47:23 +01:00
SELECT TABLE_NAME, COLUMN_NAME, PRIVILEGES FROM INFORMATION_SCHEMA.COLUMNS
2005-05-07 17:14:34 +02:00
where COLUMN_NAME='TABLE_NAME';
connection default;
2009-02-05 21:47:23 +01:00
disconnect user10261;
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 19:21:44 +02:00
#
2009-02-05 21:47:23 +01:00
# Bug#9404 information_schema: Weird error messages
2005-05-09 18:22:49 +02:00
# with SELECT SUM() ... GROUP BY queries
#
2008-04-08 16:51:26 +02:00
SELECT table_schema, count(*) FROM information_schema.TABLES WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test', 'mysqltest') AND table_name<>'ndb_binlog_index' AND table_name<>'ndb_apply_status' GROUP BY TABLE_SCHEMA;
2005-05-09 19:21:44 +02:00
2005-07-19 18:06:49 +02:00
#
# TRIGGERS table test
#
create table t1 (i int, j int);
delimiter |;
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|
delimiter ;|
show triggers;
2008-04-08 16:51:26 +02:00
select * from information_schema.triggers where trigger_schema in ('mysql', 'information_schema', 'test', 'mysqltest');
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
#
2009-02-05 21:47:23 +01:00
# Bug#10964 Information Schema:Authorization check on privilege tables is improper
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;
2005-06-18 03:02:27 +02:00
connect (con1,localhost,user1,,mysqltest);
connect (con2,localhost,user2,,mysqltest);
connect (con3,localhost,user3,,mysqltest);
2005-06-02 12:33:53 +02:00
connect (con4,localhost,user4,,);
connection con1;
2006-06-06 09:57:50 +02:00
select * from information_schema.column_privileges order by grantee;
select * from information_schema.table_privileges order by grantee;
select * from information_schema.schema_privileges order by grantee;
select * from information_schema.user_privileges order by grantee;
2005-06-02 12:33:53 +02:00
show grants;
connection con2;
2006-06-06 09:57:50 +02:00
select * from information_schema.column_privileges order by grantee;
select * from information_schema.table_privileges order by grantee;
select * from information_schema.schema_privileges order by grantee;
select * from information_schema.user_privileges order by grantee;
2005-06-02 12:33:53 +02:00
show grants;
connection con3;
2006-06-06 09:57:50 +02:00
select * from information_schema.column_privileges order by grantee;
select * from information_schema.table_privileges order by grantee;
select * from information_schema.schema_privileges order by grantee;
select * from information_schema.user_privileges order by grantee;
2005-06-02 12:33:53 +02:00
show grants;
connection con4;
2006-06-06 09:57:50 +02:00
select * from information_schema.column_privileges where grantee like '%user%'
order by grantee;
select * from information_schema.table_privileges where grantee like '%user%'
order by grantee;
select * from information_schema.schema_privileges where grantee like '%user%'
order by grantee;
select * from information_schema.user_privileges where grantee like '%user%'
order by grantee;
2005-06-02 12:33:53 +02:00
show grants;
connection default;
2009-02-05 21:47:23 +01:00
disconnect con1;
disconnect con2;
disconnect con3;
disconnect con4;
2005-06-02 12:33:53 +02:00
drop user user1@localhost, user2@localhost, user3@localhost, user4@localhost;
use test;
drop database mysqltest;
2005-06-16 09:12:47 +02:00
#
2009-02-05 21:47:23 +01:00
# Bug#11055 information_schema: routines.sql_data_access has wrong value
2005-06-16 09:12:47 +02:00
#
2005-07-04 02:42:33 +02:00
--disable_warnings
drop procedure if exists p1;
drop procedure if exists p2;
--enable_warnings
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%';
drop procedure p1;
drop procedure p2;
2005-06-16 10:27:22 +02:00
#
2009-02-05 21:47:23 +01:00
# Bug#9434 SHOW CREATE DATABASE information_schema;
2005-06-16 10:27:22 +02:00
#
show create database information_schema;
2005-07-19 11:30:32 +02:00
#
2009-02-05 21:47:23 +01:00
# Bug#11057 information_schema: columns table has some questionable contents
# Bug#12301 information_schema: NUMERIC_SCALE must be 0 for integer columns
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';
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';
drop table t1;
2005-07-27 13:17:05 +02:00
#
2009-02-05 21:47:23 +01:00
# Bug#12127 triggers do not show in info_schema before they are used if set to the database
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';
use test;
drop table t1;
2005-08-15 18:14:55 +02:00
#
# Bug#12518 COLUMN_DEFAULT has wrong value if NOT NULL is set
#
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';
use test;
2005-08-20 10:00:00 +02:00
show columns from t1;
2005-08-15 18:14:55 +02:00
drop table t1;
2005-08-23 02:32:02 +02:00
#
2009-02-05 21:47:23 +01:00
# Bug#12636 SHOW TABLE STATUS with where condition containing a subquery
2009-02-09 22:00:15 +01:00
# over information schema
2005-08-23 02:32:02 +02:00
#
CREATE TABLE t1 (a int);
CREATE TABLE t2 (b int);
--replace_column 8 # 12 # 13 #
SHOW TABLE STATUS FROM test
WHERE name IN ( SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA='test' AND TABLE_TYPE='BASE TABLE');
2005-09-07 13:11:53 +02:00
DROP TABLE t1,t2;
#
2009-02-05 21:47:23 +01:00
# Bug#12905 show fields from view behaving erratically with current database
2005-09-07 13:11:53 +02:00
#
create table t1(f1 int);
create view v1 (c) as select f1 from t1;
connect (con5,localhost,root,,*NO-ONE*);
select database();
show fields from test.v1;
connection default;
2009-02-05 21:47:23 +01:00
disconnect con5;
2005-09-07 13:11:53 +02:00
drop view v1;
drop table t1;
2005-09-13 13:07:38 +02:00
#
2009-02-05 21:47:23 +01:00
# Bug#9846 Inappropriate error displayed while dropping table from 'INFORMATION_SCHEMA'
2005-09-13 13:07:38 +02:00
#
2007-07-11 23:10:29 +02:00
--error ER_PARSE_ERROR
2005-09-13 13:07:38 +02:00
alter database information_schema;
2009-02-05 21:47:23 +01:00
--error ER_DBACCESS_DENIED_ERROR
2005-09-13 13:07:38 +02:00
drop database information_schema;
2009-02-05 21:47:23 +01:00
--error ER_DBACCESS_DENIED_ERROR
2005-09-13 13:07:38 +02:00
drop table information_schema.tables;
2009-02-05 21:47:23 +01:00
--error ER_DBACCESS_DENIED_ERROR
2005-09-13 13:07:38 +02:00
alter table information_schema.tables;
#
2009-02-05 21:47:23 +01:00
# Bug#9683 INFORMATION_SCH: Creation of temporary table allowed in Information_schema DB
2005-09-13 13:07:38 +02:00
#
use information_schema;
2009-02-05 21:47:23 +01:00
--error ER_DBACCESS_DENIED_ERROR
2005-09-13 13:07:38 +02:00
create temporary table schemata(f1 char(10));
#
2009-02-05 21:47:23 +01:00
# Bug#10708 SP's can use INFORMATION_SCHEMA as ROUTINE_SCHEMA
2005-09-13 13:07:38 +02:00
#
delimiter |;
2006-12-01 12:50:57 +01:00
--error ER_BAD_DB_ERROR
2005-09-13 13:07:38 +02:00
CREATE PROCEDURE p1 ()
BEGIN
SELECT 'foo' FROM DUAL;
END |
delimiter ;|
2009-02-09 22:00:15 +01:00
select ROUTINE_NAME from routines where ROUTINE_SCHEMA='information_schema';
2005-09-13 13:07:38 +02:00
#
2009-02-05 21:47:23 +01:00
# Bug#10734 Grant of privileges other than 'select' and 'create view' should fail on schema
2005-09-13 13:07:38 +02:00
#
2009-02-05 21:47:23 +01:00
--error ER_DBACCESS_DENIED_ERROR
2005-09-13 13:07:38 +02:00
grant all on information_schema.* to 'user1'@'localhost';
2009-02-05 21:47:23 +01:00
--error ER_DBACCESS_DENIED_ERROR
2005-09-13 13:07:38 +02:00
grant select on information_schema.* to 'user1'@'localhost';
2005-10-21 10:14:54 +02:00
#
# Bug#14089 FROM list subquery always fails when information_schema is current database
#
use test;
create table t1(id int);
insert into t1(id) values (1);
select 1 from (select 1 from test.t1) a;
use information_schema;
select 1 from (select 1 from test.t1) a;
use test;
drop table t1;
2005-10-25 14:22:58 +02:00
2005-12-01 08:00:33 +01:00
#
# Bug#14476 `information_schema`.`TABLES`.`TABLE_TYPE` with empty value
#
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";
drop view v1;
2005-12-22 10:07:47 +01:00
2005-12-19 11:46:54 +01:00
#
2009-02-05 21:47:23 +01:00
# Bug#14387 SHOW COLUMNS doesn't work on temporary tables
# Bug#15224 SHOW INDEX from temporary table doesn't work
# Bug#12770 DESC cannot display the info. about temporary table
2005-12-19 11:46:54 +01:00
#
create temporary table t1(f1 int, index(f1));
show columns from t1;
describe t1;
show indexes from t1;
drop table t1;
2005-12-19 13:21:02 +01:00
#
# Bug#14271 I_S: columns has no size for (var)binary columns
#
create table t1(f1 binary(32), f2 varbinary(64));
select character_maximum_length, character_octet_length
from information_schema.columns where table_name='t1';
drop table t1;
2005-12-24 18:13:51 +01:00
2005-12-22 10:07:47 +01:00
#
2006-01-03 11:25:19 +01:00
# Bug#15533 crash, information_schema, function, view
#
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;
delimiter //;
CREATE FUNCTION func1() RETURNS BIGINT
BEGIN
RETURN ( SELECT COUNT(*) FROM INFORMATION_SCHEMA.VIEWS);
END//
delimiter ;//
CREATE VIEW v1 AS SELECT 1 FROM t1
WHERE f3 = (SELECT func2 ());
SELECT func1();
DROP TABLE t1;
DROP VIEW v1;
DROP FUNCTION func1;
DROP FUNCTION func2;
2006-01-24 12:59:08 +01:00
2006-01-24 13:48:19 +01:00
#
# Bug#15307 GROUP_CONCAT() with ORDER BY returns empty set on information_schema
#
select column_type, group_concat(table_schema, '.', table_name), count(*) as num
from information_schema.columns where
table_schema='information_schema' and
2007-11-13 14:24:48 +01:00
(column_type = 'varchar(7)' or column_type = 'varchar(20)'
or column_type = 'varchar(27)')
2006-01-24 13:48:19 +01:00
group by column_type order by num;
2006-02-02 21:27:06 +01:00
2006-05-12 12:09:25 +02:00
#
# Bug#19236 bad COLUMNS.CHARACTER_MAXIMUM_LENGHT and CHARACTER_OCTET_LENGTH
#
create table t1(f1 char(1) not null, f2 char(9) not null)
default character set utf8;
select CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH from
information_schema.columns where table_schema='test' and table_name = 't1';
drop table t1;
2006-05-12 14:34:36 +02:00
#
# Bug#18177 any access to INFORMATION_SCHEMA.ROUTINES crashes
#
use mysql;
INSERT INTO `proc` VALUES ('test','','PROCEDURE','','SQL','CONTAINS_SQL',
'NO','DEFINER','','','BEGIN\r\n \r\nEND','root@%','2006-03-02 18:40:03',
Patch for the following bugs:
- BUG#11986: Stored routines and triggers can fail if the code
has a non-ascii symbol
- BUG#16291: mysqldump corrupts string-constants with non-ascii-chars
- BUG#19443: INFORMATION_SCHEMA does not support charsets properly
- BUG#21249: Character set of SP-var can be ignored
- BUG#25212: Character set of string constant is ignored (stored routines)
- BUG#25221: Character set of string constant is ignored (triggers)
There were a few general problems that caused these bugs:
1. Character set information of the original (definition) query for views,
triggers, stored routines and events was lost.
2. mysqldump output query in client character set, which can be
inappropriate to encode definition-query.
3. INFORMATION_SCHEMA used strings with mixed encodings to display object
definition;
1. No query-definition-character set.
In order to compile query into execution code, some extra data (such as
environment variables or the database character set) is used. The problem
here was that this context was not preserved. So, on the next load it can
differ from the original one, thus the result will be different.
The context contains the following data:
- client character set;
- connection collation (character set and collation);
- collation of the owner database;
The fix is to store this context and use it each time we parse (compile)
and execute the object (stored routine, trigger, ...).
2. Wrong mysqldump-output.
The original query can contain several encodings (by means of character set
introducers). The problem here was that we tried to convert original query
to the mysqldump-client character set.
Moreover, we stored queries in different character sets for different
objects (views, for one, used UTF8, triggers used original character set).
The solution is
- to store definition queries in the original character set;
- to change SHOW CREATE statement to output definition query in the
binary character set (i.e. without any conversion);
- introduce SHOW CREATE TRIGGER statement;
- to dump special statements to switch the context to the original one
before dumping and restore it afterwards.
Note, in order to preserve the database collation at the creation time,
additional ALTER DATABASE might be used (to temporary switch the database
collation back to the original value). In this case, ALTER DATABASE
privilege will be required. This is a backward-incompatible change.
3. INFORMATION_SCHEMA showed non-UTF8 strings
The fix is to generate UTF8-query during the parsing, store it in the object
and show it in the INFORMATION_SCHEMA.
Basically, the idea is to create a copy of the original query convert it to
UTF8. Character set introducers are removed and all text literals are
converted to UTF8.
This UTF8 query is intended to provide user-readable output. It must not be
used to recreate the object. Specialized SHOW CREATE statements should be
used for this.
The reason for this limitation is the following: the original query can
contain symbols from several character sets (by means of character set
introducers).
Example:
- original query:
CREATE VIEW v1 AS SELECT _cp1251 'Hello' AS c1;
- UTF8 query (for INFORMATION_SCHEMA):
CREATE VIEW v1 AS SELECT 'Hello' AS c1;
2007-06-28 19:34:54 +02:00
'2006-03-02 18:40:03','','','utf8','utf8_general_ci','utf8_general_ci','n/a');
2008-04-08 16:51:26 +02:00
select routine_name from information_schema.routines where ROUTINE_SCHEMA='test';
2006-05-12 14:34:36 +02:00
delete from proc where name='';
use test;
2006-05-16 10:37:40 +02:00
2006-05-23 09:45:25 +02:00
#
# Bug#16681 information_schema shows forbidden VIEW details
#
grant select on test.* to mysqltest_1@localhost;
create table t1 (id int);
create view v1 as select * from t1;
create definer = mysqltest_1@localhost
sql security definer view v2 as select 1;
connect (con16681,localhost,mysqltest_1,,test);
connection con16681;
select * from information_schema.views
where table_name='v1' or table_name='v2';
connection default;
2009-02-05 21:47:23 +01:00
disconnect con16681;
2006-05-23 09:45:25 +02:00
drop view v1, v2;
drop table t1;
drop user mysqltest_1@localhost;
2006-02-16 14:45:05 +01:00
2006-06-06 09:51:04 +02:00
#
# Bug#19599 duplication of information_schema column value in a CONCAT expr with user var
#
set @a:= '.';
create table t1(f1 char(5));
create table t2(f1 char(5));
select concat(@a, table_name), @a, table_name
from information_schema.tables where table_schema = 'test';
drop table t1,t2;
2006-06-14 07:54:56 +02:00
2006-06-29 22:21:55 +02:00
#
2009-02-05 21:47:23 +01:00
# Bug#20230 routine_definition is not null
2006-06-29 22:21:55 +02:00
#
--disable_warnings
DROP PROCEDURE IF EXISTS p1;
DROP FUNCTION IF EXISTS f1;
--enable_warnings
CREATE PROCEDURE p1() SET @a= 1;
CREATE FUNCTION f1() RETURNS INT RETURN @a + 1;
CREATE USER mysql_bug20230@localhost;
GRANT EXECUTE ON PROCEDURE p1 TO mysql_bug20230@localhost;
GRANT EXECUTE ON FUNCTION f1 TO mysql_bug20230@localhost;
2008-04-08 16:51:26 +02:00
SELECT ROUTINE_NAME, ROUTINE_DEFINITION FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_SCHEMA='test';
2006-06-29 22:21:55 +02:00
SHOW CREATE PROCEDURE p1;
SHOW CREATE FUNCTION f1;
connect (conn1, localhost, mysql_bug20230,,);
2008-04-08 16:51:26 +02:00
SELECT ROUTINE_NAME, ROUTINE_DEFINITION FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_SCHEMA='test';
2006-06-29 22:21:55 +02:00
SHOW CREATE PROCEDURE p1;
SHOW CREATE FUNCTION f1;
CALL p1();
SELECT f1();
disconnect conn1;
connection default;
DROP FUNCTION f1;
DROP PROCEDURE p1;
DROP USER mysql_bug20230@localhost;
2006-07-22 21:44:54 +02:00
#
2009-02-05 21:47:23 +01:00
# Bug#18925 subqueries with MIN/MAX functions on INFORMARTION_SCHEMA
2006-07-22 21:44:54 +02:00
#
SELECT t.table_name, c1.column_name
FROM information_schema.tables t
INNER JOIN
information_schema.columns c1
ON t.table_schema = c1.table_schema AND
t.table_name = c1.table_name
WHERE t.table_schema = 'information_schema' AND
c1.ordinal_position =
( SELECT COALESCE(MIN(c2.ordinal_position),1)
FROM information_schema.columns c2
WHERE c2.table_schema = t.table_schema AND
c2.table_name = t.table_name AND
c2.column_name LIKE '%SCHEMA%'
);
SELECT t.table_name, c1.column_name
FROM information_schema.tables t
INNER JOIN
information_schema.columns c1
ON t.table_schema = c1.table_schema AND
t.table_name = c1.table_name
WHERE t.table_schema = 'information_schema' AND
c1.ordinal_position =
( SELECT COALESCE(MIN(c2.ordinal_position),1)
FROM information_schema.columns c2
WHERE c2.table_schema = 'information_schema' AND
c2.table_name = t.table_name AND
c2.column_name LIKE '%SCHEMA%'
);
2006-07-25 04:05:46 +02:00
#
2009-02-05 21:47:23 +01:00
# Bug#2123 query with a simple non-correlated subquery over
# INFORMARTION_SCHEMA.TABLES
2006-07-25 04:05:46 +02:00
#
2008-04-08 16:51:26 +02:00
SELECT MAX(table_name) FROM information_schema.tables WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test');
2006-07-25 04:05:46 +02:00
SELECT table_name from information_schema.tables
WHERE table_name=(SELECT MAX(table_name)
2008-04-08 16:51:26 +02:00
FROM information_schema.tables WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test'));
2006-10-23 13:12:30 +02:00
#
2009-02-05 21:47:23 +01:00
# Bug#23037 Bug in field "Default" of query "SHOW COLUMNS FROM table"
2006-10-23 13:12:30 +02:00
#
# Note, MyISAM/InnoDB can't take more that 65532 chars, because the row
# size is limited to 65535 bytes (BLOBs not counted)
#
--disable_warnings
DROP TABLE IF EXISTS bug23037;
DROP FUNCTION IF EXISTS get_value;
--enable_warnings
--disable_query_log
DELIMITER |;
CREATE FUNCTION get_value()
RETURNS TEXT
DETERMINISTIC
BEGIN
DECLARE col1, col2, col3, col4, col6 CHAR(255);
DECLARE default_val VARCHAR(65532);
DECLARE done INT DEFAULT 0;
2007-10-11 22:38:40 +02:00
DECLARE cur1 CURSOR FOR SELECT COLUMN_NAME, COLUMN_TYPE, IS_NULLABLE, COLUMN_KEY, COLUMN_DEFAULT, EXTRA FROM INFORMATION_SCHEMA.COLUMNS where TABLE_NAME='bug23037';
2006-10-23 13:12:30 +02:00
DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;
OPEN cur1;
FETCH cur1 INTO col1, col2, col3, col4, default_val, col6;
CLOSE cur1;
RETURN default_val;
end|
DELIMITER ;|
let $body=`SELECT REPEAT('A', 65532)`;
eval CREATE TABLE bug23037(fld1 VARCHAR(65532) CHARACTER SET latin1 DEFAULT "$body");
--enable_query_log
SELECT COLUMN_NAME, MD5(COLUMN_DEFAULT), LENGTH(COLUMN_DEFAULT) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='bug23037';
SELECT MD5(get_value());
SELECT COLUMN_NAME, MD5(COLUMN_DEFAULT), LENGTH(COLUMN_DEFAULT), COLUMN_DEFAULT=get_value() FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='bug23037';
2006-07-25 04:05:46 +02:00
2006-10-23 13:12:30 +02:00
DROP TABLE bug23037;
DROP FUNCTION get_value;
2006-11-21 10:45:01 +01:00
#
2009-02-05 21:47:23 +01:00
# Bug#22413 EXPLAIN SELECT FROM view with ORDER BY yield server crash
2006-11-21 10:45:01 +01:00
#
create view v1 as
select table_schema as object_schema,
table_name as object_name,
table_type as object_type
from information_schema.tables
order by object_schema;
explain select * from v1;
explain select * from (select table_name from information_schema.tables) as a;
drop view v1;
2007-02-01 16:12:45 +01:00
#
# Bug#23299 Some queries against INFORMATION_SCHEMA with subqueries fail
#
create table t1 (f1 int(11));
create table t2 (f1 int(11), f2 int(11));
select table_name from information_schema.tables
where table_schema = 'test' and table_name not in
(select table_name from information_schema.columns
where table_schema = 'test' and column_name = 'f3');
drop table t1,t2;
2007-02-12 13:06:14 +01:00
#
2009-02-05 21:47:23 +01:00
# Bug#24630 Subselect query crashes mysqld
2007-02-12 13:06:14 +01:00
#
select 1 as f1 from information_schema.tables where "CHARACTER_SETS"=
(select cast(table_name as char) from information_schema.tables
order by table_name limit 1) limit 1;
select t.table_name, group_concat(t.table_schema, '.', t.table_name),
count(*) as num1
from information_schema.tables t
inner join information_schema.columns c1
on t.table_schema = c1.table_schema AND t.table_name = c1.table_name
where t.table_schema = 'information_schema' and
c1.ordinal_position =
(select isnull(c2.column_type) -
isnull(group_concat(c2.table_schema, '.', c2.table_name)) +
count(*) as num
from information_schema.columns c2 where
c2.table_schema='information_schema' and
(c2.column_type = 'varchar(7)' or c2.column_type = 'varchar(20)')
group by c2.column_type order by num limit 1)
group by t.table_name order by num1, t.table_name;
2007-06-09 13:52:37 +02:00
#
# Bug#28266 IS_UPDATABLE field on VIEWS table in I_S database is wrong
#
create table t1(f1 int);
create view v1 as select f1+1 as a from t1;
2009-02-05 21:47:23 +01:00
create table t2 (f1 int, f2 int);
create view v2 as select f1+1 as a, f2 as b from t2;
2007-06-09 13:52:37 +02:00
select table_name, is_updatable from information_schema.views;
#
# Note: we can perform 'delete' for non updatable view.
#
delete from v1;
drop view v1,v2;
drop table t1,t2;
2007-07-11 23:10:29 +02:00
#
2009-02-05 21:47:23 +01:00
# Bug#25859 ALTER DATABASE works w/o parameters
2007-07-11 23:10:29 +02:00
#
--error ER_PARSE_ERROR
alter database;
--error ER_PARSE_ERROR
alter database test;
2007-07-16 21:31:36 +02:00
2007-08-20 08:23:08 +02:00
#
# Bug#27629 Possible security flaw in INFORMATION_SCHEMA and SHOW statements
#
create database mysqltest;
create table mysqltest.t1(a int, b int, c int);
create trigger mysqltest.t1_ai after insert on mysqltest.t1
for each row set @a = new.a + new.b + new.c;
grant select(b) on mysqltest.t1 to mysqltest_1@localhost;
select trigger_name from information_schema.triggers
where event_object_table='t1';
show triggers from mysqltest;
connect (con27629,localhost,mysqltest_1,,mysqltest);
show columns from t1;
select column_name from information_schema.columns where table_name='t1';
show triggers;
select trigger_name from information_schema.triggers
where event_object_table='t1';
connection default;
2009-02-05 21:47:23 +01:00
disconnect con27629;
2007-08-20 08:23:08 +02:00
drop user mysqltest_1@localhost;
drop database mysqltest;
2007-09-20 10:54:46 +02:00
#
# Bug#27747 database metadata doesn't return sufficient column default info
#
create table t1 (
f1 varchar(50),
f2 varchar(50) not null,
f3 varchar(50) default '',
f4 varchar(50) default NULL,
f5 bigint not null,
f6 bigint not null default 10,
f7 datetime not null,
f8 datetime default '2006-01-01'
);
select column_default from information_schema.columns where table_name= 't1';
show columns from t1;
drop table t1;
2007-10-04 13:20:56 +02:00
#
# Bug#30079 A check for "hidden" I_S tables is flawed
#
2009-02-05 21:47:23 +01:00
--error ER_UNKNOWN_TABLE
2007-10-05 09:29:02 +02:00
show fields from information_schema.table_names;
2009-02-05 21:47:23 +01:00
--error ER_UNKNOWN_TABLE
2007-10-05 09:29:02 +02:00
show keys from information_schema.table_names;
2007-10-04 13:20:56 +02:00
2008-03-19 14:32:28 +01:00
#
2009-02-05 21:47:23 +01:00
# Bug#34529 Crash on complex Falcon I_S select after ALTER .. PARTITION BY
2008-03-19 14:32:28 +01:00
#
USE information_schema;
SET max_heap_table_size = 16384;
CREATE TABLE test.t1( a INT );
# What we need to create here is a bit of a corner case:
# We need a star query with information_schema tables, where the first
2009-02-05 21:47:23 +01:00
# branch of the star join produces zero rows, so that reading of the
2008-03-19 14:32:28 +01:00
# second branch never happens. At the same time we have to make sure
2009-02-05 21:47:23 +01:00
# that data for at least the last table is swapped from MEMORY/HEAP to
2008-03-19 14:32:28 +01:00
# MyISAM. This and only this triggers the bug.
SELECT *
FROM tables ta
JOIN collations co ON ( co.collation_name = ta.table_catalog )
JOIN character_sets cs ON ( cs.character_set_name = ta.table_catalog );
DROP TABLE test.t1;
SET max_heap_table_size = DEFAULT;
2008-03-25 16:44:27 +01:00
USE test;
--echo End of 5.0 tests.
2006-06-14 07:54:56 +02:00
#
# Show engines
#
select * from information_schema.engines WHERE ENGINE="MyISAM";
#
# INFORMATION_SCHEMA.PROCESSLIST
#
grant select on *.* to user3148@localhost;
connect (con3148,localhost,user3148,,test);
connection con3148;
select user,db from information_schema.processlist;
connection default;
2009-02-09 22:00:15 +01:00
disconnect con3148;
2006-06-14 07:54:56 +02:00
drop user user3148@localhost;
2007-04-02 09:51:14 +02:00
#
2009-02-09 22:00:15 +01:00
# Bug#26174 Server Crash: INSERT ... SELECT ... FROM I_S.GLOBAL_STATUS
2007-04-05 22:38:57 +02:00
# in Event (see also openssl_1.test)
2007-04-02 09:51:14 +02:00
#
--disable_warnings
2007-04-04 22:04:44 +02:00
DROP TABLE IF EXISTS server_status;
DROP EVENT IF EXISTS event_status;
2007-04-02 09:51:14 +02:00
--enable_warnings
2007-04-04 22:04:44 +02:00
SET GLOBAL event_scheduler=1;
2007-04-02 09:51:14 +02:00
DELIMITER $$;
2007-04-04 22:04:44 +02:00
CREATE EVENT event_status
2007-04-03 19:33:56 +02:00
ON SCHEDULE AT NOW()
2007-04-04 22:04:44 +02:00
ON COMPLETION NOT PRESERVE
2007-04-02 09:51:14 +02:00
DO
2007-04-04 22:04:44 +02:00
BEGIN
CREATE TABLE server_status
SELECT variable_name
FROM information_schema.global_status
WHERE variable_name LIKE 'ABORTED_CONNECTS' OR
variable_name LIKE 'BINLOG_CACHE_DISK_USE';
END$$
2007-04-02 09:51:14 +02:00
DELIMITER ;$$
2007-11-12 15:26:32 +01:00
let $wait_timeout= 300;
2007-04-04 22:04:44 +02:00
let $wait_condition=select count(*) = 0 from information_schema.events where event_name='event_status';
2007-04-03 19:33:56 +02:00
--source include/wait_condition.inc
2007-04-02 09:51:14 +02:00
2007-04-04 22:04:44 +02:00
SELECT variable_name FROM server_status;
2007-04-02 09:51:14 +02:00
DROP TABLE server_status;
SET GLOBAL event_scheduler=0;
2007-08-03 00:14:05 +02:00
#
# WL#3732 Information schema optimization
2009-02-09 22:00:15 +01:00
#
2007-08-03 00:14:05 +02:00
explain select table_name from information_schema.views where
table_schema='test' and table_name='v1';
explain select * from information_schema.tables;
explain select * from information_schema.collations;
explain select * from information_schema.tables where
table_schema='test' and table_name= 't1';
explain select table_name, table_type from information_schema.tables
where table_schema='test';
explain select b.table_name
from information_schema.tables a, information_schema.columns b
where a.table_name='t1' and a.table_schema='test' and b.table_name=a.table_name;
2007-08-09 17:41:26 +02:00
#
# Bug#30310 wrong result on SELECT * FROM INFORMATION_SCHEMA.SCHEMATA WHERE ..
#
SELECT * FROM INFORMATION_SCHEMA.SCHEMATA
WHERE SCHEMA_NAME = 'mysqltest';
SELECT * FROM INFORMATION_SCHEMA.SCHEMATA
WHERE SCHEMA_NAME = '';
SELECT * FROM INFORMATION_SCHEMA.SCHEMATA
WHERE SCHEMA_NAME = 'test';
select count(*) from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='mysql' AND TABLE_NAME='nonexisting';
select count(*) from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='mysql' AND TABLE_NAME='';
select count(*) from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='' AND TABLE_NAME='';
select count(*) from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='' AND TABLE_NAME='nonexisting';
2007-09-28 13:02:43 +02:00
#
# Bug#30689 Wrong content in I_S.VIEWS.VIEW_DEFINITION if VIEW is based on I_S
#
CREATE VIEW v1
AS SELECT *
2008-02-27 20:53:54 +01:00
FROM information_schema.tables;
2007-09-28 13:02:43 +02:00
SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS where TABLE_NAME = 'v1';
DROP VIEW v1;
2007-09-28 14:33:30 +02:00
#
# Bug#30795 Query on INFORMATION_SCHEMA.SCHEMATA, wrong result
#
SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA
WHERE SCHEMA_NAME ='information_schema';
2009-02-09 22:00:15 +01:00
2007-10-17 11:08:03 +02:00
#
# Bug#31381 Error in retrieving Data from INFORMATION_SCHEMA
#
SELECT TABLE_COLLATION FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA='mysql' and TABLE_NAME= 'db';
2007-09-28 14:33:30 +02:00
2007-10-23 10:20:51 +02:00
#
# Bug#31633 Information schema = NULL queries crash the server
#
select * from information_schema.columns where table_schema = NULL;
select * from `information_schema`.`COLUMNS` where `TABLE_NAME` = NULL;
select * from `information_schema`.`KEY_COLUMN_USAGE` where `TABLE_SCHEMA` = NULL;
select * from `information_schema`.`KEY_COLUMN_USAGE` where `TABLE_NAME` = NULL;
select * from `information_schema`.`PARTITIONS` where `TABLE_SCHEMA` = NULL;
select * from `information_schema`.`PARTITIONS` where `TABLE_NAME` = NULL;
select * from `information_schema`.`REFERENTIAL_CONSTRAINTS` where `CONSTRAINT_SCHEMA` = NULL;
select * from `information_schema`.`REFERENTIAL_CONSTRAINTS` where `TABLE_NAME` = NULL;
select * from information_schema.schemata where schema_name = NULL;
select * from `information_schema`.`STATISTICS` where `TABLE_SCHEMA` = NULL;
select * from `information_schema`.`STATISTICS` where `TABLE_NAME` = NULL;
select * from information_schema.tables where table_schema = NULL;
select * from information_schema.tables where table_catalog = NULL;
select * from information_schema.tables where table_name = NULL;
select * from `information_schema`.`TABLE_CONSTRAINTS` where `TABLE_SCHEMA` = NULL;
select * from `information_schema`.`TABLE_CONSTRAINTS` where `TABLE_NAME` = NULL;
select * from `information_schema`.`TRIGGERS` where `EVENT_OBJECT_SCHEMA` = NULL;
select * from `information_schema`.`TRIGGERS` where `EVENT_OBJECT_TABLE` = NULL;
select * from `information_schema`.`VIEWS` where `TABLE_SCHEMA` = NULL;
select * from `information_schema`.`VIEWS` where `TABLE_NAME` = NULL;
2007-11-02 09:39:14 +01:00
#
# Bug#31630 debug assert with explain extended select ... from i_s
#
2007-11-06 13:53:02 +01:00
explain extended select 1 from information_schema.tables;
2007-11-02 09:39:14 +01:00
2007-11-30 15:48:22 +01:00
#
# Bug#32775 problems with SHOW EVENTS and Information_Schema
#
use information_schema;
show events;
show events from information_schema;
show events where Db= 'information_schema';
2007-12-04 09:48:11 +01:00
use test;
2007-11-30 15:48:22 +01:00
2008-01-30 16:27:41 +01:00
--echo #
2009-02-09 22:00:15 +01:00
--echo # Bug#34166 Server crash in SHOW OPEN TABLES and prelocking
2008-01-30 16:27:41 +01:00
--echo #
--disable_warnings
drop table if exists t1;
drop function if exists f1;
--enable_warnings
create table t1 (a int);
delimiter |;
create function f1() returns int
begin
insert into t1 (a) values (1);
return 0;
end|
delimiter ;|
--disable_result_log
show open tables where f1()=0;
show open tables where f1()=0;
--enable_result_log
drop table t1;
drop function f1;
2008-03-07 15:41:50 +01:00
#
2009-02-09 22:00:15 +01:00
# Bug#34656 KILL a query = Assertion failed: m_status == DA_ERROR ||
# m_status == DA_OK
2008-03-07 15:41:50 +01:00
#
connect (conn1, localhost, root,,);
connection conn1;
let $ID= `select connection_id()`;
send select * from information_schema.tables where 1=sleep(100000);
connection default;
let $wait_timeout= 10;
let $wait_condition=select count(*)=1 from information_schema.processlist
where state='User sleep' and
info='select * from information_schema.tables where 1=sleep(100000)';
--source include/wait_condition.inc
disable_query_log;
eval kill $ID;
enable_query_log;
disconnect conn1;
let $wait_timeout= 10;
let $wait_condition=select count(*)=0 from information_schema.processlist
where state='User sleep' and
info='select * from information_schema.tables where 1=sleep(100000)';
--source include/wait_condition.inc
connect (conn1, localhost, root,,);
connection conn1;
let $ID= `select connection_id()`;
send select * from information_schema.columns where 1=sleep(100000);
connection default;
let $wait_timeout= 10;
let $wait_condition=select count(*)=1 from information_schema.processlist
where state='User sleep' and
info='select * from information_schema.columns where 1=sleep(100000)';
--source include/wait_condition.inc
disable_query_log;
eval kill $ID;
enable_query_log;
disconnect conn1;
let $wait_timeout= 10;
let $wait_condition=select count(*)=0 from information_schema.processlist
where state='User sleep' and
info='select * from information_schema.columns where 1=sleep(100000)';
--source include/wait_condition.inc
2008-10-09 09:50:29 +02:00
#
# Bug#38918 selecting from information_schema.columns is disproportionately slow
#
explain select count(*) from information_schema.tables;
explain select count(*) from information_schema.columns;
explain select count(*) from information_schema.views;
2008-11-13 13:09:11 +01:00
#
# Bug#39955 SELECT on INFORMATION_SCHEMA.GLOBAL_VARIABLES takes too long
#
set global init_connect="drop table if exists t1;drop table if exists t1;\
drop table if exists t1;drop table if exists t1;\
drop table if exists t1;drop table if exists t1;\
drop table if exists t1;drop table if exists t1;\
drop table if exists t1;drop table if exists t1;\
drop table if exists t1;drop table if exists t1;\
drop table if exists t1;drop table if exists t1;\
drop table if exists t1;drop table if exists t1;\
drop table if exists t1;drop table if exists t1;\
drop table if exists t1;drop table if exists t1;\
drop table if exists t1;drop table if exists t1;\
drop table if exists t1;drop table if exists t1;\
drop table if exists t1;drop table if exists t1;\
drop table if exists t1;drop table if exists t1;\
drop table if exists t1;drop table if exists t1;\
drop table if exists t1;drop table if exists t1;\
drop table if exists t1;drop table if exists t1;\
drop table if exists t1;drop table if exists t1;\
drop table if exists t1;drop table if exists t1;\
drop table if exists t1;drop table if exists t1;\
drop table if exists t1;drop table if exists t1;";
select * from information_schema.global_variables where variable_name='init_connect';
set global init_connect="";
2008-11-17 17:06:03 +01:00
#
2009-02-09 22:00:15 +01:00
# Bug#34517 SHOW GLOBAL STATUS does not work properly in embedded server.
2008-11-17 17:06:03 +01:00
#
create table t0 select * from information_schema.global_status where VARIABLE_NAME='COM_SELECT';
SELECT 1;
select a.VARIABLE_VALUE - b.VARIABLE_VALUE from t0 b, information_schema.global_status a
2009-02-09 22:00:15 +01:00
where a.VARIABLE_NAME = b.VARIABLE_NAME;
2008-11-17 17:06:03 +01:00
drop table t0;
2008-12-10 15:38:27 +01:00
#
# Bug#35275 INFORMATION_SCHEMA.TABLES.CREATE_OPTIONS omits KEY_BLOCK_SIZE
#
CREATE TABLE t1(a INT) KEY_BLOCK_SIZE=1;
SELECT CREATE_OPTIONS FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='t1';
DROP TABLE t1;
2009-03-17 15:29:16 +01:00
#
# Bug #22047: Time in SHOW PROCESSLIST for SQL thread in replication seems
# to become negative
#
SET TIMESTAMP=@@TIMESTAMP + 10000000;
SELECT 'OK' AS TEST_RESULT FROM INFORMATION_SCHEMA.PROCESSLIST WHERE time < 0;
SET TIMESTAMP=DEFAULT;
2010-01-21 16:14:10 +01:00
--echo #
--echo # Bug #50276: Security flaw in INFORMATION_SCHEMA.TABLES
--echo #
CREATE DATABASE db1;
USE db1;
CREATE TABLE t1 (id INT);
CREATE USER nonpriv;
USE test;
connect (nonpriv_con, localhost, nonpriv,,);
connection nonpriv_con;
--echo # connected as nonpriv
--echo # Should return 0
SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='t1';
USE INFORMATION_SCHEMA;
--echo # Should return 0
SELECT COUNT(*) FROM TABLES WHERE TABLE_NAME='t1';
connection default;
--echo # connected as root
disconnect nonpriv_con;
DROP USER nonpriv;
DROP TABLE db1.t1;
DROP DATABASE db1;
2010-06-25 10:01:47 +02:00
--echo
--echo Bug#54422 query with = 'variables'
--echo
CREATE TABLE variables(f1 INT);
SELECT COLUMN_DEFAULT, TABLE_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE INFORMATION_SCHEMA.COLUMNS.TABLE_NAME = 'variables';
DROP TABLE variables;
2010-01-21 16:14:10 +01:00
2006-07-14 23:04:51 +02:00
--echo End of 5.1 tests.
2009-02-09 22:00:15 +01:00
# Wait till all disconnects are completed
--source include/wait_until_count_sessions.inc