~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/data_dictionary_like_info.test

  • Committer: Brian Aker
  • Date: 2010-02-14 02:02:48 UTC
  • mfrom: (1273.13.64 fix_is)
  • Revision ID: brian@gaz-20100214020248-bhovaejhz9fmer3q
MergeĀ inĀ data_dictionary.

Show diffs side-by-side

added added

removed removed

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