~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/information_schema.test

  • Committer: Brian Aker
  • Date: 2009-02-05 09:11:16 UTC
  • Revision ID: brian@tangent.org-20090205091116-iy0ersp6bhyzt1ad
Removed dead variables.

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
 
--sorted_result
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%";
22
31
 
23
 
select * from data_dictionary.indexes where TABLE_SCHEMA = "mysqltest";
 
32
select * from information_schema.STATISTICS where TABLE_SCHEMA = "mysqltest";
24
33
 
25
34
show tables like 't%';
26
 
--replace_column 1 #  6 # 7 # 8 # 9 # 10 #
27
 
show table status;
28
 
show columns from t3 like "a%";
29
 
--sorted_result
30
 
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"
31
39
and column_name= "a";
32
40
 
33
41
connect (user3,localhost,mysqltest_2,,);
34
42
connection user3;
35
 
--sorted_result
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;
45
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
 
46
75
#
47
76
# Bug#2719 information_schema: errors in "columns"
48
77
#
49
 
--sorted_result
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");
53
81
 
54
82
#
55
83
# Bug#2718 information_schema: errors in "tables"
56
84
#
57
 
--replace_column 1 #
58
 
--sorted_result
59
 
select count(*) from data_dictionary.tables where 
60
 
table_schema="data_dictionary" and table_name="COLUMNS";
61
 
 
62
 
--replace_column 1 #
63
 
--sorted_result
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";
66
89
 
67
90
#
 
91
# Bug #7981:SHOW GLOBAL STATUS crashes server
 
92
#
 
93
# We don't actually care about the value, just that it doesn't crash.
 
94
--replace_column 2 #
 
95
show global status like "Threads_running";
 
96
 
 
97
#
68
98
# Bug #7215  information_schema: columns are longtext instead of varchar
69
99
# Bug #7217  information_schema: columns are varbinary() instead of timestamp
70
100
#
71
 
--sorted_result
72
 
select table_schema, table_name, column_name from data_dictionary.columns where data_type = 'longtext';
73
 
--sorted_result
74
 
select table_name, column_name, data_type from data_dictionary.columns where data_type = 'datetime';
 
101
select table_schema,table_name, column_name from
 
102
information_schema.columns 
 
103
where data_type = 'longtext';
 
104
select table_name, column_name, data_type from information_schema.columns
 
105
where data_type = 'datetime';
75
106
 
76
107
#
77
 
# Bug #8164  subquery with data_dictionary.COLUMNS, 100 % CPU
 
108
# Bug #8164  subquery with INFORMATION_SCHEMA.COLUMNS, 100 % CPU
78
109
#
79
 
--sorted_result
80
 
SELECT COUNT(*) FROM data_dictionary.tables A
 
110
SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES A
81
111
WHERE NOT EXISTS 
82
 
(SELECT * FROM data_dictionary.columns B
 
112
(SELECT * FROM INFORMATION_SCHEMA.COLUMNS B
83
113
  WHERE A.TABLE_SCHEMA = B.TABLE_SCHEMA
84
114
  AND A.TABLE_NAME = B.TABLE_NAME);
85
115
 
96
126
  x_real REAL,
97
127
  x_float FLOAT,
98
128
  x_double_precision DOUBLE PRECISION );
99
 
--sorted_result
100
129
SELECT COLUMN_NAME, CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH
101
 
FROM data_dictionary.columns
 
130
FROM INFORMATION_SCHEMA.COLUMNS
102
131
WHERE TABLE_NAME= 't1';
103
132
drop table t1;
104
133
 
106
135
# Bug #9404  information_schema: Weird error messages
107
136
# with SELECT SUM() ... GROUP BY queries
108
137
#
109
 
--replace_column 2 #
110
 
SELECT table_schema, count(*) FROM data_dictionary.tables
111
 
WHERE table_name NOT LIKE 'ndb_%' AND 
112
 
table_name NOT LIKE 'falcon%'
113
 
GROUP BY TABLE_SCHEMA ORDER BY table_schema;
 
138
SELECT table_schema, count(*) FROM information_schema.TABLES
 
139
WHERE table_name NOT LIKE 'ndb_%' AND table_name NOT LIKE 'falcon%' GROUP BY TABLE_SCHEMA;
 
140
 
 
141
#
 
142
# Bug #9434 SHOW CREATE DATABASE information_schema;
 
143
#
 
144
show create database information_schema;
114
145
 
115
146
#
116
147
# Bug #11057 information_schema: columns table has some questionable contents
117
148
# Bug #12301 information_schema: NUMERIC_SCALE must be 0 for integer columns
118
149
#
119
150
create table t1(f1 LONGBLOB, f2 LONGTEXT);
120
 
--sorted_result
121
151
select column_name,data_type,CHARACTER_OCTET_LENGTH,
122
152
       CHARACTER_MAXIMUM_LENGTH
123
 
from data_dictionary.columns
 
153
from information_schema.columns
124
154
where table_name='t1';
125
155
drop table t1;
126
156
create table t1(f1 int, f2 int, f3 BIGINT, f4 int,
127
157
                f5 BIGINT, f6 int, f7 int);
128
 
--sorted_result
129
158
select column_name, NUMERIC_PRECISION, NUMERIC_SCALE
130
 
from data_dictionary.columns
 
159
from information_schema.columns
131
160
where table_name='t1';
132
161
drop table t1;
133
162
 
135
164
# Bug#12518 COLUMN_DEFAULT has wrong value if NOT NULL is set
136
165
#
137
166
create table t1 (a int not null, b int);
138
 
--sorted_result
139
 
select column_name, column_default from data_dictionary.columns
 
167
use information_schema;
 
168
select column_name, column_default from columns
140
169
  where table_schema='test' and table_name='t1';
141
170
use test;
142
171
show columns from t1;
143
172
drop table t1;
144
173
 
145
174
#
 
175
# Bug #9846 Inappropriate error displayed while dropping table from 'INFORMATION_SCHEMA'
 
176
#
 
177
--error ER_PARSE_ERROR
 
178
alter database information_schema;
 
179
--error ER_DBACCESS_DENIED_ERROR
 
180
drop database information_schema;
 
181
--error 1044
 
182
drop table information_schema.tables;
 
183
--error 1044
 
184
alter table information_schema.tables;
 
185
#
 
186
# Bug #9683 INFORMATION_SCH: Creation of temporary table allowed in Information_schema DB
 
187
#
 
188
use information_schema;
 
189
--error 1044
 
190
create temporary table schemata(f1 char(10));
 
191
#
146
192
#
147
193
# Bug#14089 FROM list subquery always fails when information_schema is current database
148
194
#
149
195
use test;
150
196
create table t1(id int);
151
197
insert into t1(id) values (1);
152
 
--sorted_result
153
198
select 1 from (select 1 from test.t1) a;
154
 
use data_dictionary;
155
 
--sorted_result
 
199
use information_schema;
156
200
select 1 from (select 1 from test.t1) a;
157
201
use test;
158
202
drop table t1;
159
203
 
 
204
# Bug #14387 SHOW COLUMNS doesn't work on temporary tables
 
205
# Bug #15224 SHOW INDEX from temporary table doesn't work
 
206
# Bug #12770 DESC cannot display the info. about temporary table
 
207
#
 
208
create temporary table t1(f1 int, index(f1));
 
209
show columns from t1;
 
210
describe t1;
 
211
show indexes from t1;
 
212
drop table t1;
 
213
 
160
214
#
161
215
# Bug#14271 I_S: columns has no size for (var)binary columns
162
216
#
163
217
create table t1(f1 varbinary(32), f2 varbinary(64));
164
 
--sorted_result
165
218
select character_maximum_length, character_octet_length
166
 
from data_dictionary.columns where table_name='t1';
 
219
from information_schema.columns where table_name='t1';
167
220
drop table t1;
168
221
 
169
 
##
170
 
## Bug#15307 GROUP_CONCAT() with ORDER BY returns empty set on information_schema
171
 
##
 
222
#
 
223
# Bug#15307 GROUP_CONCAT() with ORDER BY returns empty set on information_schema
 
224
#
172
225
select column_type, group_concat(table_schema, '.', table_name), count(*) as num
173
 
from data_dictionary.columns where
174
 
table_schema='data_dictionary' and
 
226
from information_schema.columns where
 
227
table_schema='information_schema' and
175
228
(column_type = 'varchar(7)' or column_type = 'varchar(20)'
176
229
 or column_type = 'varchar(27)')
177
 
group by column_type order by column_type, num;
 
230
group by column_type order by num;
178
231
 
179
232
#
180
233
# Bug#19236 bad COLUMNS.CHARACTER_MAXIMUM_LENGHT and CHARACTER_OCTET_LENGTH
181
234
#
182
235
create table t1(f1 char(1) not null, f2 char(9) not null);
183
 
--sorted_result
184
236
select CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH from
185
 
data_dictionary.columns where table_schema='test' and table_name = 't1';
 
237
information_schema.columns where table_schema='test' and table_name = 't1';
186
238
drop table t1;
187
239
 
188
240
#
191
243
set @a:= '.';
192
244
create table t1(f1 char(5));
193
245
create table t2(f1 char(5));
194
 
--sorted_result
195
246
select concat(@a, table_name), @a, table_name
196
 
from data_dictionary.tables where table_schema = 'test';
 
247
from information_schema.tables where table_schema = 'test';
197
248
drop table t1,t2;
198
249
 
199
250
#
201
252
#
202
253
 
203
254
SELECT t.table_name, c1.column_name
204
 
  FROM data_dictionary.tables t
 
255
  FROM information_schema.tables t
205
256
       INNER JOIN
206
 
       data_dictionary.columns c1
 
257
       information_schema.columns c1
207
258
       ON t.table_schema = c1.table_schema AND
208
259
          t.table_name = c1.table_name
209
 
  WHERE t.table_schema = 'data_dictionary' AND
 
260
  WHERE t.table_schema = 'information_schema' AND
210
261
        c1.ordinal_position =
211
262
        ( SELECT COALESCE(MIN(c2.ordinal_position),1)
212
 
            FROM data_dictionary.columns c2
 
263
            FROM information_schema.columns c2
213
264
            WHERE c2.table_schema = t.table_schema AND
214
265
                  c2.table_name = t.table_name AND
215
266
                  c2.column_name LIKE '%SCHEMA%'
216
267
        )
217
 
  AND t.table_name NOT LIKE 'falcon%'
218
 
  ORDER BY t.table_name, c1.column_name;
219
 
 
 
268
  AND t.table_name NOT LIKE 'falcon%';
220
269
SELECT t.table_name, c1.column_name
221
 
  FROM data_dictionary.tables t
 
270
  FROM information_schema.tables t
222
271
       INNER JOIN
223
 
       data_dictionary.columns c1
 
272
       information_schema.columns c1
224
273
       ON t.table_schema = c1.table_schema AND
225
274
          t.table_name = c1.table_name
226
 
  WHERE t.table_schema = 'data_dictionary' AND
 
275
  WHERE t.table_schema = 'information_schema' AND
227
276
        c1.ordinal_position =
228
277
        ( SELECT COALESCE(MIN(c2.ordinal_position),1)
229
 
            FROM data_dictionary.columns c2
230
 
            WHERE c2.table_schema = 'data_dictionary' AND
 
278
            FROM information_schema.columns c2
 
279
            WHERE c2.table_schema = 'information_schema' AND
231
280
                  c2.table_name = t.table_name AND
232
281
                  c2.column_name LIKE '%SCHEMA%'
233
282
        )
234
 
  AND t.table_name NOT LIKE 'falcon%'
235
 
  ORDER BY t.table_name, c1.column_name;
 
283
  AND t.table_name NOT LIKE 'falcon%';
236
284
 
237
285
#
238
286
# Bug#21231: query with a simple non-correlated subquery over
239
287
#            INFORMARTION_SCHEMA.TABLES 
240
288
#
241
289
 
242
 
SELECT MAX(table_name) FROM data_dictionary.tables;
243
 
SELECT table_name from data_dictionary.tables
 
290
SELECT MAX(table_name) FROM information_schema.tables;
 
291
SELECT table_name from information_schema.tables
244
292
  WHERE table_name=(SELECT MAX(table_name)
245
 
                      FROM data_dictionary.tables)
246
 
  ORDER BY table_name;
247
 
 
 
293
                      FROM information_schema.tables);
 
294
#
248
295
# Bug#23299 Some queries against INFORMATION_SCHEMA with subqueries fail
249
296
#
250
297
create table t1 (f1 int);
251
298
create table t2 (f1 int, f2 int);
252
299
 
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;
258
 
 
 
300
select table_name from information_schema.tables
 
301
where table_schema = 'test' and table_name not in
 
302
(select table_name from information_schema.columns
 
303
 where table_schema = 'test' and column_name = 'f3');
259
304
drop table t1,t2;
260
305
 
261
306
 
262
307
#
263
308
# Bug#24630  Subselect query crashes mysqld
264
309
#
265
 
--sorted_result
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;
 
310
select 1 as f1 from information_schema.tables  where "CHARACTER_SETS"=
 
311
(select cast(table_name as char)  from information_schema.tables
 
312
 order by table_name limit 1) limit 1;
270
313
 
271
314
select t.table_name, group_concat(t.table_schema, '.', t.table_name),
272
315
       count(*) as num1
273
 
from data_dictionary.tables t
274
 
inner join data_dictionary.columns c1
 
316
from information_schema.tables t
 
317
inner join information_schema.columns c1
275
318
on t.table_schema = c1.table_schema AND t.table_name = c1.table_name
276
 
where t.table_schema = 'data_dictionary' AND
 
319
where t.table_schema = 'information_schema' AND
277
320
      t.table_name not like 'falcon%' AND
278
321
        c1.ordinal_position =
279
322
        (select isnull(c2.column_type) -
280
323
         isnull(group_concat(c2.table_schema, '.', c2.table_name)) +
281
324
         count(*) as num
282
 
         from data_dictionary.columns c2 where
283
 
         c2.table_schema='data_dictionary' and
 
325
         from information_schema.columns c2 where
 
326
         c2.table_schema='information_schema' and
284
327
         (c2.column_type = 'varchar(7)' or c2.column_type = 'varchar(20)')
285
328
          group by c2.column_type order by num limit 1)
286
329
group by t.table_name order by num1, t.table_name;
306
349
  f7 datetime not null,
307
350
  f8 datetime default '2006-01-01'
308
351
);
309
 
#select column_default from data_dictionary.columns where table_name= 't1' ORDER BY column_default;
 
352
select column_default from information_schema.columns where table_name= 't1';
310
353
show columns from t1;
311
354
drop table t1;
312
355
 
 
356
#
 
357
# Bug#30079 A check for "hidden" I_S tables is flawed
 
358
#
 
359
--error 1109
 
360
show fields from information_schema.table_names;
 
361
--error 1109
 
362
show keys from information_schema.table_names;
 
363
 
313
364
SET max_heap_table_size = DEFAULT;
314
365
USE test;
315
366
 
316
367
--echo End of 5.0 tests.
317
368
 
318
369
#
319
 
# Bug#30795 Query on data_dictionary.schemas, wrong result
 
370
# Bug#30795 Query on INFORMATION_SCHEMA.SCHEMATA, wrong result
320
371
#
321
 
--sorted_result
322
 
SELECT SCHEMA_NAME FROM data_dictionary.schemas
323
 
WHERE SCHEMA_NAME ='data_dictionary';
 
372
SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA
 
373
WHERE SCHEMA_NAME ='information_schema';
324
374
                                                                                                 
325
375
#
326
376
# Bug#31381 Error in retrieving Data from INFORMATION_SCHEMA
327
377
#
328
 
--sorted_result
329
 
SELECT TABLE_COLLATION FROM data_dictionary.tables
 
378
SELECT TABLE_COLLATION FROM INFORMATION_SCHEMA.TABLES
330
379
WHERE TABLE_SCHEMA='mysql' and TABLE_NAME= 'db';
331
380
 
332
 
--echo #
333
 
--echo # Test that the query is visible to self and others.
334
 
--echo #
335
 
 
336
 
--sorted_result
337
 
SELECT info FROM data_dictionary.processlist WHERE id = CONNECTION_ID();
338
 
 
339
 
#
340
 
# do a query on the PROCESSLIST table in I_S to ensure it works correctly
341
 
#
342
 
--sorted_result
343
 
SELECT info, command, db
344
 
FROM data_dictionary.processlist
345
 
WHERE id = CONNECTION_ID();
346
 
 
347
 
#
348
 
# query TABLES
349
 
#
350
 
#SELECT table_schema, table_name
351
 
#FROM data_dictionary.tables
352
 
#WHERE table_schema="data_dictionary"
353
 
#ORDER BY table_name;
 
381
#
 
382
# Bug#31633 Information schema = NULL queries crash the server
 
383
#
 
384
select * from information_schema.columns where table_schema = NULL;
 
385
select * from `information_schema`.`COLUMNS` where `TABLE_NAME` = NULL;
 
386
select * from `information_schema`.`KEY_COLUMN_USAGE` where `TABLE_SCHEMA` = NULL;
 
387
select * from `information_schema`.`KEY_COLUMN_USAGE` where `TABLE_NAME` = NULL;
 
388
select * from `information_schema`.`REFERENTIAL_CONSTRAINTS` where `CONSTRAINT_SCHEMA` = NULL;
 
389
select * from `information_schema`.`REFERENTIAL_CONSTRAINTS` where `TABLE_NAME` = NULL;
 
390
select * from information_schema.schemata where schema_name = NULL;
 
391
select * from `information_schema`.`STATISTICS` where `TABLE_SCHEMA` = NULL;
 
392
select * from `information_schema`.`STATISTICS` where `TABLE_NAME` = NULL;
 
393
select * from information_schema.tables where table_schema = NULL;
 
394
select * from information_schema.tables where table_catalog = NULL;
 
395
select * from information_schema.tables where table_name = NULL;
 
396
select * from `information_schema`.`TABLE_CONSTRAINTS` where `TABLE_SCHEMA` = NULL;
 
397
select * from `information_schema`.`TABLE_CONSTRAINTS` where `TABLE_NAME` = NULL;