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