~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/information_schema.test

  • Committer: Padraig O'Sullivan
  • Date: 2009-09-13 01:03:01 UTC
  • mto: (1126.9.2 captain-20090915-01)
  • mto: This revision was merged to the branch mainline in revision 1133.
  • Revision ID: osullivan.padraig@gmail.com-20090913010301-tcvvezipx1124acy
Added calls to the dtrace delete begin/end probes.

Show diffs side-by-side

added added

removed removed

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