~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/information_schema.test

  • Committer: Monty Taylor
  • Date: 2010-03-11 18:27:20 UTC
  • mfrom: (1333 staging)
  • mto: This revision was merged to the branch mainline in revision 1348.
  • Revision ID: mordred@inaugust.com-20100311182720-hd1h87y6cb1b1mp0
Merged trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Test for information_schema.schemata &
 
1
# Test for data_dictionary.schemas &
2
2
# show databases
3
3
 
4
4
--disable_warnings
5
5
DROP TABLE IF EXISTS t0,t1,t2,t3,t4,t5;
 
6
DROP SCHEMA IF EXISTS data_dictionary;
6
7
--enable_warnings
7
8
 
8
 
 
9
 
select * from information_schema.SCHEMATA where schema_name > 'm';
10
 
select schema_name from information_schema.schemata;
11
 
show databases like 't%';
12
 
show databases;
13
 
 
14
 
# Test for information_schema.tables &
 
9
# Test for data_dictionary.tables &
15
10
# show tables
16
11
 
17
12
create database mysqltest;
22
17
create table t5 (id int auto_increment primary key);
23
18
insert into t5 values (10);
24
19
 
25
 
select table_name from information_schema.TABLES
 
20
select table_name from data_dictionary.tables
26
21
where table_schema = "mysqltest" and table_name like "t%";
27
22
 
28
 
select * from information_schema.STATISTICS where TABLE_SCHEMA = "mysqltest";
 
23
select * from data_dictionary.indexes where TABLE_SCHEMA = "mysqltest";
29
24
 
30
25
show tables like 't%';
31
 
--replace_column 8 # 12 # 13 #
32
 
#show table status;
33
 
show full columns from t3 like "a%";
34
 
select * from information_schema.COLUMNS where table_name="t1"
 
26
--replace_column 1 #  6 # 7 # 8 # 9 # 10 #
 
27
show table status;
 
28
show columns from t3 like "a%";
 
29
select * from data_dictionary.columns where table_name="t1"
35
30
and column_name= "a";
36
31
 
37
32
connect (user3,localhost,mysqltest_2,,);
38
33
connection user3;
39
 
select table_name, column_name, privileges from information_schema.columns 
 
34
select table_name, column_name from data_dictionary.columns 
40
35
where table_schema = 'mysqltest' and table_name = 't1';
41
36
show columns from mysqltest.t1;
42
37
connect (user4,localhost,mysqltest_3,,mysqltest);
46
41
drop tables mysqltest.t4, mysqltest.t1, t2, t3, t5;
47
42
drop database mysqltest;
48
43
 
49
 
# Test for information_schema.CHARACTER_SETS &
50
 
# SHOW CHARACTER SET
51
 
 
52
 
select * from information_schema.CHARACTER_SETS
53
 
where CHARACTER_SET_NAME like 'latin1%';
54
 
 
55
 
# Test for information_schema.COLLATIONS &
56
 
# SHOW COLLATION
57
 
 
58
 
--replace_column 5 #
59
 
select * from information_schema.COLLATIONS
60
 
where COLLATION_NAME like 'latin1%';
61
 
 
62
 
select * from information_schema.COLLATION_CHARACTER_SET_APPLICABILITY
63
 
where COLLATION_NAME like 'latin1%';
64
 
 
65
 
#
66
 
# Bug#7213: information_schema: redundant non-standard TABLE_NAMES table
67
 
#
68
 
--error 1109
69
 
select * from information_schema.table_names;
70
 
 
71
44
#
72
45
# Bug#2719 information_schema: errors in "columns"
73
46
#
74
 
select column_type from information_schema.columns
75
 
where table_schema="information_schema" and table_name="COLUMNS" and
 
47
select column_type from data_dictionary.columns
 
48
where table_schema="data_dictionary" and table_name="COLUMNS" and
76
49
(column_name="character_set_name" or column_name="collation_name");
77
50
 
78
51
#
79
52
# Bug#2718 information_schema: errors in "tables"
80
53
#
81
 
select TABLE_ROWS from information_schema.tables where 
82
 
table_schema="information_schema" and table_name="COLUMNS";
83
 
select table_type from information_schema.tables
 
54
--replace_column 1 #
 
55
select count(*) from data_dictionary.tables where 
 
56
table_schema="data_dictionary" and table_name="COLUMNS";
 
57
 
 
58
--replace_column 1 #
 
59
select count(*) from data_dictionary.tables
84
60
where table_schema="mysql" and table_name="user";
85
61
 
86
62
#
87
63
# Bug #7215  information_schema: columns are longtext instead of varchar
88
64
# Bug #7217  information_schema: columns are varbinary() instead of timestamp
89
65
#
90
 
select table_schema,table_name, column_name from
91
 
information_schema.columns 
92
 
where data_type = 'longtext';
93
 
select table_name, column_name, data_type from information_schema.columns
94
 
where data_type = 'datetime';
 
66
select table_schema, table_name, column_name from data_dictionary.columns where data_type = 'longtext';
 
67
select table_name, column_name, data_type from data_dictionary.columns where data_type = 'datetime';
95
68
 
96
69
#
97
 
# Bug #8164  subquery with INFORMATION_SCHEMA.COLUMNS, 100 % CPU
 
70
# Bug #8164  subquery with data_dictionary.COLUMNS, 100 % CPU
98
71
#
99
 
SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES A
 
72
SELECT COUNT(*) FROM data_dictionary.tables A
100
73
WHERE NOT EXISTS 
101
 
(SELECT * FROM INFORMATION_SCHEMA.COLUMNS B
 
74
(SELECT * FROM data_dictionary.columns B
102
75
  WHERE A.TABLE_SCHEMA = B.TABLE_SCHEMA
103
76
  AND A.TABLE_NAME = B.TABLE_NAME);
104
77
 
116
89
  x_float FLOAT,
117
90
  x_double_precision DOUBLE PRECISION );
118
91
SELECT COLUMN_NAME, CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH
119
 
FROM INFORMATION_SCHEMA.COLUMNS
 
92
FROM data_dictionary.columns
120
93
WHERE TABLE_NAME= 't1';
121
94
drop table t1;
122
95
 
124
97
# Bug #9404  information_schema: Weird error messages
125
98
# with SELECT SUM() ... GROUP BY queries
126
99
#
127
 
SELECT table_schema, count(*) FROM information_schema.TABLES
 
100
SELECT table_schema, count(*) FROM data_dictionary.tables
128
101
WHERE table_name NOT LIKE 'ndb_%' AND 
129
 
table_name NOT LIKE 'falcon%' AND
130
 
plugin_name IS NULL
131
 
GROUP BY TABLE_SCHEMA;
132
 
 
133
 
#
134
 
# Bug #9434 SHOW CREATE DATABASE information_schema;
135
 
#
136
 
show create database information_schema;
 
102
table_name NOT LIKE 'falcon%'
 
103
GROUP BY TABLE_SCHEMA ORDER BY table_schema;
137
104
 
138
105
#
139
106
# Bug #11057 information_schema: columns table has some questionable contents
142
109
create table t1(f1 LONGBLOB, f2 LONGTEXT);
143
110
select column_name,data_type,CHARACTER_OCTET_LENGTH,
144
111
       CHARACTER_MAXIMUM_LENGTH
145
 
from information_schema.columns
 
112
from data_dictionary.columns
146
113
where table_name='t1';
147
114
drop table t1;
148
115
create table t1(f1 int, f2 int, f3 BIGINT, f4 int,
149
116
                f5 BIGINT, f6 int, f7 int);
150
117
select column_name, NUMERIC_PRECISION, NUMERIC_SCALE
151
 
from information_schema.columns
 
118
from data_dictionary.columns
152
119
where table_name='t1';
153
120
drop table t1;
154
121
 
156
123
# Bug#12518 COLUMN_DEFAULT has wrong value if NOT NULL is set
157
124
#
158
125
create table t1 (a int not null, b int);
159
 
use information_schema;
160
 
select column_name, column_default from columns
 
126
select column_name, column_default from data_dictionary.columns
161
127
  where table_schema='test' and table_name='t1';
162
128
use test;
163
129
show columns from t1;
164
130
drop table t1;
165
131
 
166
132
#
167
 
# Bug #9846 Inappropriate error displayed while dropping table from 'INFORMATION_SCHEMA'
168
 
#
169
 
--error ER_PARSE_ERROR
170
 
alter database information_schema;
171
 
--error ER_DBACCESS_DENIED_ERROR
172
 
drop database information_schema;
173
 
use information_schema;
174
 
--error 1044
175
 
drop table tables;
176
 
--error 1044
177
 
alter table tables;
178
 
#
179
 
# Bug #9683 INFORMATION_SCH: Creation of temporary table allowed in Information_schema DB
180
 
#
181
 
use information_schema;
182
 
--error 1044
183
 
create temporary table schemata(f1 char(10));
184
 
#
185
133
#
186
134
# Bug#14089 FROM list subquery always fails when information_schema is current database
187
135
#
189
137
create table t1(id int);
190
138
insert into t1(id) values (1);
191
139
select 1 from (select 1 from test.t1) a;
192
 
use information_schema;
 
140
use data_dictionary;
193
141
select 1 from (select 1 from test.t1) a;
194
142
use test;
195
143
drop table t1;
196
144
 
197
 
# Bug #14387 SHOW COLUMNS doesn't work on temporary tables
198
 
# Bug #15224 SHOW INDEX from temporary table doesn't work
199
 
# Bug #12770 DESC cannot display the info. about temporary table
200
 
#
201
 
create temporary table t1(f1 int, index(f1));
202
 
show columns from t1;
203
 
describe t1;
204
 
show indexes from t1;
205
 
drop table t1;
206
 
 
207
145
#
208
146
# Bug#14271 I_S: columns has no size for (var)binary columns
209
147
#
210
148
create table t1(f1 varbinary(32), f2 varbinary(64));
211
149
select character_maximum_length, character_octet_length
212
 
from information_schema.columns where table_name='t1';
 
150
from data_dictionary.columns where table_name='t1';
213
151
drop table t1;
214
152
 
215
 
#
216
 
# Bug#15307 GROUP_CONCAT() with ORDER BY returns empty set on information_schema
217
 
#
 
153
##
 
154
## Bug#15307 GROUP_CONCAT() with ORDER BY returns empty set on information_schema
 
155
##
218
156
select column_type, group_concat(table_schema, '.', table_name), count(*) as num
219
 
from information_schema.columns where
220
 
table_schema='information_schema' and
 
157
from data_dictionary.columns where
 
158
table_schema='data_dictionary' and
221
159
(column_type = 'varchar(7)' or column_type = 'varchar(20)'
222
160
 or column_type = 'varchar(27)')
223
161
group by column_type order by column_type, num;
227
165
#
228
166
create table t1(f1 char(1) not null, f2 char(9) not null);
229
167
select CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH from
230
 
information_schema.columns where table_schema='test' and table_name = 't1';
 
168
data_dictionary.columns where table_schema='test' and table_name = 't1';
231
169
drop table t1;
232
170
 
233
171
#
237
175
create table t1(f1 char(5));
238
176
create table t2(f1 char(5));
239
177
select concat(@a, table_name), @a, table_name
240
 
from information_schema.tables where table_schema = 'test';
 
178
from data_dictionary.tables where table_schema = 'test';
241
179
drop table t1,t2;
242
180
 
243
181
#
245
183
#
246
184
 
247
185
SELECT t.table_name, c1.column_name
248
 
  FROM information_schema.tables t
 
186
  FROM data_dictionary.tables t
249
187
       INNER JOIN
250
 
       information_schema.columns c1
 
188
       data_dictionary.columns c1
251
189
       ON t.table_schema = c1.table_schema AND
252
190
          t.table_name = c1.table_name
253
 
  WHERE t.table_schema = 'information_schema' AND
 
191
  WHERE t.table_schema = 'data_dictionary' AND
254
192
        c1.ordinal_position =
255
193
        ( SELECT COALESCE(MIN(c2.ordinal_position),1)
256
 
            FROM information_schema.columns c2
 
194
            FROM data_dictionary.columns c2
257
195
            WHERE c2.table_schema = t.table_schema AND
258
196
                  c2.table_name = t.table_name AND
259
197
                  c2.column_name LIKE '%SCHEMA%'
260
198
        )
261
199
  AND t.table_name NOT LIKE 'falcon%'
262
 
  AND t.plugin_name IS NULL;
 
200
  ORDER BY t.table_name, c1.column_name;
 
201
 
263
202
SELECT t.table_name, c1.column_name
264
 
  FROM information_schema.tables t
 
203
  FROM data_dictionary.tables t
265
204
       INNER JOIN
266
 
       information_schema.columns c1
 
205
       data_dictionary.columns c1
267
206
       ON t.table_schema = c1.table_schema AND
268
207
          t.table_name = c1.table_name
269
 
  WHERE t.table_schema = 'information_schema' AND
 
208
  WHERE t.table_schema = 'data_dictionary' AND
270
209
        c1.ordinal_position =
271
210
        ( SELECT COALESCE(MIN(c2.ordinal_position),1)
272
 
            FROM information_schema.columns c2
273
 
            WHERE c2.table_schema = 'information_schema' AND
 
211
            FROM data_dictionary.columns c2
 
212
            WHERE c2.table_schema = 'data_dictionary' AND
274
213
                  c2.table_name = t.table_name AND
275
214
                  c2.column_name LIKE '%SCHEMA%'
276
215
        )
277
216
  AND t.table_name NOT LIKE 'falcon%'
278
 
  AND t.plugin_name IS NULL;
 
217
  ORDER BY t.table_name, c1.column_name;
279
218
 
280
219
#
281
220
# Bug#21231: query with a simple non-correlated subquery over
282
221
#            INFORMARTION_SCHEMA.TABLES 
283
222
#
284
223
 
285
 
SELECT MAX(table_name) FROM information_schema.tables;
286
 
SELECT table_name from information_schema.tables
 
224
SELECT MAX(table_name) FROM data_dictionary.tables;
 
225
SELECT table_name from data_dictionary.tables
287
226
  WHERE table_name=(SELECT MAX(table_name)
288
 
                      FROM information_schema.tables);
289
 
#
 
227
                      FROM data_dictionary.tables)
 
228
  ORDER BY table_name;
 
229
 
290
230
# Bug#23299 Some queries against INFORMATION_SCHEMA with subqueries fail
291
231
#
292
232
create table t1 (f1 int);
293
233
create table t2 (f1 int, f2 int);
294
234
 
295
 
select table_name from information_schema.tables
296
 
where table_schema = 'test' and table_name not in
297
 
(select table_name from information_schema.columns
298
 
 where table_schema = 'test' and column_name = 'f3');
 
235
#select table_name from data_dictionary.tables
 
236
#where table_schema = 'test' and table_name not in
 
237
#(select table_name from data_dictionary.columns
 
238
# where table_schema = 'test' and column_name = 'f3')
 
239
#ORDER BY table_name;
 
240
 
299
241
drop table t1,t2;
300
242
 
301
243
 
302
244
#
303
245
# Bug#24630  Subselect query crashes mysqld
304
246
#
305
 
select 1 as f1 from information_schema.tables  where "CHARACTER_SETS"=
306
 
(select cast(table_name as char)  from information_schema.tables
 
247
select 1 as f1 from data_dictionary.tables  where "CHARACTER_SETS"=
 
248
(select cast(table_name as char)  from data_dictionary.tables
307
249
 order by table_name limit 1) limit 1;
308
250
 
309
251
select t.table_name, group_concat(t.table_schema, '.', t.table_name),
310
252
       count(*) as num1
311
 
from information_schema.tables t
312
 
inner join information_schema.columns c1
 
253
from data_dictionary.tables t
 
254
inner join data_dictionary.columns c1
313
255
on t.table_schema = c1.table_schema AND t.table_name = c1.table_name
314
 
where t.table_schema = 'information_schema' AND
 
256
where t.table_schema = 'data_dictionary' AND
315
257
      t.table_name not like 'falcon%' AND
316
 
      t.plugin_name IS NULL AND
317
258
        c1.ordinal_position =
318
259
        (select isnull(c2.column_type) -
319
260
         isnull(group_concat(c2.table_schema, '.', c2.table_name)) +
320
261
         count(*) as num
321
 
         from information_schema.columns c2 where
322
 
         c2.table_schema='information_schema' and
 
262
         from data_dictionary.columns c2 where
 
263
         c2.table_schema='data_dictionary' and
323
264
         (c2.column_type = 'varchar(7)' or c2.column_type = 'varchar(20)')
324
265
          group by c2.column_type order by num limit 1)
325
266
group by t.table_name order by num1, t.table_name;
345
286
  f7 datetime not null,
346
287
  f8 datetime default '2006-01-01'
347
288
);
348
 
select column_default from information_schema.columns where table_name= 't1';
 
289
#select column_default from data_dictionary.columns where table_name= 't1' ORDER BY column_default;
349
290
show columns from t1;
350
291
drop table t1;
351
292
 
352
 
#
353
 
# Bug#30079 A check for "hidden" I_S tables is flawed
354
 
#
355
 
--error 1109
356
 
show fields from information_schema.table_names;
357
 
--error 1109
358
 
show keys from information_schema.table_names;
359
 
 
360
293
SET max_heap_table_size = DEFAULT;
361
294
USE test;
362
295
 
363
296
--echo End of 5.0 tests.
364
297
 
365
298
#
366
 
# Bug#30795 Query on INFORMATION_SCHEMA.SCHEMATA, wrong result
 
299
# Bug#30795 Query on data_dictionary.schemas, wrong result
367
300
#
368
 
SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA
369
 
WHERE SCHEMA_NAME ='information_schema';
 
301
SELECT SCHEMA_NAME FROM data_dictionary.schemas
 
302
WHERE SCHEMA_NAME ='data_dictionary';
370
303
                                                                                                 
371
304
#
372
305
# Bug#31381 Error in retrieving Data from INFORMATION_SCHEMA
373
306
#
374
 
SELECT TABLE_COLLATION FROM INFORMATION_SCHEMA.TABLES
 
307
SELECT TABLE_COLLATION FROM data_dictionary.tables
375
308
WHERE TABLE_SCHEMA='mysql' and TABLE_NAME= 'db';
376
309
 
377
 
#
378
 
# Bug#31633 Information schema = NULL queries crash the server
379
 
#
380
 
select * from information_schema.columns where table_schema = NULL;
381
 
select * from `information_schema`.`COLUMNS` where `TABLE_NAME` = NULL;
382
 
select * from `information_schema`.`KEY_COLUMN_USAGE` where `TABLE_SCHEMA` = NULL;
383
 
select * from `information_schema`.`KEY_COLUMN_USAGE` where `TABLE_NAME` = NULL;
384
 
select * from `information_schema`.`REFERENTIAL_CONSTRAINTS` where `CONSTRAINT_SCHEMA` = NULL;
385
 
select * from `information_schema`.`REFERENTIAL_CONSTRAINTS` where `TABLE_NAME` = NULL;
386
 
select * from information_schema.schemata where schema_name = NULL;
387
 
select * from `information_schema`.`STATISTICS` where `TABLE_SCHEMA` = NULL;
388
 
select * from `information_schema`.`STATISTICS` where `TABLE_NAME` = NULL;
389
 
select * from information_schema.tables where table_schema = NULL;
390
 
select * from information_schema.tables where table_catalog = NULL;
391
 
select * from information_schema.tables where table_name = NULL;
392
 
select * from `information_schema`.`TABLE_CONSTRAINTS` where `TABLE_SCHEMA` = NULL;
393
 
select * from `information_schema`.`TABLE_CONSTRAINTS` where `TABLE_NAME` = NULL;
394
 
 
395
310
--echo #
396
311
--echo # Test that the query is visible to self and others.
397
312
--echo #
398
313
 
399
 
SELECT info FROM information_schema.processlist WHERE id = CONNECTION_ID();
400
 
 
401
 
#
402
 
# test that SHOW PROCESSLIST works correctly
403
 
#
404
 
--replace_column 1 # 2 # 3 # 6 # 7 #
405
 
show processlist;
 
314
SELECT info FROM data_dictionary.processlist WHERE id = CONNECTION_ID();
406
315
 
407
316
#
408
317
# do a query on the PROCESSLIST table in I_S to ensure it works correctly
409
318
#
410
319
SELECT info, command, db
411
 
FROM information_schema.processlist
 
320
FROM data_dictionary.processlist
412
321
WHERE id = CONNECTION_ID();
413
322
 
414
323
#
415
 
# do a query on the CHARACTER_SET table in I_S 
416
 
#
417
 
SELECT *
418
 
FROM information_schema.character_sets
419
 
ORDER BY character_set_name;
420
 
 
421
 
#
422
 
# perform a query on the COLLATIONS table
423
 
#
424
 
SELECT *
425
 
FROM information_schema.collations
426
 
ORDER BY collation_name;
427
 
 
428
 
#
429
 
# perform a query on COLLATION_CHARACTER_SET_APPLICABILITY
430
 
#
431
 
SELECT * 
432
 
FROM information_schema.collation_character_set_applicability
433
 
ORDER BY collation_name;
434
 
 
435
 
#
436
 
# perform a query on COLUMNS
437
 
#
438
 
SELECT table_name, column_name
439
 
FROM information_schema.columns
440
 
WHERE table_name IN
441
 
(SELECT table_name FROM information_schema.tables 
442
 
 WHERE plugin_name IS NULL)
443
 
ORDER BY table_name;
444
 
 
445
 
#
446
 
# perform a query on KEY_COLUMN_USAGE
447
 
#
448
 
SELECT *
449
 
FROM information_schema.key_column_usage;
450
 
 
451
 
#
452
 
# perform a query on REFERENTIAL_CONSTRAINTS
453
 
#
454
 
SELECT * 
455
 
FROM information_schema.referential_constraints;
456
 
 
457
 
#
458
 
# query the SCHEMATA table
459
 
#
460
 
SELECT catalog_name, schema_name
461
 
FROM information_schema.schemata
462
 
ORDER BY schema_name;
463
 
 
464
 
#
465
 
# Query the STATUS and VARIABLES related
466
 
# I_S related tables. 
467
 
#
468
 
--replace_column 1 # 2 #
469
 
SELECT *
470
 
FROM information_schema.session_status
471
 
ORDER BY variable_name;
472
 
 
473
 
--replace_column 1 # 2 #
474
 
SHOW STATUS;
475
 
 
476
 
#--replace_column 1 # 2 #
477
 
#SELECT *
478
 
#FROM information_schema.session_variables
479
 
#ORDER BY variable_name;
480
 
 
481
 
#--replace_column 1 # 2 #
482
 
#SHOW VARIABLES;
483
 
 
484
 
--replace_column 1 # 2 #
485
 
SELECT *
486
 
FROM information_schema.global_status
487
 
ORDER BY variable_name;
488
 
 
489
 
#--replace_column 1 # 2 #
490
 
#SELECT *
491
 
#FROM information_schema.global_variables
492
 
#ORDER BY variable_name;
493
 
 
494
 
#
495
 
# query TABLE_CONSTRAINTS table
496
 
#
497
 
SELECT *
498
 
FROM information_schema.table_constraints;
499
 
 
500
 
#
501
324
# query TABLES
502
325
#
503
 
SELECT table_schema, table_name
504
 
FROM information_schema.tables
505
 
WHERE plugin_name IS NULL
506
 
ORDER BY table_name;
507
 
 
508
 
509
 
# do a query on the PLUGINS table in I_S to ensure it works correctly
510
 
# how do we test for this if the contents of this table can change
511
 
# depend on what plugins are configured for use?
512
 
#
513
 
#SELECT *
514
 
#FROM plugins;
 
326
#SELECT table_schema, table_name
 
327
#FROM data_dictionary.tables
 
328
#WHERE table_schema="data_dictionary"
 
329
#ORDER BY table_name;