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