16
26
create table t5 (id int auto_increment primary key);
17
27
insert into t5 values (10);
20
select table_name from data_dictionary.tables
29
select table_name from information_schema.TABLES
21
30
where table_schema = "mysqltest" and table_name like "t%";
23
select * from data_dictionary.indexes where TABLE_SCHEMA = "mysqltest";
32
select * from information_schema.STATISTICS where TABLE_SCHEMA = "mysqltest";
25
34
show tables like 't%';
26
--replace_column 1 # 6 # 7 # 8 # 9 # 10 #
28
show columns from t3 like "a%";
30
select * from data_dictionary.columns where table_name="t1"
35
--replace_column 8 # 12 # 13 #
37
show full columns from t3 like "a%";
38
select * from information_schema.COLUMNS where table_name="t1"
31
39
and column_name= "a";
33
41
connect (user3,localhost,mysqltest_2,,);
36
select table_name, column_name from data_dictionary.columns
43
select table_name, column_name, privileges from information_schema.columns
37
44
where table_schema = 'mysqltest' and table_name = 't1';
38
45
show columns from mysqltest.t1;
39
46
connect (user4,localhost,mysqltest_3,,mysqltest);
43
50
drop tables mysqltest.t4, mysqltest.t1, t2, t3, t5;
44
51
drop database mysqltest;
53
# Test for information_schema.CHARACTER_SETS &
56
select * from information_schema.CHARACTER_SETS
57
where CHARACTER_SET_NAME like 'latin1%';
59
# Test for information_schema.COLLATIONS &
63
select * from information_schema.COLLATIONS
64
where COLLATION_NAME like 'latin1%';
66
select * from information_schema.COLLATION_CHARACTER_SET_APPLICABILITY
67
where COLLATION_NAME like 'latin1%';
70
# Bug#7213: information_schema: redundant non-standard TABLE_NAMES table
73
select * from information_schema.table_names;
47
76
# Bug#2719 information_schema: errors in "columns"
50
select column_type from data_dictionary.columns
51
where table_schema="data_dictionary" and table_name="COLUMNS" and
78
select column_type from information_schema.columns
79
where table_schema="information_schema" and table_name="COLUMNS" and
52
80
(column_name="character_set_name" or column_name="collation_name");
55
83
# Bug#2718 information_schema: errors in "tables"
59
select count(*) from data_dictionary.tables where
60
table_schema="data_dictionary" and table_name="COLUMNS";
64
select count(*) from data_dictionary.tables
85
select TABLE_ROWS from information_schema.tables where
86
table_schema="information_schema" and table_name="COLUMNS";
87
select table_type from information_schema.tables
65
88
where table_schema="mysql" and table_name="user";
68
91
# Bug #7215 information_schema: columns are longtext instead of varchar
69
92
# Bug #7217 information_schema: columns are varbinary() instead of timestamp
72
select table_schema, table_name, column_name from data_dictionary.columns where data_type = 'longtext';
74
select table_name, column_name, data_type from data_dictionary.columns where data_type = 'datetime';
94
select table_schema,table_name, column_name from
95
information_schema.columns
96
where data_type = 'longtext';
97
select table_name, column_name, data_type from information_schema.columns
98
where data_type = 'datetime';
77
# Bug #8164 subquery with data_dictionary.COLUMNS, 100 % CPU
101
# Bug #8164 subquery with INFORMATION_SCHEMA.COLUMNS, 100 % CPU
80
SELECT COUNT(*) FROM data_dictionary.tables A
103
SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES A
82
(SELECT * FROM data_dictionary.columns B
105
(SELECT * FROM INFORMATION_SCHEMA.COLUMNS B
83
106
WHERE A.TABLE_SCHEMA = B.TABLE_SCHEMA
84
107
AND A.TABLE_NAME = B.TABLE_NAME);
106
128
# Bug #9404 information_schema: Weird error messages
107
129
# with SELECT SUM() ... GROUP BY queries
110
SELECT table_schema, count(*) FROM data_dictionary.tables
131
SELECT table_schema, count(*) FROM information_schema.TABLES
111
132
WHERE table_name NOT LIKE 'ndb_%' AND
112
table_name NOT LIKE 'falcon%'
113
GROUP BY TABLE_SCHEMA ORDER BY table_schema;
133
table_name NOT LIKE 'falcon%' AND
134
table_name NOT LIKE 'MEMCACHED%'
135
GROUP BY TABLE_SCHEMA;
138
# Bug #9434 SHOW CREATE DATABASE information_schema;
140
show create database information_schema;
116
143
# Bug #11057 information_schema: columns table has some questionable contents
117
144
# Bug #12301 information_schema: NUMERIC_SCALE must be 0 for integer columns
119
146
create table t1(f1 LONGBLOB, f2 LONGTEXT);
121
147
select column_name,data_type,CHARACTER_OCTET_LENGTH,
122
148
CHARACTER_MAXIMUM_LENGTH
123
from data_dictionary.columns
149
from information_schema.columns
124
150
where table_name='t1';
126
152
create table t1(f1 int, f2 int, f3 BIGINT, f4 int,
127
153
f5 BIGINT, f6 int, f7 int);
129
154
select column_name, NUMERIC_PRECISION, NUMERIC_SCALE
130
from data_dictionary.columns
155
from information_schema.columns
131
156
where table_name='t1';
135
160
# Bug#12518 COLUMN_DEFAULT has wrong value if NOT NULL is set
137
162
create table t1 (a int not null, b int);
139
select column_name, column_default from data_dictionary.columns
163
use information_schema;
164
select column_name, column_default from columns
140
165
where table_schema='test' and table_name='t1';
142
167
show columns from t1;
171
# Bug #9846 Inappropriate error displayed while dropping table from 'INFORMATION_SCHEMA'
173
--error ER_PARSE_ERROR
174
alter database information_schema;
175
--error ER_DBACCESS_DENIED_ERROR
176
drop database information_schema;
178
drop table information_schema.tables;
180
alter table information_schema.tables;
182
# Bug #9683 INFORMATION_SCH: Creation of temporary table allowed in Information_schema DB
184
use information_schema;
186
create temporary table schemata(f1 char(10));
147
189
# Bug#14089 FROM list subquery always fails when information_schema is current database
150
192
create table t1(id int);
151
193
insert into t1(id) values (1);
153
194
select 1 from (select 1 from test.t1) a;
195
use information_schema;
156
196
select 1 from (select 1 from test.t1) a;
200
# Bug #14387 SHOW COLUMNS doesn't work on temporary tables
201
# Bug #15224 SHOW INDEX from temporary table doesn't work
202
# Bug #12770 DESC cannot display the info. about temporary table
204
create temporary table t1(f1 int, index(f1));
205
show columns from t1;
207
show indexes from t1;
161
211
# Bug#14271 I_S: columns has no size for (var)binary columns
163
213
create table t1(f1 varbinary(32), f2 varbinary(64));
165
214
select character_maximum_length, character_octet_length
166
from data_dictionary.columns where table_name='t1';
215
from information_schema.columns where table_name='t1';
170
## Bug#15307 GROUP_CONCAT() with ORDER BY returns empty set on information_schema
219
# Bug#15307 GROUP_CONCAT() with ORDER BY returns empty set on information_schema
172
221
select column_type, group_concat(table_schema, '.', table_name), count(*) as num
173
from data_dictionary.columns where
174
table_schema='data_dictionary' and
222
from information_schema.columns where
223
table_schema='information_schema' and
175
224
(column_type = 'varchar(7)' or column_type = 'varchar(20)'
176
225
or column_type = 'varchar(27)')
177
group by column_type order by column_type, num;
226
group by column_type order by num;
180
229
# Bug#19236 bad COLUMNS.CHARACTER_MAXIMUM_LENGHT and CHARACTER_OCTET_LENGTH
182
231
create table t1(f1 char(1) not null, f2 char(9) not null);
184
232
select CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH from
185
data_dictionary.columns where table_schema='test' and table_name = 't1';
233
information_schema.columns where table_schema='test' and table_name = 't1';
203
250
SELECT t.table_name, c1.column_name
204
FROM data_dictionary.tables t
251
FROM information_schema.tables t
206
data_dictionary.columns c1
253
information_schema.columns c1
207
254
ON t.table_schema = c1.table_schema AND
208
255
t.table_name = c1.table_name
209
WHERE t.table_schema = 'data_dictionary' AND
256
WHERE t.table_schema = 'information_schema' AND
210
257
c1.ordinal_position =
211
258
( SELECT COALESCE(MIN(c2.ordinal_position),1)
212
FROM data_dictionary.columns c2
259
FROM information_schema.columns c2
213
260
WHERE c2.table_schema = t.table_schema AND
214
261
c2.table_name = t.table_name AND
215
262
c2.column_name LIKE '%SCHEMA%'
217
264
AND t.table_name NOT LIKE 'falcon%'
218
ORDER BY t.table_name, c1.column_name;
265
AND t.table_name NOT LIKE 'MEMCACHED%';
220
266
SELECT t.table_name, c1.column_name
221
FROM data_dictionary.tables t
267
FROM information_schema.tables t
223
data_dictionary.columns c1
269
information_schema.columns c1
224
270
ON t.table_schema = c1.table_schema AND
225
271
t.table_name = c1.table_name
226
WHERE t.table_schema = 'data_dictionary' AND
272
WHERE t.table_schema = 'information_schema' AND
227
273
c1.ordinal_position =
228
274
( SELECT COALESCE(MIN(c2.ordinal_position),1)
229
FROM data_dictionary.columns c2
230
WHERE c2.table_schema = 'data_dictionary' AND
275
FROM information_schema.columns c2
276
WHERE c2.table_schema = 'information_schema' AND
231
277
c2.table_name = t.table_name AND
232
278
c2.column_name LIKE '%SCHEMA%'
234
280
AND t.table_name NOT LIKE 'falcon%'
235
ORDER BY t.table_name, c1.column_name;
281
AND t.table_name NOT LIKE 'MEMCACHED%';
238
284
# Bug#21231: query with a simple non-correlated subquery over
239
285
# INFORMARTION_SCHEMA.TABLES
242
SELECT MAX(table_name) FROM data_dictionary.tables;
243
SELECT table_name from data_dictionary.tables
288
SELECT MAX(table_name) FROM information_schema.tables;
289
SELECT table_name from information_schema.tables
244
290
WHERE table_name=(SELECT MAX(table_name)
245
FROM data_dictionary.tables)
291
FROM information_schema.tables);
248
293
# Bug#23299 Some queries against INFORMATION_SCHEMA with subqueries fail
250
295
create table t1 (f1 int);
251
296
create table t2 (f1 int, f2 int);
253
#select table_name from data_dictionary.tables
254
#where table_schema = 'test' and table_name not in
255
#(select table_name from data_dictionary.columns
256
# where table_schema = 'test' and column_name = 'f3')
257
#ORDER BY table_name;
298
select table_name from information_schema.tables
299
where table_schema = 'test' and table_name not in
300
(select table_name from information_schema.columns
301
where table_schema = 'test' and column_name = 'f3');
259
302
drop table t1,t2;
263
306
# Bug#24630 Subselect query crashes mysqld
266
select 1 as f1 from data_dictionary.tables where "CHARACTER_SETS"=
267
(select cast(table_name as char) from data_dictionary.tables WHERE TABLE_SCHEMA=schema()
268
AND TABLE_NAME = "CHARACTER_SETS"
269
order by table_name limit 1) AND TABLE_SCHEMA=schema() limit 1;
308
select 1 as f1 from information_schema.tables where "CHARACTER_SETS"=
309
(select cast(table_name as char) from information_schema.tables
310
order by table_name limit 1) limit 1;
271
312
select t.table_name, group_concat(t.table_schema, '.', t.table_name),
273
from data_dictionary.tables t
274
inner join data_dictionary.columns c1
314
from information_schema.tables t
315
inner join information_schema.columns c1
275
316
on t.table_schema = c1.table_schema AND t.table_name = c1.table_name
276
where t.table_schema = 'data_dictionary' AND
317
where t.table_schema = 'information_schema' AND
277
318
t.table_name not like 'falcon%' AND
319
t.table_name not like 'MEMCACHED%' AND
278
320
c1.ordinal_position =
279
321
(select isnull(c2.column_type) -
280
322
isnull(group_concat(c2.table_schema, '.', c2.table_name)) +
282
from data_dictionary.columns c2 where
283
c2.table_schema='data_dictionary' and
324
from information_schema.columns c2 where
325
c2.table_schema='information_schema' and
284
326
(c2.column_type = 'varchar(7)' or c2.column_type = 'varchar(20)')
285
327
group by c2.column_type order by num limit 1)
286
328
group by t.table_name order by num1, t.table_name;
306
348
f7 datetime not null,
307
349
f8 datetime default '2006-01-01'
309
#select column_default from data_dictionary.columns where table_name= 't1' ORDER BY column_default;
351
select column_default from information_schema.columns where table_name= 't1';
310
352
show columns from t1;
356
# Bug#30079 A check for "hidden" I_S tables is flawed
359
show fields from information_schema.table_names;
361
show keys from information_schema.table_names;
313
363
SET max_heap_table_size = DEFAULT;
316
366
--echo End of 5.0 tests.
319
# Bug#30795 Query on data_dictionary.schemas, wrong result
369
# Bug#30795 Query on INFORMATION_SCHEMA.SCHEMATA, wrong result
322
SELECT SCHEMA_NAME FROM data_dictionary.schemas
323
WHERE SCHEMA_NAME ='data_dictionary';
371
SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA
372
WHERE SCHEMA_NAME ='information_schema';
326
375
# Bug#31381 Error in retrieving Data from INFORMATION_SCHEMA
329
SELECT TABLE_COLLATION FROM data_dictionary.tables
377
SELECT TABLE_COLLATION FROM INFORMATION_SCHEMA.TABLES
330
378
WHERE TABLE_SCHEMA='mysql' and TABLE_NAME= 'db';
381
# Bug#31633 Information schema = NULL queries crash the server
383
select * from information_schema.columns where table_schema = NULL;
384
select * from `information_schema`.`COLUMNS` where `TABLE_NAME` = NULL;
385
select * from `information_schema`.`KEY_COLUMN_USAGE` where `TABLE_SCHEMA` = NULL;
386
select * from `information_schema`.`KEY_COLUMN_USAGE` where `TABLE_NAME` = NULL;
387
select * from `information_schema`.`REFERENTIAL_CONSTRAINTS` where `CONSTRAINT_SCHEMA` = NULL;
388
select * from `information_schema`.`REFERENTIAL_CONSTRAINTS` where `TABLE_NAME` = NULL;
389
select * from information_schema.schemata where schema_name = NULL;
390
select * from `information_schema`.`STATISTICS` where `TABLE_SCHEMA` = NULL;
391
select * from `information_schema`.`STATISTICS` where `TABLE_NAME` = NULL;
392
select * from information_schema.tables where table_schema = NULL;
393
select * from information_schema.tables where table_catalog = NULL;
394
select * from information_schema.tables where table_name = NULL;
395
select * from `information_schema`.`TABLE_CONSTRAINTS` where `TABLE_SCHEMA` = NULL;
396
select * from `information_schema`.`TABLE_CONSTRAINTS` where `TABLE_NAME` = NULL;
333
399
--echo # Test that the query is visible to self and others.
337
SELECT info FROM data_dictionary.processlist WHERE id = CONNECTION_ID();
402
SELECT info FROM information_schema.processlist WHERE id = CONNECTION_ID();
405
# test that SHOW PROCESSLIST works correctly
407
--replace_column 1 # 2 # 3 # 6 # 7 #
340
411
# do a query on the PROCESSLIST table in I_S to ensure it works correctly
343
413
SELECT info, command, db
344
FROM data_dictionary.processlist
414
FROM information_schema.processlist
345
415
WHERE id = CONNECTION_ID();
418
# do a query on the CHARACTER_SET table in I_S
421
FROM information_schema.character_sets
422
ORDER BY character_set_name;
425
# perform a query on the COLLATIONS table
428
FROM information_schema.collations
429
ORDER BY collation_name;
432
# perform a query on COLLATION_CHARACTER_SET_APPLICABILITY
435
FROM information_schema.collation_character_set_applicability
436
ORDER BY collation_name;
439
# perform a query on COLUMNS
441
SELECT table_name, column_name
442
FROM information_schema.columns
443
WHERE table_name NOT LIKE 'MEMCACHED%'
447
# perform a query on KEY_COLUMN_USAGE
450
FROM information_schema.key_column_usage;
453
# perform a query on REFERENTIAL_CONSTRAINTS
456
FROM information_schema.referential_constraints;
459
# query the SCHEMATA table
461
SELECT catalog_name, schema_name
462
FROM information_schema.schemata
463
ORDER BY schema_name;
466
# Query the STATUS and VARIABLES related
467
# I_S related tables.
469
--replace_column 1 # 2 #
471
FROM information_schema.session_status
472
ORDER BY variable_name;
474
--replace_column 1 # 2 #
477
#--replace_column 1 # 2 #
479
#FROM information_schema.session_variables
480
#ORDER BY variable_name;
482
#--replace_column 1 # 2 #
485
--replace_column 1 # 2 #
487
FROM information_schema.global_status
488
ORDER BY variable_name;
490
#--replace_column 1 # 2 #
492
#FROM information_schema.global_variables
493
#ORDER BY variable_name;
496
# query TABLE_CONSTRAINTS table
499
FROM information_schema.table_constraints;
350
#SELECT table_schema, table_name
351
#FROM data_dictionary.tables
352
#WHERE table_schema="data_dictionary"
353
#ORDER BY table_name;
504
SELECT table_schema, table_name
505
FROM information_schema.tables
506
WHERE table_name NOT LIKE 'MEMCACHED%'
510
# do a query on the PLUGINS table in I_S to ensure it works correctly
511
# how do we test for this if the contents of this table can change
512
# depend on what plugins are configured for use?