~drizzle-trunk/drizzle/development

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
# Test for data_dictionary.schemas &
# show databases

--disable_warnings
DROP TABLE IF EXISTS t0,t1,t2,t3,t4,t5;
DROP SCHEMA IF EXISTS data_dictionary;
--enable_warnings
CREATE SCHEMA data_dictionary;

--replace_column 1 #
select count(*) from data_dictionary.SCHEMAS where schema_name > 'm';
--replace_column 1 #
select count(*) from data_dictionary.schemas;
show databases like 't%';
show databases;

# Test for data_dictionary.tables &
# show tables

create database mysqltest;
create table mysqltest.t1(a int, b VARCHAR(30), KEY string_data (b));
create table test.t2(a int);
create table t3(a int, KEY a_data (a));
create table mysqltest.t4(a int);
create table t5 (id int auto_increment primary key);
insert into t5 values (10);

select table_name from data_dictionary.TABLES
where table_schema = "mysqltest" and table_name like "t%";

show tables like 't%';
--replace_column 8 # 12 # 13 #
show table status;
show columns from t3 like "a%";
select * from data_dictionary.COLUMNS where table_name="t1"
and column_name= "a";

connect (user3,localhost,mysqltest_2,,);
connection user3;
select table_name, column_name from data_dictionary.columns 
where table_schema = 'mysqltest' and table_name = 't1';
show columns from mysqltest.t1;
connect (user4,localhost,mysqltest_3,,mysqltest);
connection user4;
connection default;

drop tables mysqltest.t4, mysqltest.t1, t2, t3, t5;
drop database mysqltest;

# Test for data_dictionary.CHARACTER_SETS &
select * from data_dictionary.CHARACTER_SETS
where CHARACTER_SET_NAME like 'latin1%';

# Test for data_dictionary.COLLATIONS &

--replace_column 5 #
select * from data_dictionary.COLLATIONS
where COLLATION_NAME like 'latin1%';

#
# Bug#2719 data_dictionary: errors in "columns"
#
select DATA_TYPE from data_dictionary.columns
where table_schema="data_dictionary" and table_name="COLUMNS" and
(column_name="character_set_name" or column_name="collation_name");

#
# Bug#2718 data_dictionary: errors in "tables"
#
select TABLE_TYPE from data_dictionary.tables where 
table_schema="data_dictionary" and table_name="COLUMNS";
select table_type from data_dictionary.tables
where table_schema="mysql" and table_name="user";

#
# Bug #7215  data_dictionary: columns are longtext instead of varchar
# Bug #7217  data_dictionary: columns are varbinary() instead of timestamp
#
select table_schema,table_name, column_name from
data_dictionary.columns 
where DATA_TYPE = 'longtext';
select table_name, column_name, DATA_TYPE from data_dictionary.columns
where DATA_TYPE = 'datetime';

#
# Bug #8164  subquery with DATA_DICTIONARY.COLUMNS, 100 % CPU
#
SELECT COUNT(*) FROM DATA_DICTIONARY.TABLES A
WHERE NOT EXISTS 
(SELECT * FROM DATA_DICTIONARY.COLUMNS B
  WHERE A.TABLE_SCHEMA = B.TABLE_SCHEMA
  AND A.TABLE_NAME = B.TABLE_NAME);

#
# Bug #9344  DATA_DICTIONARY, wrong content, numeric columns
#

create table t1
( x_bigint BIGINT,
  x_integer INTEGER,
  x_int int,
  x_decimal DECIMAL(5,3),
  x_numeric NUMERIC(5,3),
  x_real REAL,
  x_float FLOAT,
  x_double_precision DOUBLE PRECISION );
SELECT COLUMN_NAME, CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH
FROM DATA_DICTIONARY.COLUMNS
WHERE TABLE_NAME= 't1';
drop table t1;

#
# Bug #9404  data_dictionary: Weird error messages
# with SELECT SUM() ... GROUP BY queries
#
SELECT table_schema, count(*) FROM data_dictionary.TABLES
WHERE table_name NOT LIKE 'ndb_%' AND 
table_name NOT LIKE 'falcon%' AND
ENGINE IS NULL
GROUP BY TABLE_SCHEMA;

#
# Bug #9434 SHOW CREATE DATABASE data_dictionary;
#
#show create database data_dictionary;

#
# Bug #11057 data_dictionary: columns table has some questionable contents
# Bug #12301 data_dictionary: NUMERIC_SCALE must be 0 for integer columns
#
create table t1(f1 LONGBLOB, f2 LONGTEXT);
select column_name, DATA_TYPE, CHARACTER_OCTET_LENGTH,
       CHARACTER_MAXIMUM_LENGTH
from data_dictionary.columns
where table_name='t1';
drop table t1;
create table t1(f1 int, f2 int, f3 BIGINT, f4 int,
                f5 BIGINT, f6 int, f7 int);
select column_name, NUMERIC_PRECISION, NUMERIC_SCALE
from data_dictionary.columns
where table_name='t1';
drop table t1;

#
# Bug#12518 COLUMN_DEFAULT has wrong value if NOT NULL is set
#
create table t1 (a int not null, b int);
use data_dictionary;
select column_name, column_default from columns
  where table_schema='test' and table_name='t1';
use test;
show columns from t1;
drop table t1;

#
# Bug #9846 Inappropriate error displayed while dropping table from
# 'DATA_DICTIONARY'
#
--error ER_PARSE_ERROR
alter database data_dictionary;
use data_dictionary;
#--error 1044
#drop table tables;
#--error 1044
#alter table tables;
#
# Bug #9683 INFORMATION_SCH: Creation of temporary table allowed in Information_schema DB
#
use data_dictionary;
--error 1044
create temporary table schemas(f1 char(10));
#
#
# Bug#14089 FROM list subquery always fails when data_dictionary is current database
#
use test;
create table t1(id int);
insert into t1(id) values (1);
select 1 from (select 1 from test.t1) a;
use data_dictionary;
select 1 from (select 1 from test.t1) a;
use test;
drop table t1;

# Bug #14387 SHOW COLUMNS doesn't work on temporary tables
# Bug #15224 SHOW INDEX from temporary table doesn't work
# Bug #12770 DESC cannot display the info. about temporary table
#
create temporary table t1(f1 int, index(f1));
show columns from t1;
describe t1;
show indexes from t1;
drop table t1;

#
# Bug#14271 I_S: columns has no size for (var)binary columns
#
create table t1(f1 varbinary(32), f2 varbinary(64));
select character_maximum_length, character_octet_length
from data_dictionary.columns where table_name='t1';
drop table t1;

#
# Bug#15307 GROUP_CONCAT() with ORDER BY returns empty set on data_dictionary
#
select DATA_TYPE, group_concat(table_schema, '.', table_name), count(*) as num
from data_dictionary.columns where
table_schema='data_dictionary' and
(DATA_TYPE = 'varchar' or DATA_TYPE = 'varchar'
 or DATA_TYPE = 'varchar')
group by DATA_TYPE order by DATA_TYPE, num;

#
# Bug#19236 bad COLUMNS.CHARACTER_MAXIMUM_LENGHT and CHARACTER_OCTET_LENGTH
#
create table t1(f1 char(1) not null, f2 char(9) not null);
select CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH from
data_dictionary.columns where table_schema='test' and table_name = 't1';
drop table t1;

#
# Bug#19599 duplication of data_dictionary column value in a CONCAT expr with user var
#
set @a:= '.';
create table t1(f1 char(5));
create table t2(f1 char(5));
select concat(@a, table_name), @a, table_name
from data_dictionary.tables where table_schema = 'test';
drop table t1,t2;

#
# Bug#18925: subqueries with MIN/MAX functions on INFORMARTION_SCHEMA 
#

SELECT t.table_name, c1.column_name
  FROM data_dictionary.tables t
       INNER JOIN
       data_dictionary.columns c1
       ON t.table_schema = c1.table_schema AND
          t.table_name = c1.table_name
  WHERE t.table_schema = 'data_dictionary' AND
        c1.ordinal_position =
        ( SELECT COALESCE(MIN(c2.ordinal_position),1)
            FROM data_dictionary.columns c2
            WHERE c2.table_schema = t.table_schema AND
                  c2.table_name = t.table_name AND
                  c2.column_name LIKE '%SCHEMA%'
        )
  AND t.table_name NOT LIKE 'falcon%'
  AND t.ENGINE IS NULL;
SELECT t.table_name, c1.column_name
  FROM data_dictionary.tables t
       INNER JOIN
       data_dictionary.columns c1
       ON t.table_schema = c1.table_schema AND
          t.table_name = c1.table_name
  WHERE t.table_schema = 'data_dictionary' AND
        c1.ordinal_position =
        ( SELECT COALESCE(MIN(c2.ordinal_position),1)
            FROM data_dictionary.columns c2
            WHERE c2.table_schema = 'data_dictionary' AND
                  c2.table_name = t.table_name AND
                  c2.column_name LIKE '%SCHEMA%'
        )
  AND t.table_name NOT LIKE 'falcon%'
  AND t.ENGINE IS NULL;

#
# Bug#21231: query with a simple non-correlated subquery over
#            INFORMARTION_SCHEMA.TABLES 
#

SELECT MAX(table_name) FROM data_dictionary.tables;
SELECT table_name from data_dictionary.tables
  WHERE table_name=(SELECT MAX(table_name)
                      FROM data_dictionary.tables);
#
# Bug#23299 Some queries against DATA_DICTIONARY with subqueries fail
#
create table t1 (f1 int);
create table t2 (f1 int, f2 int);

select table_name from data_dictionary.tables
where table_schema = 'test' and table_name not in
(select table_name from data_dictionary.columns
 where table_schema = 'test' and column_name = 'f3');
drop table t1,t2;


#
# Bug#24630  Subselect query crashes mysqld
#
select 1 as f1 from data_dictionary.tables  where "CHARACTER_SETS"=
(select cast(table_name as char)  from data_dictionary.tables
 order by table_name limit 1) limit 1;

select t.table_name, group_concat(t.table_schema, '.', t.table_name),
       count(*) as num1
from data_dictionary.tables t
inner join data_dictionary.columns c1
on t.table_schema = c1.table_schema AND t.table_name = c1.table_name
where t.table_schema = 'data_dictionary' AND
      t.table_name not like 'falcon%' AND
      t.ENGINE IS NULL AND
        c1.ordinal_position =
        (select isnull(c2.DATA_TYPE) -
         isnull(group_concat(c2.table_schema, '.', c2.table_name)) +
         count(*) as num
         from data_dictionary.columns c2 where
         c2.table_schema='data_dictionary' and
         (c2.DATA_TYPE = 'varchar' or c2.DATA_TYPE = 'varchar')
          group by c2.DATA_TYPE order by num limit 1)
group by t.table_name order by num1, t.table_name;

#
# Bug#25859    ALTER DATABASE works w/o parameters
#
--error ER_PARSE_ERROR
alter database;
--error ER_PARSE_ERROR
alter database test;

#
# Bug#27747 database metadata doesn't return sufficient column default info
#
create table t1 (
  f1 varchar(50),
  f2 varchar(50) not null,
  f3 varchar(50) default '',
  f4 varchar(50) default NULL,
  f5 bigint not null,
  f6 bigint not null default 10,
  f7 datetime not null,
  f8 datetime default '2006-01-01'
);
select column_default from data_dictionary.columns where table_name= 't1';
show columns from t1;
drop table t1;

#
# Bug#30079 A check for "hidden" I_S tables is flawed
#
#--error 1109
#show fields from data_dictionary.table_names;
#--error 1109
#show keys from data_dictionary.table_names;

SET max_heap_table_size = DEFAULT;
USE test;

--echo End of 5.0 tests.

#
# Bug#30795 Query on DATA_DICTIONARY.SCHEMAS, wrong result
#
SELECT SCHEMA_NAME FROM DATA_DICTIONARY.SCHEMAS
WHERE SCHEMA_NAME ='data_dictionary';
                                                                                                 
#
# Bug#31381 Error in retrieving Data from DATA_DICTIONARY
#
SELECT TABLE_COLLATION FROM DATA_DICTIONARY.TABLES
WHERE TABLE_SCHEMA='mysql' and TABLE_NAME= 'db';

#
# Bug#31633 Information schema = NULL queries crash the server
#
select * from data_dictionary.columns where table_schema = NULL;
select * from `data_dictionary`.`COLUMNS` where `TABLE_NAME` = NULL;
select * from `data_dictionary`.`INDEXES` where `TABLE_SCHEMA` = NULL;
select * from `data_dictionary`.`INDEXES` where `TABLE_NAME` = NULL;
#select * from `data_dictionary`.`REFERENTIAL_CONSTRAINTS` where `CONSTRAINT_SCHEMA` = NULL;
#select * from `data_dictionary`.`REFERENTIAL_CONSTRAINTS` where `TABLE_NAME` = NULL;
select * from data_dictionary.schemas where schema_name = NULL;
select * from data_dictionary.tables where table_schema = NULL;
select * from data_dictionary.tables where table_name = NULL;
#select * from `data_dictionary`.`TABLE_CONSTRAINTS` where `TABLE_SCHEMA` = NULL;
#select * from `data_dictionary`.`TABLE_CONSTRAINTS` where `TABLE_NAME` = NULL;

--echo #
--echo # Test that the query is visible to self and others.
--echo #

SELECT info FROM data_dictionary.processlist WHERE id = CONNECTION_ID();

#
# test that SHOW PROCESSLIST works correctly
#
--replace_column 1 # 2 # 3 # 6 # 7 #
#show processlist;

#
# do a query on the PROCESSLIST table in I_S to ensure it works correctly
#
#--replace_column 1 # 2 # 3
#SELECT info, command, db FROM data_dictionary.processlist WHERE id = CONNECTION_ID();

#
# do a query on the CHARACTER_SET table in I_S 
#
SELECT * FROM data_dictionary.character_sets ORDER BY character_set_name;

#
# perform a query on the COLLATIONS table
#
SELECT * FROM data_dictionary.collations ORDER BY collation_name;

#
# perform a query on COLUMNS
#
SELECT table_name, column_name
FROM data_dictionary.columns
WHERE table_name IN
(SELECT table_name FROM data_dictionary.tables 
 WHERE ENGINE IS NULL)
ORDER BY table_name;

#
# perform a query on REFERENTIAL_CONSTRAINTS
#
#SELECT * FROM data_dictionary.referential_constraints;

#
# query the SCHEMAS table
#
--replace_column 1 #
SELECT count(schema_name) FROM data_dictionary.schemas ORDER BY schema_name;

#
# Query the STATUS and VARIABLES related
# I_S related tables. 
#
--replace_column 1 #
SELECT count(*) FROM data_dictionary.session_status ORDER BY variable_name;

--replace_column 1 #
SELECT count(*) FROM data_dictionary.session_variables ORDER BY variable_name;

--replace_column 1 #
SELECT count(*) FROM data_dictionary.global_status ORDER BY variable_name;

--replace_column 1 #
SELECT count(*) FROM data_dictionary.global_variables ORDER BY variable_name;

#
# query TABLE_CONSTRAINTS table
#
#--replace_column 1 #
#SELECT count(*) FROM data_dictionary.table_constraints; 

#
# query TABLES
#
SELECT table_schema, table_name FROM data_dictionary.tables WHERE ENGINE IS NULL ORDER BY table_name;

# 
# do a query on the PLUGINS table in I_S to ensure it works correctly
# how do we test for this if the contents of this table can change
# depend on what plugins are configured for use?
#
--replace_column 1 #
SELECT count(*) FROM data_dictionary.plugins;

--disable_warnings
DROP SCHEMA IF EXISTS data_dictionary;
--enable_warnings