~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/information_schema.test

  • Committer: Jay Pipes
  • Date: 2008-09-11 16:03:22 UTC
  • mto: (383.5.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 386.
  • Revision ID: jay@mysql.com-20080911160322-vrl0k1djo6q6ytv1
Removed SQL_MODE variances from comment_table.test and ensured correct error thrown when a comment that is too long was input.  After moving to proto buffer definition for table, the 2048 length will go away.

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