1
# Test for data_dictionary.schemas &
5
DROP TABLE IF EXISTS t0,t1,t2,t3,t4,t5;
6
DROP SCHEMA IF EXISTS data_dictionary;
10
select count(*) from data_dictionary.SCHEMAS where schema_name > 'm';
12
select count(*) from data_dictionary.schemas;
13
show databases like 't%';
16
# Test for data_dictionary.tables &
19
create database mysqltest;
20
create table mysqltest.t1(a int, b VARCHAR(30), KEY string_data (b));
21
create table test.t2(a int);
22
create table t3(a int, KEY a_data (a));
23
create table mysqltest.t4(a int);
24
create table t5 (id int auto_increment primary key);
25
insert into t5 values (10);
27
select table_name from data_dictionary.TABLES
28
where table_schema = "mysqltest" and table_name like "t%";
30
show tables like 't%';
31
--replace_column 1 # 6 # 7 # 8 # 9 # 10 #
33
show columns from t3 like "a%";
34
select * from data_dictionary.COLUMNS where table_name="t1"
37
connect (user3,localhost,mysqltest_2,,);
39
select table_name, column_name from data_dictionary.columns
40
where table_schema = 'mysqltest' and table_name = 't1';
41
show columns from mysqltest.t1;
42
connect (user4,localhost,mysqltest_3,,mysqltest);
46
drop tables mysqltest.t4, mysqltest.t1, t2, t3, t5;
47
drop database mysqltest;
49
# Test for data_dictionary.CHARACTER_SETS &
50
select * from data_dictionary.CHARACTER_SETS
51
where CHARACTER_SET_NAME like 'latin1%';
53
# Test for data_dictionary.COLLATIONS &
56
select * from data_dictionary.COLLATIONS
57
where COLLATION_NAME like 'latin1%';
60
# Bug#2719 data_dictionary: errors in "columns"
62
select DATA_TYPE from data_dictionary.columns
63
where table_schema="data_dictionary" and table_name="COLUMNS" and
64
(column_name="character_set_name" or column_name="collation_name");
67
# Bug#2718 data_dictionary: errors in "tables"
69
select TABLE_TYPE from data_dictionary.tables where
70
table_schema="data_dictionary" and table_name="COLUMNS";
71
select table_type from data_dictionary.tables
72
where table_schema="mysql" and table_name="user";
75
# Bug #7215 data_dictionary: columns are longtext instead of varchar
76
# Bug #7217 data_dictionary: columns are varbinary() instead of timestamp
78
select table_schema,table_name, column_name from
79
data_dictionary.columns
80
where DATA_TYPE = 'longtext';
81
select table_name, column_name, DATA_TYPE from data_dictionary.columns
82
where DATA_TYPE = 'datetime';
85
# Bug #8164 subquery with DATA_DICTIONARY.COLUMNS, 100 % CPU
87
SELECT COUNT(*) FROM DATA_DICTIONARY.TABLES A
89
(SELECT * FROM DATA_DICTIONARY.COLUMNS B
90
WHERE A.TABLE_SCHEMA = B.TABLE_SCHEMA
91
AND A.TABLE_NAME = B.TABLE_NAME);
94
# Bug #9344 DATA_DICTIONARY, wrong content, numeric columns
101
x_decimal DECIMAL(5,3),
102
x_numeric NUMERIC(5,3),
105
x_double_precision DOUBLE PRECISION );
106
SELECT COLUMN_NAME, CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH
107
FROM DATA_DICTIONARY.COLUMNS
108
WHERE TABLE_NAME= 't1';
112
# Bug #9404 data_dictionary: Weird error messages
113
# with SELECT SUM() ... GROUP BY queries
115
SELECT table_schema, count(*) FROM data_dictionary.TABLES
116
WHERE table_name NOT LIKE 'ndb_%' AND
117
table_name NOT LIKE 'falcon%' AND
119
GROUP BY TABLE_SCHEMA;
122
# Bug #9434 SHOW CREATE DATABASE data_dictionary;
124
#show create database data_dictionary;
127
# Bug #11057 data_dictionary: columns table has some questionable contents
128
# Bug #12301 data_dictionary: NUMERIC_SCALE must be 0 for integer columns
130
create table t1(f1 LONGBLOB, f2 LONGTEXT);
131
select column_name, DATA_TYPE, CHARACTER_OCTET_LENGTH,
132
CHARACTER_MAXIMUM_LENGTH
133
from data_dictionary.columns
134
where table_name='t1';
136
create table t1(f1 int, f2 int, f3 BIGINT, f4 int,
137
f5 BIGINT, f6 int, f7 int);
138
select column_name, NUMERIC_PRECISION, NUMERIC_SCALE
139
from data_dictionary.columns
140
where table_name='t1';
144
# Bug#12518 COLUMN_DEFAULT has wrong value if NOT NULL is set
146
create table t1 (a int not null, b int);
148
select column_name, column_default from columns
149
where table_schema='test' and table_name='t1';
151
show columns from t1;
155
# Bug #9846 Inappropriate error displayed while dropping table from
158
--error ER_PARSE_ERROR
159
alter database data_dictionary;
166
# Bug #9683 INFORMATION_SCH: Creation of temporary table allowed in Information_schema DB
170
create temporary table schemas(f1 char(10));
173
# Bug#14089 FROM list subquery always fails when data_dictionary is current database
176
create table t1(id int);
177
insert into t1(id) values (1);
178
select 1 from (select 1 from test.t1) a;
180
select 1 from (select 1 from test.t1) a;
184
# Bug #14387 SHOW COLUMNS doesn't work on temporary tables
185
# Bug #15224 SHOW INDEX from temporary table doesn't work
186
# Bug #12770 DESC cannot display the info. about temporary table
188
create temporary table t1(f1 int, index(f1));
189
show columns from t1;
191
show indexes from t1;
195
# Bug#14271 I_S: columns has no size for (var)binary columns
197
create table t1(f1 varbinary(32), f2 varbinary(64));
198
select character_maximum_length, character_octet_length
199
from data_dictionary.columns where table_name='t1';
203
# Bug#15307 GROUP_CONCAT() with ORDER BY returns empty set on data_dictionary
205
select DATA_TYPE, group_concat(table_schema, '.', table_name), count(*) as num
206
from data_dictionary.columns where
207
table_schema='data_dictionary' and
208
(DATA_TYPE = 'varchar' or DATA_TYPE = 'varchar'
209
or DATA_TYPE = 'varchar')
210
group by DATA_TYPE order by DATA_TYPE, num;
213
# Bug#19236 bad COLUMNS.CHARACTER_MAXIMUM_LENGHT and CHARACTER_OCTET_LENGTH
215
create table t1(f1 char(1) not null, f2 char(9) not null);
216
select CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH from
217
data_dictionary.columns where table_schema='test' and table_name = 't1';
221
# Bug#19599 duplication of data_dictionary column value in a CONCAT expr with user var
224
create table t1(f1 char(5));
225
create table t2(f1 char(5));
226
select concat(@a, table_name), @a, table_name
227
from data_dictionary.tables where table_schema = 'test';
231
# Bug#18925: subqueries with MIN/MAX functions on INFORMARTION_SCHEMA
234
SELECT t.table_name, c1.column_name
235
FROM data_dictionary.tables t
237
data_dictionary.columns c1
238
ON t.table_schema = c1.table_schema AND
239
t.table_name = c1.table_name
240
WHERE t.table_schema = 'data_dictionary' AND
241
c1.ordinal_position =
242
( SELECT COALESCE(MIN(c2.ordinal_position),1)
243
FROM data_dictionary.columns c2
244
WHERE c2.table_schema = t.table_schema AND
245
c2.table_name = t.table_name AND
246
c2.column_name LIKE '%SCHEMA%'
248
AND t.table_name NOT LIKE 'falcon%'
249
AND t.ENGINE IS NULL;
250
SELECT t.table_name, c1.column_name
251
FROM data_dictionary.tables t
253
data_dictionary.columns c1
254
ON t.table_schema = c1.table_schema AND
255
t.table_name = c1.table_name
256
WHERE t.table_schema = 'data_dictionary' AND
257
c1.ordinal_position =
258
( SELECT COALESCE(MIN(c2.ordinal_position),1)
259
FROM data_dictionary.columns c2
260
WHERE c2.table_schema = 'data_dictionary' AND
261
c2.table_name = t.table_name AND
262
c2.column_name LIKE '%SCHEMA%'
264
AND t.table_name NOT LIKE 'falcon%'
265
AND t.ENGINE IS NULL;
268
# Bug#21231: query with a simple non-correlated subquery over
269
# INFORMARTION_SCHEMA.TABLES
272
SELECT MAX(table_name) FROM data_dictionary.tables;
273
SELECT table_name from data_dictionary.tables
274
WHERE table_name=(SELECT MAX(table_name)
275
FROM data_dictionary.tables);
277
# Bug#23299 Some queries against DATA_DICTIONARY with subqueries fail
279
create table t1 (f1 int);
280
create table t2 (f1 int, f2 int);
282
select table_name from data_dictionary.tables
283
where table_schema = 'test' and table_name not in
284
(select table_name from data_dictionary.columns
285
where table_schema = 'test' and column_name = 'f3');
290
# Bug#24630 Subselect query crashes mysqld
292
select 1 as f1 from data_dictionary.tables where "CHARACTER_SETS"=
293
(select cast(table_name as char) from data_dictionary.tables
294
order by table_name limit 1) limit 1;
296
select t.table_name, group_concat(t.table_schema, '.', t.table_name),
298
from data_dictionary.tables t
299
inner join data_dictionary.columns c1
300
on t.table_schema = c1.table_schema AND t.table_name = c1.table_name
301
where t.table_schema = 'data_dictionary' AND
302
t.table_name not like 'falcon%' AND
304
c1.ordinal_position =
305
(select isnull(c2.DATA_TYPE) -
306
isnull(group_concat(c2.table_schema, '.', c2.table_name)) +
308
from data_dictionary.columns c2 where
309
c2.table_schema='data_dictionary' and
310
(c2.DATA_TYPE = 'varchar' or c2.DATA_TYPE = 'varchar')
311
group by c2.DATA_TYPE order by num limit 1)
312
group by t.table_name order by num1, t.table_name;
315
# Bug#25859 ALTER DATABASE works w/o parameters
317
--error ER_PARSE_ERROR
319
--error ER_PARSE_ERROR
323
# Bug#27747 database metadata doesn't return sufficient column default info
327
f2 varchar(50) not null,
328
f3 varchar(50) default '',
329
f4 varchar(50) default NULL,
331
f6 bigint not null default 10,
332
f7 datetime not null,
333
f8 datetime default '2006-01-01'
335
select column_default from data_dictionary.columns where table_name= 't1';
336
show columns from t1;
340
# Bug#30079 A check for "hidden" I_S tables is flawed
343
#show fields from data_dictionary.table_names;
345
#show keys from data_dictionary.table_names;
347
SET max_heap_table_size = DEFAULT;
350
--echo End of 5.0 tests.
353
# Bug#30795 Query on DATA_DICTIONARY.SCHEMAS, wrong result
355
SELECT SCHEMA_NAME FROM DATA_DICTIONARY.SCHEMAS
356
WHERE SCHEMA_NAME ='data_dictionary';
359
# Bug#31381 Error in retrieving Data from DATA_DICTIONARY
361
SELECT TABLE_COLLATION FROM DATA_DICTIONARY.TABLES
362
WHERE TABLE_SCHEMA='mysql' and TABLE_NAME= 'db';
365
# Bug#31633 Information schema = NULL queries crash the server
367
select * from data_dictionary.columns where table_schema = NULL;
368
select * from `data_dictionary`.`COLUMNS` where `TABLE_NAME` = NULL;
369
select * from `data_dictionary`.`INDEXES` where `TABLE_SCHEMA` = NULL;
370
select * from `data_dictionary`.`INDEXES` where `TABLE_NAME` = NULL;
371
#select * from `data_dictionary`.`REFERENTIAL_CONSTRAINTS` where `CONSTRAINT_SCHEMA` = NULL;
372
#select * from `data_dictionary`.`REFERENTIAL_CONSTRAINTS` where `TABLE_NAME` = NULL;
373
select * from data_dictionary.schemas where schema_name = NULL;
374
select * from data_dictionary.tables where table_schema = NULL;
375
select * from data_dictionary.tables where table_name = NULL;
376
#select * from `data_dictionary`.`TABLE_CONSTRAINTS` where `TABLE_SCHEMA` = NULL;
377
#select * from `data_dictionary`.`TABLE_CONSTRAINTS` where `TABLE_NAME` = NULL;
380
--echo # Test that the query is visible to self and others.
383
SELECT info FROM data_dictionary.processlist WHERE id = CONNECTION_ID();
386
# test that SHOW PROCESSLIST works correctly
388
--replace_column 1 # 2 # 3 # 6 # 7 #
392
# do a query on the PROCESSLIST table in I_S to ensure it works correctly
394
#--replace_column 1 # 2 # 3
395
#SELECT info, command, db FROM data_dictionary.processlist WHERE id = CONNECTION_ID();
398
# do a query on the CHARACTER_SET table in I_S
400
SELECT * FROM data_dictionary.character_sets ORDER BY character_set_name;
403
# perform a query on the COLLATIONS table
405
SELECT * FROM data_dictionary.collations ORDER BY collation_name;
408
# perform a query on COLUMNS
410
SELECT table_name, column_name
411
FROM data_dictionary.columns
413
(SELECT table_name FROM data_dictionary.tables
414
WHERE ENGINE IS NULL)
418
# perform a query on REFERENTIAL_CONSTRAINTS
420
#SELECT * FROM data_dictionary.referential_constraints;
423
# query the SCHEMAS table
426
SELECT count(schema_name) FROM data_dictionary.schemas ORDER BY schema_name;
429
# Query the STATUS and VARIABLES related
430
# I_S related tables.
433
SELECT count(*) FROM data_dictionary.session_status ORDER BY variable_name;
436
SELECT count(*) FROM data_dictionary.session_variables ORDER BY variable_name;
439
SELECT count(*) FROM data_dictionary.global_status ORDER BY variable_name;
442
SELECT count(*) FROM data_dictionary.global_variables ORDER BY variable_name;
445
# query TABLE_CONSTRAINTS table
447
#--replace_column 1 #
448
#SELECT count(*) FROM data_dictionary.table_constraints;
453
SELECT table_schema, table_name FROM data_dictionary.tables WHERE ENGINE IS NULL ORDER BY table_name;
456
# do a query on the PLUGINS table in I_S to ensure it works correctly
457
# how do we test for this if the contents of this table can change
458
# depend on what plugins are configured for use?
461
SELECT count(*) FROM data_dictionary.plugins;