1
# Test for data_dictionary.schemas &
5
DROP TABLE IF EXISTS t0,t1,t2,t3,t4,t5;
6
DROP SCHEMA IF EXISTS data_dictionary;
8
CREATE SCHEMA data_dictionary;
11
select count(*) from data_dictionary.SCHEMAS where schema_name > 'm';
13
select count(*) from data_dictionary.schemas;
14
#show databases like 't%';
17
# Test for data_dictionary.tables &
20
create database mysqltest;
21
create table mysqltest.t1(a int, b VARCHAR(30), KEY string_data (b));
22
create table test.t2(a int);
23
create table t3(a int, KEY a_data (a));
24
create table mysqltest.t4(a int);
25
create table t5 (id int auto_increment primary key);
26
insert into t5 values (10);
28
select table_name from data_dictionary.TABLES
29
where table_schema = "mysqltest" and table_name like "t%";
31
#show tables like 't%';
32
--replace_column 8 # 12 # 13 #
34
#show columns from t3 like "a%";
35
select * from data_dictionary.COLUMNS where table_name="t1"
38
connect (user3,localhost,mysqltest_2,,);
40
select table_name, column_name from data_dictionary.columns
41
where table_schema = 'mysqltest' and table_name = 't1';
42
#show columns from mysqltest.t1;
43
connect (user4,localhost,mysqltest_3,,mysqltest);
47
drop tables mysqltest.t4, mysqltest.t1, t2, t3, t5;
48
drop database mysqltest;
50
# Test for data_dictionary.CHARACTER_SETS &
51
select * from data_dictionary.CHARACTER_SETS
52
where CHARACTER_SET_NAME like 'latin1%';
54
# Test for data_dictionary.COLLATIONS &
57
select * from data_dictionary.COLLATIONS
58
where COLLATION_NAME like 'latin1%';
61
# Bug#2719 data_dictionary: errors in "columns"
63
select DATA_TYPE from data_dictionary.columns
64
where table_schema="data_dictionary" and table_name="COLUMNS" and
65
(column_name="character_set_name" or column_name="collation_name");
68
# Bug#2718 data_dictionary: errors in "tables"
70
select TABLE_TYPE from data_dictionary.tables where
71
table_schema="data_dictionary" and table_name="COLUMNS";
72
select table_type from data_dictionary.tables
73
where table_schema="mysql" and table_name="user";
76
# Bug #7215 data_dictionary: columns are longtext instead of varchar
77
# Bug #7217 data_dictionary: columns are varbinary() instead of timestamp
79
select table_schema,table_name, column_name from
80
data_dictionary.columns
81
where DATA_TYPE = 'longtext';
82
select table_name, column_name, DATA_TYPE from data_dictionary.columns
83
where DATA_TYPE = 'datetime';
86
# Bug #8164 subquery with DATA_DICTIONARY.COLUMNS, 100 % CPU
88
SELECT COUNT(*) FROM DATA_DICTIONARY.TABLES A
90
(SELECT * FROM DATA_DICTIONARY.COLUMNS B
91
WHERE A.TABLE_SCHEMA = B.TABLE_SCHEMA
92
AND A.TABLE_NAME = B.TABLE_NAME);
95
# Bug #9344 DATA_DICTIONARY, wrong content, numeric columns
102
x_decimal DECIMAL(5,3),
103
x_numeric NUMERIC(5,3),
106
x_double_precision DOUBLE PRECISION );
107
SELECT COLUMN_NAME, CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH
108
FROM DATA_DICTIONARY.COLUMNS
109
WHERE TABLE_NAME= 't1';
113
# Bug #9404 data_dictionary: Weird error messages
114
# with SELECT SUM() ... GROUP BY queries
116
SELECT table_schema, count(*) FROM data_dictionary.TABLES
117
WHERE table_name NOT LIKE 'ndb_%' AND
118
table_name NOT LIKE 'falcon%' AND
120
GROUP BY TABLE_SCHEMA;
123
# Bug #9434 SHOW CREATE DATABASE data_dictionary;
125
#show create database data_dictionary;
128
# Bug #11057 data_dictionary: columns table has some questionable contents
129
# Bug #12301 data_dictionary: NUMERIC_SCALE must be 0 for integer columns
131
create table t1(f1 LONGBLOB, f2 LONGTEXT);
132
select column_name, DATA_TYPE, CHARACTER_OCTET_LENGTH,
133
CHARACTER_MAXIMUM_LENGTH
134
from data_dictionary.columns
135
where table_name='t1';
137
create table t1(f1 int, f2 int, f3 BIGINT, f4 int,
138
f5 BIGINT, f6 int, f7 int);
139
select column_name, NUMERIC_PRECISION, NUMERIC_SCALE
140
from data_dictionary.columns
141
where table_name='t1';
145
# Bug#12518 COLUMN_DEFAULT has wrong value if NOT NULL is set
147
create table t1 (a int not null, b int);
149
select column_name, column_default from columns
150
where table_schema='test' and table_name='t1';
152
#show columns from t1;
156
# Bug #9846 Inappropriate error displayed while dropping table from
159
--error ER_PARSE_ERROR
160
alter database data_dictionary;
167
# Bug #9683 INFORMATION_SCH: Creation of temporary table allowed in Information_schema DB
171
create temporary table schemas(f1 char(10));
174
# Bug#14089 FROM list subquery always fails when data_dictionary is current database
177
create table t1(id int);
178
insert into t1(id) values (1);
179
select 1 from (select 1 from test.t1) a;
181
select 1 from (select 1 from test.t1) a;
185
# Bug #14387 SHOW COLUMNS doesn't work on temporary tables
186
# Bug #15224 SHOW INDEX from temporary table doesn't work
187
# Bug #12770 DESC cannot display the info. about temporary table
189
create temporary table t1(f1 int, index(f1));
190
#show columns from t1;
192
#show indexes from t1;
196
# Bug#14271 I_S: columns has no size for (var)binary columns
198
create table t1(f1 varbinary(32), f2 varbinary(64));
199
select character_maximum_length, character_octet_length
200
from data_dictionary.columns where table_name='t1';
204
# Bug#15307 GROUP_CONCAT() with ORDER BY returns empty set on data_dictionary
206
select DATA_TYPE, group_concat(table_schema, '.', table_name), count(*) as num
207
from data_dictionary.columns where
208
table_schema='data_dictionary' and
209
(DATA_TYPE = 'varchar' or DATA_TYPE = 'varchar'
210
or DATA_TYPE = 'varchar')
211
group by DATA_TYPE order by DATA_TYPE, num;
214
# Bug#19236 bad COLUMNS.CHARACTER_MAXIMUM_LENGHT and CHARACTER_OCTET_LENGTH
216
create table t1(f1 char(1) not null, f2 char(9) not null);
217
select CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH from
218
data_dictionary.columns where table_schema='test' and table_name = 't1';
222
# Bug#19599 duplication of data_dictionary column value in a CONCAT expr with user var
225
create table t1(f1 char(5));
226
create table t2(f1 char(5));
227
select concat(@a, table_name), @a, table_name
228
from data_dictionary.tables where table_schema = 'test';
232
# Bug#18925: subqueries with MIN/MAX functions on INFORMARTION_SCHEMA
235
SELECT t.table_name, c1.column_name
236
FROM data_dictionary.tables t
238
data_dictionary.columns c1
239
ON t.table_schema = c1.table_schema AND
240
t.table_name = c1.table_name
241
WHERE t.table_schema = 'data_dictionary' AND
242
c1.ordinal_position =
243
( SELECT COALESCE(MIN(c2.ordinal_position),1)
244
FROM data_dictionary.columns c2
245
WHERE c2.table_schema = t.table_schema AND
246
c2.table_name = t.table_name AND
247
c2.column_name LIKE '%SCHEMA%'
249
AND t.table_name NOT LIKE 'falcon%'
250
AND t.ENGINE IS NULL;
251
SELECT t.table_name, c1.column_name
252
FROM data_dictionary.tables t
254
data_dictionary.columns c1
255
ON t.table_schema = c1.table_schema AND
256
t.table_name = c1.table_name
257
WHERE t.table_schema = 'data_dictionary' AND
258
c1.ordinal_position =
259
( SELECT COALESCE(MIN(c2.ordinal_position),1)
260
FROM data_dictionary.columns c2
261
WHERE c2.table_schema = 'data_dictionary' AND
262
c2.table_name = t.table_name AND
263
c2.column_name LIKE '%SCHEMA%'
265
AND t.table_name NOT LIKE 'falcon%'
266
AND t.ENGINE IS NULL;
269
# Bug#21231: query with a simple non-correlated subquery over
270
# INFORMARTION_SCHEMA.TABLES
273
SELECT MAX(table_name) FROM data_dictionary.tables;
274
SELECT table_name from data_dictionary.tables
275
WHERE table_name=(SELECT MAX(table_name)
276
FROM data_dictionary.tables);
278
# Bug#23299 Some queries against DATA_DICTIONARY with subqueries fail
280
create table t1 (f1 int);
281
create table t2 (f1 int, f2 int);
283
select table_name from data_dictionary.tables
284
where table_schema = 'test' and table_name not in
285
(select table_name from data_dictionary.columns
286
where table_schema = 'test' and column_name = 'f3');
291
# Bug#24630 Subselect query crashes mysqld
293
select 1 as f1 from data_dictionary.tables where "CHARACTER_SETS"=
294
(select cast(table_name as char) from data_dictionary.tables
295
order by table_name limit 1) limit 1;
297
select t.table_name, group_concat(t.table_schema, '.', t.table_name),
299
from data_dictionary.tables t
300
inner join data_dictionary.columns c1
301
on t.table_schema = c1.table_schema AND t.table_name = c1.table_name
302
where t.table_schema = 'data_dictionary' AND
303
t.table_name not like 'falcon%' AND
305
c1.ordinal_position =
306
(select isnull(c2.DATA_TYPE) -
307
isnull(group_concat(c2.table_schema, '.', c2.table_name)) +
309
from data_dictionary.columns c2 where
310
c2.table_schema='data_dictionary' and
311
(c2.DATA_TYPE = 'varchar' or c2.DATA_TYPE = 'varchar')
312
group by c2.DATA_TYPE order by num limit 1)
313
group by t.table_name order by num1, t.table_name;
316
# Bug#25859 ALTER DATABASE works w/o parameters
318
--error ER_PARSE_ERROR
320
--error ER_PARSE_ERROR
324
# Bug#27747 database metadata doesn't return sufficient column default info
328
f2 varchar(50) not null,
329
f3 varchar(50) default '',
330
f4 varchar(50) default NULL,
332
f6 bigint not null default 10,
333
f7 datetime not null,
334
f8 datetime default '2006-01-01'
336
select column_default from data_dictionary.columns where table_name= 't1';
337
#show columns from t1;
341
# Bug#30079 A check for "hidden" I_S tables is flawed
344
#show fields from data_dictionary.table_names;
346
#show keys from data_dictionary.table_names;
348
SET max_heap_table_size = DEFAULT;
351
--echo End of 5.0 tests.
354
# Bug#30795 Query on DATA_DICTIONARY.SCHEMAS, wrong result
356
SELECT SCHEMA_NAME FROM DATA_DICTIONARY.SCHEMAS
357
WHERE SCHEMA_NAME ='data_dictionary';
360
# Bug#31381 Error in retrieving Data from DATA_DICTIONARY
362
SELECT TABLE_COLLATION FROM DATA_DICTIONARY.TABLES
363
WHERE TABLE_SCHEMA='mysql' and TABLE_NAME= 'db';
366
# Bug#31633 Information schema = NULL queries crash the server
368
select * from data_dictionary.columns where table_schema = NULL;
369
select * from `data_dictionary`.`COLUMNS` where `TABLE_NAME` = NULL;
370
select * from `data_dictionary`.`INDEXES` where `TABLE_SCHEMA` = NULL;
371
select * from `data_dictionary`.`INDEXES` where `TABLE_NAME` = NULL;
372
#select * from `data_dictionary`.`REFERENTIAL_CONSTRAINTS` where `CONSTRAINT_SCHEMA` = NULL;
373
#select * from `data_dictionary`.`REFERENTIAL_CONSTRAINTS` where `TABLE_NAME` = NULL;
374
select * from data_dictionary.schemas where schema_name = NULL;
375
select * from data_dictionary.tables where table_schema = NULL;
376
select * from data_dictionary.tables where table_name = NULL;
377
#select * from `data_dictionary`.`TABLE_CONSTRAINTS` where `TABLE_SCHEMA` = NULL;
378
#select * from `data_dictionary`.`TABLE_CONSTRAINTS` where `TABLE_NAME` = NULL;
381
--echo # Test that the query is visible to self and others.
384
SELECT info FROM data_dictionary.processlist WHERE id = CONNECTION_ID();
387
# test that SHOW PROCESSLIST works correctly
389
--replace_column 1 # 2 # 3 # 6 # 7 #
393
# do a query on the PROCESSLIST table in I_S to ensure it works correctly
395
#--replace_column 1 # 2 # 3
396
#SELECT info, command, db FROM data_dictionary.processlist WHERE id = CONNECTION_ID();
399
# do a query on the CHARACTER_SET table in I_S
401
SELECT * FROM data_dictionary.character_sets ORDER BY character_set_name;
404
# perform a query on the COLLATIONS table
406
SELECT * FROM data_dictionary.collations ORDER BY collation_name;
409
# perform a query on COLUMNS
411
SELECT table_name, column_name
412
FROM data_dictionary.columns
414
(SELECT table_name FROM data_dictionary.tables
415
WHERE ENGINE IS NULL)
419
# perform a query on REFERENTIAL_CONSTRAINTS
421
#SELECT * FROM data_dictionary.referential_constraints;
424
# query the SCHEMAS table
427
SELECT count(schema_name) FROM data_dictionary.schemas ORDER BY schema_name;
430
# Query the STATUS and VARIABLES related
431
# I_S related tables.
434
SELECT count(*) FROM data_dictionary.session_status ORDER BY variable_name;
437
SELECT count(*) FROM data_dictionary.session_variables ORDER BY variable_name;
440
SELECT count(*) FROM data_dictionary.global_status ORDER BY variable_name;
443
SELECT count(*) FROM data_dictionary.global_variables ORDER BY variable_name;
446
# query TABLE_CONSTRAINTS table
448
#--replace_column 1 #
449
#SELECT count(*) FROM data_dictionary.table_constraints;
454
SELECT table_schema, table_name FROM data_dictionary.tables WHERE ENGINE IS NULL ORDER BY table_name;
457
# do a query on the PLUGINS table in I_S to ensure it works correctly
458
# how do we test for this if the contents of this table can change
459
# depend on what plugins are configured for use?
462
SELECT count(*) FROM data_dictionary.plugins;
465
DROP SCHEMA IF EXISTS data_dictionary;