1
# check that CSV engine was compiled in, as the result of the test depends
2
# on the presence of the log tables (which are CSV-based).
3
--source include/have_csv.inc
5
# Test for information_schema.schemata &
1
# Test for data_dictionary.schemas &
9
5
DROP TABLE IF EXISTS t0,t1,t2,t3,t4,t5;
13
show variables where variable_name like "skip_show_database";
16
select * from information_schema.SCHEMATA where schema_name > 'm';
17
select schema_name from information_schema.schemata;
18
show databases like 't%';
20
show databases where `database` = 't%';
22
# Test for information_schema.tables &
8
# Test for data_dictionary.tables &
25
11
create database mysqltest;
30
16
create table t5 (id int auto_increment primary key);
31
17
insert into t5 values (10);
33
select table_name from information_schema.TABLES
19
select table_name from data_dictionary.tables
34
20
where table_schema = "mysqltest" and table_name like "t%";
36
select * from information_schema.STATISTICS where TABLE_SCHEMA = "mysqltest";
37
show keys from t3 where Key_name = "a_data";
22
select * from data_dictionary.indexes where TABLE_SCHEMA = "mysqltest";
39
24
show tables like 't%';
40
--replace_column 8 # 12 # 13 #
25
--replace_column 1 # 6 # 7 # 8 # 9 # 10 #
42
show full columns from t3 like "a%";
43
select * from information_schema.COLUMNS where table_name="t1"
27
show columns from t3 like "a%";
28
select * from data_dictionary.columns where table_name="t1"
44
29
and column_name= "a";
45
show columns from mysqltest.t1 where field like "%a%";
47
31
connect (user3,localhost,mysqltest_2,,);
49
select table_name, column_name, privileges from information_schema.columns
33
select table_name, column_name from data_dictionary.columns
50
34
where table_schema = 'mysqltest' and table_name = 't1';
51
35
show columns from mysqltest.t1;
52
36
connect (user4,localhost,mysqltest_3,,mysqltest);
56
40
drop tables mysqltest.t4, mysqltest.t1, t2, t3, t5;
57
41
drop database mysqltest;
59
# Test for information_schema.CHARACTER_SETS &
62
select * from information_schema.CHARACTER_SETS
63
where CHARACTER_SET_NAME like 'latin1%';
64
SHOW CHARACTER SET LIKE 'latin1%';
65
SHOW CHARACTER SET WHERE charset like 'latin1%';
67
# Test for information_schema.COLLATIONS &
71
select * from information_schema.COLLATIONS
72
where COLLATION_NAME like 'latin1%';
74
SHOW COLLATION LIKE 'latin1%';
76
SHOW COLLATION WHERE collation like 'latin1%';
78
select * from information_schema.COLLATION_CHARACTER_SET_APPLICABILITY
79
where COLLATION_NAME like 'latin1%';
82
# Bug#7213: information_schema: redundant non-standard TABLE_NAMES table
85
select * from information_schema.table_names;
88
44
# Bug#2719 information_schema: errors in "columns"
90
select column_type from information_schema.columns
91
where table_schema="information_schema" and table_name="COLUMNS" and
46
select column_type from data_dictionary.columns
47
where table_schema="data_dictionary" and table_name="COLUMNS" and
92
48
(column_name="character_set_name" or column_name="collation_name");
95
51
# Bug#2718 information_schema: errors in "tables"
97
select TABLE_ROWS from information_schema.tables where
98
table_schema="information_schema" and table_name="COLUMNS";
99
select table_type from information_schema.tables
54
select count(*) from data_dictionary.tables where
55
table_schema="data_dictionary" and table_name="COLUMNS";
58
select count(*) from data_dictionary.tables
100
59
where table_schema="mysql" and table_name="user";
102
# test for 'show open tables ... where'
103
show open tables where `table` like "user";
104
# test for 'show status ... where'
105
show status where variable_name like "%database%";
106
# test for 'show variables ... where'
107
show variables where variable_name like "skip_show_databas";
110
# Bug #7981:SHOW GLOBAL STATUS crashes server
112
# We don't actually care about the value, just that it doesn't crash.
114
show global status like "Threads_running";
117
62
# Bug #7215 information_schema: columns are longtext instead of varchar
118
63
# Bug #7217 information_schema: columns are varbinary() instead of timestamp
120
select table_schema,table_name, column_name from
121
information_schema.columns
122
where data_type = 'longtext';
123
select table_name, column_name, data_type from information_schema.columns
124
where data_type = 'datetime';
65
select table_schema, table_name, column_name from data_dictionary.columns where data_type = 'longtext';
66
select table_name, column_name, data_type from data_dictionary.columns where data_type = 'datetime';
127
# Bug #8164 subquery with INFORMATION_SCHEMA.COLUMNS, 100 % CPU
69
# Bug #8164 subquery with data_dictionary.COLUMNS, 100 % CPU
129
SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES A
71
SELECT COUNT(*) FROM data_dictionary.tables A
131
(SELECT * FROM INFORMATION_SCHEMA.COLUMNS B
73
(SELECT * FROM data_dictionary.columns B
132
74
WHERE A.TABLE_SCHEMA = B.TABLE_SCHEMA
133
75
AND A.TABLE_NAME = B.TABLE_NAME);
169
108
create table t1(f1 LONGBLOB, f2 LONGTEXT);
170
109
select column_name,data_type,CHARACTER_OCTET_LENGTH,
171
110
CHARACTER_MAXIMUM_LENGTH
172
from information_schema.columns
111
from data_dictionary.columns
173
112
where table_name='t1';
175
create table t1(f1 tinyint, f2 SMALLINT, f3 BIGINT, f4 int,
176
f5 BIGINT, f6 TINYINT, f7 SMALLINT);
114
create table t1(f1 int, f2 int, f3 BIGINT, f4 int,
115
f5 BIGINT, f6 int, f7 int);
177
116
select column_name, NUMERIC_PRECISION, NUMERIC_SCALE
178
from information_schema.columns
117
from data_dictionary.columns
179
118
where table_name='t1';
183
122
# Bug#12518 COLUMN_DEFAULT has wrong value if NOT NULL is set
185
124
create table t1 (a int not null, b int);
186
use information_schema;
187
select column_name, column_default from columns
125
select column_name, column_default from data_dictionary.columns
188
126
where table_schema='test' and table_name='t1';
190
128
show columns from t1;
194
# Bug #12636: SHOW TABLE STATUS with where condition containing a subquery
195
# over information schema
198
CREATE TABLE t1 (a int);
199
CREATE TABLE t2 (b int);
201
--replace_column 8 # 12 # 13 #
202
SHOW TABLE STATUS FROM test
203
WHERE name IN ( SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES
204
WHERE TABLE_SCHEMA='test' AND TABLE_TYPE='BASE TABLE');
209
# Bug #9846 Inappropriate error displayed while dropping table from 'INFORMATION_SCHEMA'
211
--error ER_PARSE_ERROR
212
alter database information_schema;
213
--error ER_DBACCESS_DENIED_ERROR
214
drop database information_schema;
216
drop table information_schema.tables;
218
alter table information_schema.tables;
220
# Bug #9683 INFORMATION_SCH: Creation of temporary table allowed in Information_schema DB
222
use information_schema;
224
create temporary table schemata(f1 char(10));
227
133
# Bug#14089 FROM list subquery always fails when information_schema is current database
230
136
create table t1(id int);
231
137
insert into t1(id) values (1);
232
138
select 1 from (select 1 from test.t1) a;
233
use information_schema;
234
140
select 1 from (select 1 from test.t1) a;
238
# Bug #14387 SHOW COLUMNS doesn't work on temporary tables
239
# Bug #15224 SHOW INDEX from temporary table doesn't work
240
# Bug #12770 DESC cannot display the info. about temporary table
242
create temporary table t1(f1 int, index(f1));
243
show columns from t1;
245
show indexes from t1;
249
145
# Bug#14271 I_S: columns has no size for (var)binary columns
251
147
create table t1(f1 varbinary(32), f2 varbinary(64));
252
148
select character_maximum_length, character_octet_length
253
from information_schema.columns where table_name='t1';
149
from data_dictionary.columns where table_name='t1';
257
# Bug#15307 GROUP_CONCAT() with ORDER BY returns empty set on information_schema
153
## Bug#15307 GROUP_CONCAT() with ORDER BY returns empty set on information_schema
259
155
select column_type, group_concat(table_schema, '.', table_name), count(*) as num
260
from information_schema.columns where
261
table_schema='information_schema' and
156
from data_dictionary.columns where
157
table_schema='data_dictionary' and
262
158
(column_type = 'varchar(7)' or column_type = 'varchar(20)'
263
159
or column_type = 'varchar(27)')
264
group by column_type order by num;
160
group by column_type order by column_type, num;
267
163
# Bug#19236 bad COLUMNS.CHARACTER_MAXIMUM_LENGHT and CHARACTER_OCTET_LENGTH
269
create table t1(f1 char(1) not null, f2 char(9) not null)
270
default character set utf8;
165
create table t1(f1 char(1) not null, f2 char(9) not null);
271
166
select CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH from
272
information_schema.columns where table_schema='test' and table_name = 't1';
167
data_dictionary.columns where table_schema='test' and table_name = 't1';
289
184
SELECT t.table_name, c1.column_name
290
FROM information_schema.tables t
185
FROM data_dictionary.tables t
292
information_schema.columns c1
187
data_dictionary.columns c1
293
188
ON t.table_schema = c1.table_schema AND
294
189
t.table_name = c1.table_name
295
WHERE t.table_schema = 'information_schema' AND
190
WHERE t.table_schema = 'data_dictionary' AND
296
191
c1.ordinal_position =
297
192
( SELECT COALESCE(MIN(c2.ordinal_position),1)
298
FROM information_schema.columns c2
193
FROM data_dictionary.columns c2
299
194
WHERE c2.table_schema = t.table_schema AND
300
195
c2.table_name = t.table_name AND
301
196
c2.column_name LIKE '%SCHEMA%'
303
AND t.table_name NOT LIKE 'falcon%';
198
AND t.table_name NOT LIKE 'falcon%'
199
ORDER BY t.table_name, c1.column_name;
304
201
SELECT t.table_name, c1.column_name
305
FROM information_schema.tables t
202
FROM data_dictionary.tables t
307
information_schema.columns c1
204
data_dictionary.columns c1
308
205
ON t.table_schema = c1.table_schema AND
309
206
t.table_name = c1.table_name
310
WHERE t.table_schema = 'information_schema' AND
207
WHERE t.table_schema = 'data_dictionary' AND
311
208
c1.ordinal_position =
312
209
( SELECT COALESCE(MIN(c2.ordinal_position),1)
313
FROM information_schema.columns c2
314
WHERE c2.table_schema = 'information_schema' AND
210
FROM data_dictionary.columns c2
211
WHERE c2.table_schema = 'data_dictionary' AND
315
212
c2.table_name = t.table_name AND
316
213
c2.column_name LIKE '%SCHEMA%'
318
AND t.table_name NOT LIKE 'falcon%';
215
AND t.table_name NOT LIKE 'falcon%'
216
ORDER BY t.table_name, c1.column_name;
321
219
# Bug#21231: query with a simple non-correlated subquery over
322
220
# INFORMARTION_SCHEMA.TABLES
325
SELECT MAX(table_name) FROM information_schema.tables;
326
SELECT table_name from information_schema.tables
223
SELECT MAX(table_name) FROM data_dictionary.tables;
224
SELECT table_name from data_dictionary.tables
327
225
WHERE table_name=(SELECT MAX(table_name)
328
FROM information_schema.tables);
226
FROM data_dictionary.tables)
330
229
# Bug#23299 Some queries against INFORMATION_SCHEMA with subqueries fail
332
231
create table t1 (f1 int);
333
232
create table t2 (f1 int, f2 int);
335
select table_name from information_schema.tables
336
where table_schema = 'test' and table_name not in
337
(select table_name from information_schema.columns
338
where table_schema = 'test' and column_name = 'f3');
234
#select table_name from data_dictionary.tables
235
#where table_schema = 'test' and table_name not in
236
#(select table_name from data_dictionary.columns
237
# where table_schema = 'test' and column_name = 'f3')
238
#ORDER BY table_name;
339
240
drop table t1,t2;
343
244
# Bug#24630 Subselect query crashes mysqld
345
select 1 as f1 from information_schema.tables where "CHARACTER_SETS"=
346
(select cast(table_name as char) from information_schema.tables
246
select 1 as f1 from data_dictionary.tables where "CHARACTER_SETS"=
247
(select cast(table_name as char) from data_dictionary.tables
347
248
order by table_name limit 1) limit 1;
349
250
select t.table_name, group_concat(t.table_schema, '.', t.table_name),
351
from information_schema.tables t
352
inner join information_schema.columns c1
252
from data_dictionary.tables t
253
inner join data_dictionary.columns c1
353
254
on t.table_schema = c1.table_schema AND t.table_name = c1.table_name
354
where t.table_schema = 'information_schema' AND
255
where t.table_schema = 'data_dictionary' AND
355
256
t.table_name not like 'falcon%' AND
356
257
c1.ordinal_position =
357
258
(select isnull(c2.column_type) -
358
259
isnull(group_concat(c2.table_schema, '.', c2.table_name)) +
360
from information_schema.columns c2 where
361
c2.table_schema='information_schema' and
261
from data_dictionary.columns c2 where
262
c2.table_schema='data_dictionary' and
362
263
(c2.column_type = 'varchar(7)' or c2.column_type = 'varchar(20)')
363
264
group by c2.column_type order by num limit 1)
364
265
group by t.table_name order by num1, t.table_name;
384
285
f7 datetime not null,
385
286
f8 datetime default '2006-01-01'
387
select column_default from information_schema.columns where table_name= 't1';
288
#select column_default from data_dictionary.columns where table_name= 't1' ORDER BY column_default;
388
289
show columns from t1;
392
# Bug#30079 A check for "hidden" I_S tables is flawed
395
show fields from information_schema.table_names;
397
show keys from information_schema.table_names;
399
292
SET max_heap_table_size = DEFAULT;
402
295
--echo End of 5.0 tests.
405
# Bug#30795 Query on INFORMATION_SCHEMA.SCHEMATA, wrong result
298
# Bug#30795 Query on data_dictionary.schemas, wrong result
407
SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA
408
WHERE SCHEMA_NAME ='information_schema';
300
SELECT SCHEMA_NAME FROM data_dictionary.schemas
301
WHERE SCHEMA_NAME ='data_dictionary';
411
304
# Bug#31381 Error in retrieving Data from INFORMATION_SCHEMA
413
SELECT TABLE_COLLATION FROM INFORMATION_SCHEMA.TABLES
306
SELECT TABLE_COLLATION FROM data_dictionary.tables
414
307
WHERE TABLE_SCHEMA='mysql' and TABLE_NAME= 'db';
417
# Bug#31633 Information schema = NULL queries crash the server
419
select * from information_schema.columns where table_schema = NULL;
420
select * from `information_schema`.`COLUMNS` where `TABLE_NAME` = NULL;
421
select * from `information_schema`.`KEY_COLUMN_USAGE` where `TABLE_SCHEMA` = NULL;
422
select * from `information_schema`.`KEY_COLUMN_USAGE` where `TABLE_NAME` = NULL;
423
select * from `information_schema`.`REFERENTIAL_CONSTRAINTS` where `CONSTRAINT_SCHEMA` = NULL;
424
select * from `information_schema`.`REFERENTIAL_CONSTRAINTS` where `TABLE_NAME` = NULL;
425
select * from information_schema.schemata where schema_name = NULL;
426
select * from `information_schema`.`STATISTICS` where `TABLE_SCHEMA` = NULL;
427
select * from `information_schema`.`STATISTICS` where `TABLE_NAME` = NULL;
428
select * from information_schema.tables where table_schema = NULL;
429
select * from information_schema.tables where table_catalog = NULL;
430
select * from information_schema.tables where table_name = NULL;
431
select * from `information_schema`.`TABLE_CONSTRAINTS` where `TABLE_SCHEMA` = NULL;
432
select * from `information_schema`.`TABLE_CONSTRAINTS` where `TABLE_NAME` = NULL;
310
--echo # Test that the query is visible to self and others.
313
SELECT info FROM data_dictionary.processlist WHERE id = CONNECTION_ID();
316
# do a query on the PROCESSLIST table in I_S to ensure it works correctly
318
SELECT info, command, db
319
FROM data_dictionary.processlist
320
WHERE id = CONNECTION_ID();
325
#SELECT table_schema, table_name
326
#FROM data_dictionary.tables
327
#WHERE table_schema="data_dictionary"
328
#ORDER BY table_name;