~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysql-test/t/information_schema.test

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
1
5
# Test for information_schema.schemata &
2
6
# show databases
3
7
 
6
10
--enable_warnings
7
11
 
8
12
 
 
13
show variables where variable_name like "skip_show_database";
 
14
 
 
15
 
9
16
select * from information_schema.SCHEMATA where schema_name > 'm';
10
17
select schema_name from information_schema.schemata;
11
18
show databases like 't%';
12
19
show databases;
 
20
show databases where `database` = 't%';
13
21
 
14
22
# Test for information_schema.tables &
15
23
# show tables
26
34
where table_schema = "mysqltest" and table_name like "t%";
27
35
 
28
36
select * from information_schema.STATISTICS where TABLE_SCHEMA = "mysqltest";
 
37
show keys from t3 where Key_name = "a_data";
29
38
 
30
39
show tables like 't%';
31
40
--replace_column 8 # 12 # 13 #
32
 
#show table status;
 
41
show table status;
33
42
show full columns from t3 like "a%";
 
43
show full columns from mysql.db like "Insert%";
34
44
select * from information_schema.COLUMNS where table_name="t1"
35
45
and column_name= "a";
 
46
show columns from mysqltest.t1 where field like "%a%";
36
47
 
37
48
connect (user3,localhost,mysqltest_2,,);
38
49
connection user3;
51
62
 
52
63
select * from information_schema.CHARACTER_SETS
53
64
where CHARACTER_SET_NAME like 'latin1%';
 
65
SHOW CHARACTER SET LIKE 'latin1%';
 
66
SHOW CHARACTER SET WHERE charset like 'latin1%';
54
67
 
55
68
# Test for information_schema.COLLATIONS &
56
69
# SHOW COLLATION
58
71
--replace_column 5 #
59
72
select * from information_schema.COLLATIONS
60
73
where COLLATION_NAME like 'latin1%';
 
74
--replace_column 5 #
 
75
SHOW COLLATION LIKE 'latin1%';
 
76
--replace_column 5 #
 
77
SHOW COLLATION WHERE collation like 'latin1%';
61
78
 
62
79
select * from information_schema.COLLATION_CHARACTER_SET_APPLICABILITY
63
80
where COLLATION_NAME like 'latin1%';
83
100
select table_type from information_schema.tables
84
101
where table_schema="mysql" and table_name="user";
85
102
 
 
103
# test for 'show open tables ... where'
 
104
show open tables where `table` like "user";
 
105
# test for 'show status ... where'
 
106
show status where variable_name like "%database%";
 
107
# test for 'show variables ... where'
 
108
show variables where variable_name like "skip_show_databas";
 
109
 
 
110
#
 
111
# Bug #7981:SHOW GLOBAL STATUS crashes server
 
112
#
 
113
# We don't actually care about the value, just that it doesn't crash.
 
114
--replace_column 2 #
 
115
show global status like "Threads_running";
 
116
 
86
117
#
87
118
# Bug #7215  information_schema: columns are longtext instead of varchar
88
119
# Bug #7217  information_schema: columns are varbinary() instead of timestamp
109
140
create table t1
110
141
( x_bigint BIGINT,
111
142
  x_integer INTEGER,
112
 
  x_int int,
 
143
  x_smallint SMALLINT,
113
144
  x_decimal DECIMAL(5,3),
114
145
  x_numeric NUMERIC(5,3),
115
146
  x_real REAL,
125
156
# with SELECT SUM() ... GROUP BY queries
126
157
#
127
158
SELECT table_schema, count(*) FROM information_schema.TABLES
128
 
WHERE table_name NOT LIKE 'ndb_%' AND 
129
 
table_name NOT LIKE 'falcon%' AND
130
 
table_name NOT LIKE 'MEMCACHED%'
131
 
GROUP BY TABLE_SCHEMA;
 
159
WHERE table_name NOT LIKE 'ndb_%' AND table_name NOT LIKE 'falcon%' GROUP BY TABLE_SCHEMA;
132
160
 
133
161
#
134
162
# Bug #9434 SHOW CREATE DATABASE information_schema;
145
173
from information_schema.columns
146
174
where table_name='t1';
147
175
drop table t1;
148
 
create table t1(f1 int, f2 int, f3 BIGINT, f4 int,
149
 
                f5 BIGINT, f6 int, f7 int);
 
176
create table t1(f1 tinyint, f2 SMALLINT, f3 mediumint, f4 int,
 
177
                f5 BIGINT, f6 BIT, f7 bit(64));
150
178
select column_name, NUMERIC_PRECISION, NUMERIC_SCALE
151
179
from information_schema.columns
152
180
where table_name='t1';
164
192
drop table t1;
165
193
 
166
194
#
 
195
# Bug #12636: SHOW TABLE STATUS with where condition containing a subquery
 
196
#             over information schema
 
197
#
 
198
 
 
199
CREATE TABLE t1 (a int);
 
200
CREATE TABLE t2 (b int);
 
201
 
 
202
--replace_column 8 # 12 # 13 #
 
203
SHOW TABLE STATUS FROM test
 
204
  WHERE name IN ( SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES
 
205
                    WHERE TABLE_SCHEMA='test' AND TABLE_TYPE='BASE TABLE');
 
206
 
 
207
DROP TABLE t1,t2;
 
208
 
 
209
#
167
210
# Bug #9846 Inappropriate error displayed while dropping table from 'INFORMATION_SCHEMA'
168
211
#
169
212
--error ER_PARSE_ERROR
170
213
alter database information_schema;
171
214
--error ER_DBACCESS_DENIED_ERROR
172
215
drop database information_schema;
173
 
use information_schema;
174
 
--error 1044
175
 
drop table tables;
176
 
--error 1044
177
 
alter table tables;
 
216
--error 1044
 
217
drop table information_schema.tables;
 
218
--error 1044
 
219
alter table information_schema.tables;
178
220
#
179
221
# Bug #9683 INFORMATION_SCH: Creation of temporary table allowed in Information_schema DB
180
222
#
207
249
#
208
250
# Bug#14271 I_S: columns has no size for (var)binary columns
209
251
#
210
 
create table t1(f1 varbinary(32), f2 varbinary(64));
 
252
create table t1(f1 binary(32), f2 varbinary(64));
211
253
select character_maximum_length, character_octet_length
212
254
from information_schema.columns where table_name='t1';
213
255
drop table t1;
220
262
table_schema='information_schema' and
221
263
(column_type = 'varchar(7)' or column_type = 'varchar(20)'
222
264
 or column_type = 'varchar(27)')
223
 
group by column_type order by column_type, num;
 
265
group by column_type order by num;
224
266
 
225
267
#
226
268
# Bug#19236 bad COLUMNS.CHARACTER_MAXIMUM_LENGHT and CHARACTER_OCTET_LENGTH
227
269
#
228
 
create table t1(f1 char(1) not null, f2 char(9) not null);
 
270
create table t1(f1 char(1) not null, f2 char(9) not null)
 
271
default character set utf8;
229
272
select CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH from
230
273
information_schema.columns where table_schema='test' and table_name = 't1';
231
274
drop table t1;
258
301
                  c2.table_name = t.table_name AND
259
302
                  c2.column_name LIKE '%SCHEMA%'
260
303
        )
261
 
  AND t.table_name NOT LIKE 'falcon%'
262
 
  AND t.table_name NOT LIKE 'MEMCACHED%';
 
304
  AND t.table_name NOT LIKE 'falcon%';
263
305
SELECT t.table_name, c1.column_name
264
306
  FROM information_schema.tables t
265
307
       INNER JOIN
274
316
                  c2.table_name = t.table_name AND
275
317
                  c2.column_name LIKE '%SCHEMA%'
276
318
        )
277
 
  AND t.table_name NOT LIKE 'falcon%'
278
 
  AND t.table_name NOT LIKE 'MEMCACHED%';
 
319
  AND t.table_name NOT LIKE 'falcon%';
279
320
 
280
321
#
281
322
# Bug#21231: query with a simple non-correlated subquery over
289
330
#
290
331
# Bug#23299 Some queries against INFORMATION_SCHEMA with subqueries fail
291
332
#
292
 
create table t1 (f1 int);
293
 
create table t2 (f1 int, f2 int);
 
333
create table t1 (f1 int(11));
 
334
create table t2 (f1 int(11), f2 int(11));
294
335
 
295
336
select table_name from information_schema.tables
296
337
where table_schema = 'test' and table_name not in
313
354
on t.table_schema = c1.table_schema AND t.table_name = c1.table_name
314
355
where t.table_schema = 'information_schema' AND
315
356
      t.table_name not like 'falcon%' AND
316
 
      t.table_name not like 'MEMCACHED%' AND
317
357
        c1.ordinal_position =
318
358
        (select isnull(c2.column_type) -
319
359
         isnull(group_concat(c2.table_schema, '.', c2.table_name)) +
391
431
select * from information_schema.tables where table_name = NULL;
392
432
select * from `information_schema`.`TABLE_CONSTRAINTS` where `TABLE_SCHEMA` = NULL;
393
433
select * from `information_schema`.`TABLE_CONSTRAINTS` where `TABLE_NAME` = NULL;
394
 
 
395
 
--echo #
396
 
--echo # Test that the query is visible to self and others.
397
 
--echo #
398
 
 
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;
406
 
 
407
 
#
408
 
# do a query on the PROCESSLIST table in I_S to ensure it works correctly
409
 
#
410
 
SELECT info, command, db
411
 
FROM information_schema.processlist
412
 
WHERE id = CONNECTION_ID();
413
 
 
414
 
#
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 NOT LIKE 'MEMCACHED%'
441
 
ORDER BY table_name;
442
 
 
443
 
#
444
 
# perform a query on KEY_COLUMN_USAGE
445
 
#
446
 
SELECT *
447
 
FROM information_schema.key_column_usage;
448
 
 
449
 
#
450
 
# perform a query on REFERENTIAL_CONSTRAINTS
451
 
#
452
 
SELECT * 
453
 
FROM information_schema.referential_constraints;
454
 
 
455
 
#
456
 
# query the SCHEMATA table
457
 
#
458
 
SELECT catalog_name, schema_name
459
 
FROM information_schema.schemata
460
 
ORDER BY schema_name;
461
 
 
462
 
#
463
 
# Query the STATUS and VARIABLES related
464
 
# I_S related tables. 
465
 
#
466
 
--replace_column 1 # 2 #
467
 
SELECT *
468
 
FROM information_schema.session_status
469
 
ORDER BY variable_name;
470
 
 
471
 
--replace_column 1 # 2 #
472
 
SHOW STATUS;
473
 
 
474
 
#--replace_column 1 # 2 #
475
 
#SELECT *
476
 
#FROM information_schema.session_variables
477
 
#ORDER BY variable_name;
478
 
 
479
 
#--replace_column 1 # 2 #
480
 
#SHOW VARIABLES;
481
 
 
482
 
--replace_column 1 # 2 #
483
 
SELECT *
484
 
FROM information_schema.global_status
485
 
ORDER BY variable_name;
486
 
 
487
 
#--replace_column 1 # 2 #
488
 
#SELECT *
489
 
#FROM information_schema.global_variables
490
 
#ORDER BY variable_name;
491
 
 
492
 
#
493
 
# query TABLE_CONSTRAINTS table
494
 
#
495
 
SELECT *
496
 
FROM information_schema.table_constraints;
497
 
 
498
 
#
499
 
# query TABLES
500
 
#
501
 
SELECT table_schema, table_name
502
 
FROM information_schema.tables
503
 
WHERE table_name NOT LIKE 'MEMCACHED%'
504
 
ORDER BY table_name;
505
 
 
506
 
507
 
# do a query on the PLUGINS table in I_S to ensure it works correctly
508
 
# how do we test for this if the contents of this table can change
509
 
# depend on what plugins are configured for use?
510
 
#
511
 
#SELECT *
512
 
#FROM plugins;