~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/r/data_dictionary_like_info.result

Big ole patch. This covers moving information_schema to  old_* table names
(to not have plugins bang against each other).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
DROP TABLE IF EXISTS t0,t1,t2,t3,t4,t5;
 
2
DROP SCHEMA IF EXISTS data_dictionary;
 
3
CREATE SCHEMA data_dictionary;
 
4
select * from data_dictionary.SCHEMAS where schema_name > 'm';
 
5
SCHEMA_NAME     DEFAULT_COLLATION_NAME
 
6
select schema_name from data_dictionary.schemas;
 
7
schema_name
 
8
data_dictionary
 
9
information_schema
 
10
 
 
11
 
 
12
create database mysqltest;
 
13
create table mysqltest.t1(a int, b VARCHAR(30), KEY string_data (b));
 
14
create table test.t2(a int);
 
15
create table t3(a int, KEY a_data (a));
 
16
create table mysqltest.t4(a int);
 
17
create table t5 (id int auto_increment primary key);
 
18
insert into t5 values (10);
 
19
select table_name from data_dictionary.TABLES
 
20
where table_schema = "mysqltest" and table_name like "t%";
 
21
table_name
 
22
t1
 
23
t4
 
24
select * from data_dictionary.COLUMNS where table_name="t1"
 
25
and column_name= "a";
 
26
TABLE_SCHEMA    TABLE_NAME      COLUMN_NAME     ORDINAL_POSITION        COLUMN_DEFAULT  IS_NULLABLE     DATATYPE        CHARACTER_MAXIMUM_LENGTH        CHARACTER_OCTET_LENGTH  NUMERIC_PRECISION       NUMERIC_SCALE   COLLATION_NAME  COLUMN_COMMENT
 
27
mysqltest       t1      a       0               TRUE    4       #       0       0       0       #       #
 
28
select table_name, column_name from data_dictionary.columns 
 
29
where table_schema = 'mysqltest' and table_name = 't1';
 
30
table_name      column_name
 
31
t1      a
 
32
t1      b
 
33
drop tables mysqltest.t4, mysqltest.t1, t2, t3, t5;
 
34
drop database mysqltest;
 
35
select * from data_dictionary.CHARACTER_SETS
 
36
where CHARACTER_SET_NAME like 'latin1%';
 
37
CHARACTER_SET_NAME      DEFAULT_COLLATE_NAME    DESCRIPTION     MAXLEN
 
38
select * from data_dictionary.COLLATIONS
 
39
where COLLATION_NAME like 'latin1%';
 
40
CHARACTER_SET_NAME      COLLATION_NAME  DESCRIPTION     ID      IS_DEFAULT      IS_COMPILED     SORTLEN
 
41
select DATATYPE from data_dictionary.columns
 
42
where table_schema="data_dictionary" and table_name="COLUMNS" and
 
43
(column_name="character_set_name" or column_name="collation_name");
 
44
DATATYPE
 
45
1
 
46
select TABLE_TYPE from data_dictionary.tables where 
 
47
table_schema="data_dictionary" and table_name="COLUMNS";
 
48
TABLE_TYPE
 
49
FUNCTION
 
50
select table_type from data_dictionary.tables
 
51
where table_schema="mysql" and table_name="user";
 
52
table_type
 
53
select table_schema,table_name, column_name from
 
54
data_dictionary.columns 
 
55
where DATATYPE = 'longtext';
 
56
table_schema    table_name      column_name
 
57
select table_name, column_name, DATATYPE from data_dictionary.columns
 
58
where DATATYPE = 'datetime';
 
59
table_name      column_name     DATATYPE
 
60
SELECT COUNT(*) FROM DATA_DICTIONARY.TABLES A
 
61
WHERE NOT EXISTS 
 
62
(SELECT * FROM DATA_DICTIONARY.COLUMNS B
 
63
WHERE A.TABLE_SCHEMA = B.TABLE_SCHEMA
 
64
AND A.TABLE_NAME = B.TABLE_NAME);
 
65
COUNT(*)
 
66
0
 
67
create table t1
 
68
( x_bigint BIGINT,
 
69
x_integer INTEGER,
 
70
x_int int,
 
71
x_decimal DECIMAL(5,3),
 
72
x_numeric NUMERIC(5,3),
 
73
x_real REAL,
 
74
x_float FLOAT,
 
75
x_double_precision DOUBLE PRECISION );
 
76
SELECT COLUMN_NAME, CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH
 
77
FROM DATA_DICTIONARY.COLUMNS
 
78
WHERE TABLE_NAME= 't1';
 
79
COLUMN_NAME     CHARACTER_MAXIMUM_LENGTH        CHARACTER_OCTET_LENGTH
 
80
x_bigint        0       0
 
81
x_integer       0       0
 
82
x_int   0       0
 
83
x_decimal       0       0
 
84
x_numeric       0       0
 
85
x_real  0       0
 
86
x_float 0       0
 
87
x_double_precision      0       0
 
88
drop table t1;
 
89
SELECT table_schema, count(*) FROM data_dictionary.TABLES
 
90
WHERE table_name NOT LIKE 'ndb_%' AND 
 
91
table_name NOT LIKE 'falcon%' AND
 
92
ENGINE IS NULL
 
93
GROUP BY TABLE_SCHEMA;
 
94
table_schema    count(*)
 
95
create table t1(f1 LONGBLOB, f2 LONGTEXT);
 
96
select column_name,DATATYPE,CHARACTER_OCTET_LENGTH,
 
97
CHARACTER_MAXIMUM_LENGTH
 
98
from data_dictionary.columns
 
99
where table_name='t1';
 
100
column_name     DATATYPE        CHARACTER_OCTET_LENGTH  CHARACTER_MAXIMUM_LENGTH
 
101
f1      2       0       0
 
102
f2      2       0       0
 
103
drop table t1;
 
104
create table t1(f1 int, f2 int, f3 BIGINT, f4 int,
 
105
f5 BIGINT, f6 int, f7 int);
 
106
select column_name, NUMERIC_PRECISION, NUMERIC_SCALE
 
107
from data_dictionary.columns
 
108
where table_name='t1';
 
109
column_name     NUMERIC_PRECISION       NUMERIC_SCALE
 
110
f1      0       0
 
111
f2      0       0
 
112
f3      0       0
 
113
f4      0       0
 
114
f5      0       0
 
115
f6      0       0
 
116
f7      0       0
 
117
drop table t1;
 
118
create table t1 (a int not null, b int);
 
119
use data_dictionary;
 
120
select column_name, column_default from columns
 
121
where table_schema='test' and table_name='t1';
 
122
column_name     column_default
 
123
a       
 
124
b       
 
125
use test;
 
126
drop table t1;
 
127
alter database data_dictionary;
 
128
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your Drizzle server version for the right syntax to use near '' at line 1
 
129
use data_dictionary;
 
130
use data_dictionary;
 
131
create temporary table schemas(f1 char(10));
 
132
ERROR 42000: Access denied for user ''@'' to database 'data_dictionary'
 
133
use test;
 
134
create table t1(id int);
 
135
insert into t1(id) values (1);
 
136
select 1 from (select 1 from test.t1) a;
 
137
1
 
138
1
 
139
use data_dictionary;
 
140
select 1 from (select 1 from test.t1) a;
 
141
1
 
142
1
 
143
use test;
 
144
drop table t1;
 
145
create temporary table t1(f1 int, index(f1));
 
146
drop table t1;
 
147
create table t1(f1 varbinary(32), f2 varbinary(64));
 
148
select character_maximum_length, character_octet_length
 
149
from data_dictionary.columns where table_name='t1';
 
150
character_maximum_length        character_octet_length
 
151
32      128
 
152
64      256
 
153
drop table t1;
 
154
select DATATYPE, group_concat(table_schema, '.', table_name), count(*) as num
 
155
from data_dictionary.columns where
 
156
table_schema='data_dictionary' and
 
157
(DATATYPE = 'varchar' or DATATYPE = 'varchar'
 
158
 or DATATYPE = 'varchar')
 
159
group by DATATYPE order by DATATYPE, num;
 
160
DATATYPE        group_concat(table_schema, '.', table_name)     num
 
161
create table t1(f1 char(1) not null, f2 char(9) not null);
 
162
select CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH from
 
163
data_dictionary.columns where table_schema='test' and table_name = 't1';
 
164
CHARACTER_MAXIMUM_LENGTH        CHARACTER_OCTET_LENGTH
 
165
1       4
 
166
9       36
 
167
drop table t1;
 
168
set @a:= '.';
 
169
create table t1(f1 char(5));
 
170
create table t2(f1 char(5));
 
171
select concat(@a, table_name), @a, table_name
 
172
from data_dictionary.tables where table_schema = 'test';
 
173
concat(@a, table_name)  @a      table_name
 
174
.t1     .       t1
 
175
.t2     .       t2
 
176
drop table t1,t2;
 
177
SELECT t.table_name, c1.column_name
 
178
FROM data_dictionary.tables t
 
179
INNER JOIN
 
180
data_dictionary.columns c1
 
181
ON t.table_schema = c1.table_schema AND
 
182
t.table_name = c1.table_name
 
183
WHERE t.table_schema = 'data_dictionary' AND
 
184
c1.ordinal_position =
 
185
( SELECT COALESCE(MIN(c2.ordinal_position),1)
 
186
FROM data_dictionary.columns c2
 
187
WHERE c2.table_schema = t.table_schema AND
 
188
c2.table_name = t.table_name AND
 
189
c2.column_name LIKE '%SCHEMA%'
 
190
        )
 
191
AND t.table_name NOT LIKE 'falcon%'
 
192
  AND t.ENGINE IS NULL;
 
193
table_name      column_name
 
194
SELECT t.table_name, c1.column_name
 
195
FROM data_dictionary.tables t
 
196
INNER JOIN
 
197
data_dictionary.columns c1
 
198
ON t.table_schema = c1.table_schema AND
 
199
t.table_name = c1.table_name
 
200
WHERE t.table_schema = 'data_dictionary' AND
 
201
c1.ordinal_position =
 
202
( SELECT COALESCE(MIN(c2.ordinal_position),1)
 
203
FROM data_dictionary.columns c2
 
204
WHERE c2.table_schema = 'data_dictionary' AND
 
205
c2.table_name = t.table_name AND
 
206
c2.column_name LIKE '%SCHEMA%'
 
207
        )
 
208
AND t.table_name NOT LIKE 'falcon%'
 
209
  AND t.ENGINE IS NULL;
 
210
table_name      column_name
 
211
SELECT MAX(table_name) FROM data_dictionary.tables;
 
212
MAX(table_name)
 
213
TABLE_CONSTRAINTS
 
214
SELECT table_name from data_dictionary.tables
 
215
WHERE table_name=(SELECT MAX(table_name)
 
216
FROM data_dictionary.tables);
 
217
table_name
 
218
TABLE_CONSTRAINTS
 
219
create table t1 (f1 int);
 
220
create table t2 (f1 int, f2 int);
 
221
select table_name from data_dictionary.tables
 
222
where table_schema = 'test' and table_name not in
 
223
(select table_name from data_dictionary.columns
 
224
where table_schema = 'test' and column_name = 'f3');
 
225
table_name
 
226
t1
 
227
t2
 
228
drop table t1,t2;
 
229
select 1 as f1 from data_dictionary.tables  where "CHARACTER_SETS"=
 
230
(select cast(table_name as char)  from data_dictionary.tables
 
231
order by table_name limit 1) limit 1;
 
232
f1
 
233
1
 
234
select t.table_name, group_concat(t.table_schema, '.', t.table_name),
 
235
count(*) as num1
 
236
from data_dictionary.tables t
 
237
inner join data_dictionary.columns c1
 
238
on t.table_schema = c1.table_schema AND t.table_name = c1.table_name
 
239
where t.table_schema = 'data_dictionary' AND
 
240
t.table_name not like 'falcon%' AND
 
241
t.ENGINE IS NULL AND
 
242
c1.ordinal_position =
 
243
(select isnull(c2.DATATYPE) -
 
244
isnull(group_concat(c2.table_schema, '.', c2.table_name)) +
 
245
count(*) as num
 
246
from data_dictionary.columns c2 where
 
247
c2.table_schema='data_dictionary' and
 
248
(c2.DATATYPE = 'varchar' or c2.DATATYPE = 'varchar')
 
249
group by c2.DATATYPE order by num limit 1)
 
250
group by t.table_name order by num1, t.table_name;
 
251
table_name      group_concat(t.table_schema, '.', t.table_name) num1
 
252
alter database;
 
253
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your Drizzle server version for the right syntax to use near '' at line 1
 
254
alter database test;
 
255
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your Drizzle server version for the right syntax to use near '' at line 1
 
256
create table t1 (
 
257
f1 varchar(50),
 
258
f2 varchar(50) not null,
 
259
f3 varchar(50) default '',
 
260
f4 varchar(50) default NULL,
 
261
f5 bigint not null,
 
262
f6 bigint not null default 10,
 
263
f7 datetime not null,
 
264
f8 datetime default '2006-01-01'
 
265
);
 
266
select column_default from data_dictionary.columns where table_name= 't1';
 
267
column_default
 
268
 
 
269
 
 
270
 
 
271
 
 
272
 
 
273
10
 
274
 
 
275
2006-01-01
 
276
drop table t1;
 
277
SET max_heap_table_size = DEFAULT;
 
278
USE test;
 
279
End of 5.0 tests.
 
280
SELECT SCHEMA_NAME FROM DATA_DICTIONARY.SCHEMAS
 
281
WHERE SCHEMA_NAME ='data_dictionary';
 
282
SCHEMA_NAME
 
283
data_dictionary
 
284
SELECT TABLE_COLLATION FROM DATA_DICTIONARY.TABLES
 
285
WHERE TABLE_SCHEMA='mysql' and TABLE_NAME= 'db';
 
286
TABLE_COLLATION
 
287
select * from data_dictionary.columns where table_schema = NULL;
 
288
TABLE_SCHEMA    TABLE_NAME      COLUMN_NAME     ORDINAL_POSITION        COLUMN_DEFAULT  IS_NULLABLE     DATATYPE        CHARACTER_MAXIMUM_LENGTH        CHARACTER_OCTET_LENGTH  NUMERIC_PRECISION       NUMERIC_SCALE   COLLATION_NAME  COLUMN_COMMENT
 
289
select * from `data_dictionary`.`COLUMNS` where `TABLE_NAME` = NULL;
 
290
TABLE_SCHEMA    TABLE_NAME      COLUMN_NAME     ORDINAL_POSITION        COLUMN_DEFAULT  IS_NULLABLE     DATATYPE        CHARACTER_MAXIMUM_LENGTH        CHARACTER_OCTET_LENGTH  NUMERIC_PRECISION       NUMERIC_SCALE   COLLATION_NAME  COLUMN_COMMENT
 
291
select * from `data_dictionary`.`INDEXES` where `TABLE_SCHEMA` = NULL;
 
292
TABLE_SCHEMA    TABLE_NAME      INDEX_NAME      IS_PRIMARY      IS_UNIQUE       IS_NULLABLE     KEY_LENGTH      INDEX_TYPE      INDEX_COMMENT
 
293
select * from `data_dictionary`.`INDEXES` where `TABLE_NAME` = NULL;
 
294
TABLE_SCHEMA    TABLE_NAME      INDEX_NAME      IS_PRIMARY      IS_UNIQUE       IS_NULLABLE     KEY_LENGTH      INDEX_TYPE      INDEX_COMMENT
 
295
select * from data_dictionary.schemas where schema_name = NULL;
 
296
SCHEMA_NAME     DEFAULT_COLLATION_NAME
 
297
select * from data_dictionary.tables where table_schema = NULL;
 
298
TABLE_SCHEMA    TABLE_NAME      TABLE_TYPE      ENGINE  ROW_FORMAT      TABLE_COLLATION TABLE_COMMENT
 
299
select * from data_dictionary.tables where table_name = NULL;
 
300
TABLE_SCHEMA    TABLE_NAME      TABLE_TYPE      ENGINE  ROW_FORMAT      TABLE_COLLATION TABLE_COMMENT
 
301
#
 
302
# Test that the query is visible to self and others.
 
303
#
 
304
SELECT info FROM data_dictionary.processlist WHERE id = CONNECTION_ID();
 
305
info
 
306
SELECT info FROM data_dictionary.processlist WHERE id = CONNECTION_ID()
 
307
SELECT * FROM data_dictionary.character_sets ORDER BY character_set_name;
 
308
CHARACTER_SET_NAME      DEFAULT_COLLATE_NAME    DESCRIPTION     MAXLEN
 
309
#       #       #       1
 
310
#       #       #       4
 
311
SELECT * FROM data_dictionary.collations ORDER BY collation_name;
 
312
CHARACTER_SET_NAME      COLLATION_NAME  DESCRIPTION     ID      IS_DEFAULT      IS_COMPILED     SORTLEN
 
313
binary  binary  binary  63      TRUE    TRUE    1
 
314
utf8_general_ci utf8_bin        utf8    46      FALSE   TRUE    1
 
315
utf8_general_ci utf8_czech_ci   utf8    234     FALSE   TRUE    8
 
316
utf8_general_ci utf8_danish_ci  utf8    235     FALSE   TRUE    8
 
317
utf8_general_ci utf8_esperanto_ci       utf8    241     FALSE   TRUE    8
 
318
utf8_general_ci utf8_estonian_ci        utf8    230     FALSE   TRUE    8
 
319
utf8_general_ci utf8_general_ci utf8    45      TRUE    TRUE    1
 
320
utf8_general_ci utf8_hungarian_ci       utf8    242     FALSE   TRUE    8
 
321
utf8_general_ci utf8_icelandic_ci       utf8    225     FALSE   TRUE    8
 
322
utf8_general_ci utf8_latvian_ci utf8    226     FALSE   TRUE    8
 
323
utf8_general_ci utf8_lithuanian_ci      utf8    236     FALSE   TRUE    8
 
324
utf8_general_ci utf8_persian_ci utf8    240     FALSE   TRUE    8
 
325
utf8_general_ci utf8_polish_ci  utf8    229     FALSE   TRUE    8
 
326
utf8_general_ci utf8_romanian_ci        utf8    227     FALSE   TRUE    8
 
327
utf8_general_ci utf8_roman_ci   utf8    239     FALSE   TRUE    8
 
328
utf8_general_ci utf8_sinhala_ci utf8    243     FALSE   TRUE    8
 
329
utf8_general_ci utf8_slovak_ci  utf8    237     FALSE   TRUE    8
 
330
utf8_general_ci utf8_slovenian_ci       utf8    228     FALSE   TRUE    8
 
331
utf8_general_ci utf8_spanish2_ci        utf8    238     FALSE   TRUE    8
 
332
utf8_general_ci utf8_spanish_ci utf8    231     FALSE   TRUE    8
 
333
utf8_general_ci utf8_swedish_ci utf8    232     FALSE   TRUE    8
 
334
utf8_general_ci utf8_turkish_ci utf8    233     FALSE   TRUE    8
 
335
utf8_general_ci utf8_unicode_ci utf8    224     FALSE   TRUE    8
 
336
SELECT table_name, column_name
 
337
FROM data_dictionary.columns
 
338
WHERE table_name IN
 
339
(SELECT table_name FROM data_dictionary.tables 
 
340
WHERE ENGINE IS NULL)
 
341
ORDER BY table_name;
 
342
table_name      column_name
 
343
SELECT schema_name FROM data_dictionary.schemas ORDER BY schema_name;
 
344
schema_name
 
345
 
 
346
 
 
347
data_dictionary
 
348
information_schema
 
349
SELECT count(*) FROM data_dictionary.session_status ORDER BY variable_name;
 
350
count(*)
 
351
#
 
352
SELECT count(*) FROM data_dictionary.session_variables ORDER BY variable_name;
 
353
count(*)
 
354
#
 
355
SELECT count(*) FROM data_dictionary.global_status ORDER BY variable_name;
 
356
count(*)
 
357
#
 
358
SELECT count(*) FROM data_dictionary.global_variables ORDER BY variable_name;
 
359
count(*)
 
360
#
 
361
SELECT table_schema, table_name FROM data_dictionary.tables WHERE ENGINE IS NULL ORDER BY table_name;
 
362
table_schema    table_name
 
363
SELECT count(*) FROM data_dictionary.plugins;
 
364
count(*)
 
365
#
 
366
DROP SCHEMA IF EXISTS data_dictionary;