~drizzle-trunk/drizzle/development

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