~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/information_schema.test

  • Committer: Monty Taylor
  • Date: 2008-08-01 22:33:44 UTC
  • mto: (236.1.42 codestyle)
  • mto: This revision was merged to the branch mainline in revision 261.
  • Revision ID: monty@inaugust.com-20080801223344-vzhlflfmtijp1imv
First pass at gettexizing the error messages.

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