information_schema.test 56.3 KB
Newer Older
1
# This test  uses grants, which can't get tested for embedded server
2
-- source include/not_embedded.inc
3

4 5 6
#Don't run this test when thread_pool active
--source include/not_threadpool.inc

7 8
# check that CSV engine was compiled in, as the result of the test depends
# on the presence of the log tables (which are CSV-based).
9 10
--source include/have_csv.inc

11
-- source include/have_innodb.inc
12

Matthias Leich's avatar
Matthias Leich committed
13 14 15
# Save the initial number of concurrent sessions
--source include/count_sessions.inc

16 17
set global sql_mode="";
set local sql_mode="";
Matthias Leich's avatar
Matthias Leich committed
18

19 20 21
# Test for information_schema.schemata &
# show databases

unknown's avatar
unknown committed
22
--disable_warnings
unknown's avatar
unknown committed
23 24
DROP TABLE IF EXISTS t0,t1,t2,t3,t4,t5;
DROP VIEW IF EXISTS v1;
unknown's avatar
unknown committed
25 26 27
--enable_warnings


28
show variables where variable_name like "skip_show_database";
29 30
grant select, update, execute on test.* to mysqltest_2@localhost;
grant select, update on test.* to mysqltest_1@localhost;
31 32 33
create user mysqltest_3@localhost;
create user mysqltest_3;

34 35 36 37 38

select * from information_schema.SCHEMATA where schema_name > 'm';
select schema_name from information_schema.schemata;
show databases like 't%';
show databases;
39
show databases where `database` = 't%';
40 41 42 43

# Test for information_schema.tables &
# show tables

44 45
create database mysqltest;
create table mysqltest.t1(a int, b VARCHAR(30), KEY string_data (b));
46 47
create table test.t2(a int);
create table t3(a int, KEY a_data (a));
48
create table mysqltest.t4(a int);
49 50
create table t5 (id int auto_increment primary key);
insert into t5 values (10);
51 52 53
create view v1 (c) as
 SELECT table_name FROM information_schema.TABLES
  WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test', 'mysqltest') AND
54
        table_name not like 'innodb_%' AND
Sergei Golubchik's avatar
Sergei Golubchik committed
55
        table_name not like 'xtradb_%';
Sergei Golubchik's avatar
Sergei Golubchik committed
56
--sorted_result
57
select * from v1;
58

59
--sorted_result
60 61 62 63
select c,table_name from v1 
inner join information_schema.TABLES v2 on (v1.c=v2.table_name)
where v1.c like "t%";

64
--sorted_result
65 66 67 68
select c,table_name from v1 
left join information_schema.TABLES v2 on (v1.c=v2.table_name)
where v1.c like "t%";

69
--sorted_result
70 71 72 73 74
select c, v2.table_name from v1
right join information_schema.TABLES v2 on (v1.c=v2.table_name)
where v1.c like "t%";

select table_name from information_schema.TABLES
75
where table_schema = "mysqltest" and table_name like "t%";
76

77
select * from information_schema.STATISTICS where TABLE_SCHEMA = "mysqltest";
78
show keys from t3 where Key_name = "a_data";
79 80

show tables like 't%';
81
--replace_column 8 # 12 # 13 #
82 83 84 85 86 87
show table status;
show full columns from t3 like "a%";
show full columns from mysql.db like "Insert%";
show full columns from v1;
select * from information_schema.COLUMNS where table_name="t1"
and column_name= "a";
88 89
show columns from mysqltest.t1 where field like "%a%";

90
create view mysqltest.v1 (c) as select a from mysqltest.t1;
91
grant select (a) on mysqltest.t1 to mysqltest_2@localhost;
92
grant select on mysqltest.v1 to mysqltest_3;
93 94
connect (user3,localhost,mysqltest_2,,);
connection user3;
95
select table_name, column_name, privileges from information_schema.columns
96 97
where table_schema = 'mysqltest' and table_name = 't1';
show columns from mysqltest.t1;
98 99 100 101
connect (user4,localhost,mysqltest_3,,mysqltest);
connection user4;
select table_name, column_name, privileges from information_schema.columns
where table_schema = 'mysqltest' and table_name = 'v1';
Matthias Leich's avatar
Matthias Leich committed
102
--error ER_VIEW_NO_EXPLAIN
103
explain select * from v1;
104
connection default;
105
disconnect user4;
106

107
drop view v1, mysqltest.v1;
108
drop tables mysqltest.t4, mysqltest.t1, t2, t3, t5;
109
drop database mysqltest;
110 111 112 113 114 115 116

# Test for information_schema.CHARACTER_SETS &
# SHOW CHARACTER SET

select * from information_schema.CHARACTER_SETS
where CHARACTER_SET_NAME like 'latin1%';
SHOW CHARACTER SET LIKE 'latin1%';
117
SHOW CHARACTER SET WHERE charset like 'latin1%';
118 119 120 121

# Test for information_schema.COLLATIONS &
# SHOW COLLATION

122
--replace_column 5 #
123 124
select * from information_schema.COLLATIONS
where COLLATION_NAME like 'latin1%';
125
--replace_column 5 #
126
SHOW COLLATION LIKE 'latin1%';
127
--replace_column 5 #
128
SHOW COLLATION WHERE collation like 'latin1%';
129 130 131 132 133 134 135

select * from information_schema.COLLATION_CHARACTER_SET_APPLICABILITY
where COLLATION_NAME like 'latin1%';

# Test for information_schema.ROUTINES &
#

unknown's avatar
unknown committed
136 137 138 139 140 141
--disable_warnings
drop procedure if exists sel2;
drop function if exists sub1;
drop function if exists sub2;
--enable_warnings

142 143 144 145 146 147 148 149 150 151
create function sub1(i int) returns int
  return i+1;
delimiter |;
create procedure sel2()
begin
  select * from t1;
  select * from t2;
end|
delimiter ;|

152 153 154
#
# Bug#7222 information_schema: errors in "routines"
#
155
select parameter_style, sql_data_access, dtd_identifier
156
from information_schema.routines where routine_schema='test';
157

158
--replace_column 5 # 6 #
159
show procedure status where db='test';
160
--replace_column 5 # 6 #
161
show function status where db='test';
162 163
select a.ROUTINE_NAME from information_schema.ROUTINES a,
information_schema.SCHEMATA b where
164
a.ROUTINE_SCHEMA = b.SCHEMA_NAME AND b.SCHEMA_NAME='test';
165 166 167 168 169 170
--replace_column 3 #
explain select a.ROUTINE_NAME from information_schema.ROUTINES a,
information_schema.SCHEMATA b where
a.ROUTINE_SCHEMA = b.SCHEMA_NAME;

select a.ROUTINE_NAME, b.name from information_schema.ROUTINES a,
171 172
mysql.proc b where a.ROUTINE_NAME = convert(b.name using utf8) AND a.ROUTINE_SCHEMA='test' order by 1;
select count(*) from information_schema.ROUTINES where routine_schema='test';
173

174
create view v1 as select routine_schema, routine_name from information_schema.routines where routine_schema='test'
175 176 177 178
order by routine_schema, routine_name;
select * from v1;
drop view v1;

179 180 181
connect (user1,localhost,mysqltest_1,,);
connection user1;
select ROUTINE_NAME, ROUTINE_DEFINITION from information_schema.ROUTINES;
182
--error ER_SP_DOES_NOT_EXIST
183 184 185 186 187 188 189 190 191 192 193 194 195 196
show create function sub1;
connection user3;
select ROUTINE_NAME, ROUTINE_DEFINITION from information_schema.ROUTINES;
connection default;
grant all privileges on test.* to mysqltest_1@localhost;
connect (user2,localhost,mysqltest_1,,);
connection user2;
select ROUTINE_NAME, ROUTINE_DEFINITION from information_schema.ROUTINES;
create function sub2(i int) returns int
  return i+1;
select ROUTINE_NAME, ROUTINE_DEFINITION from information_schema.ROUTINES;
show create procedure sel2;
show create function sub1;
show create function sub2;
197 198
--replace_column 5 # 6 #
show function status like "sub2";
199 200
connection default;
disconnect user1;
201
disconnect user3;
202 203 204
drop function sub2;
show create procedure sel2;

205 206 207
#
# Test for views
#
unknown's avatar
unknown committed
208
create view v0 (c) as select schema_name from information_schema.schemata;
209 210 211
select * from v0;
--replace_column 3 #
explain select * from v0;
unknown's avatar
unknown committed
212
create view v1 (c) as select table_name from information_schema.tables
213 214
where table_name="v1";
select * from v1;
unknown's avatar
unknown committed
215
create view v2 (c) as select column_name from information_schema.columns
216 217
where table_name="v2";
select * from v2;
unknown's avatar
unknown committed
218
create view v3 (c) as select CHARACTER_SET_NAME from information_schema.character_sets
219 220
where CHARACTER_SET_NAME like "latin1%";
select * from v3;
unknown's avatar
unknown committed
221
create view v4 (c) as select COLLATION_NAME from information_schema.collations
222 223 224
where COLLATION_NAME like "latin1%";
select * from v4;
show keys from v4;
unknown's avatar
unknown committed
225
select * from information_schema.views where TABLE_NAME like "v%";
226 227 228 229 230 231 232 233 234 235 236 237 238
drop view v0, v1, v2, v3, v4;

#
# Test for privileges tables
#
create table t1 (a int);
grant select,update,insert on t1 to mysqltest_1@localhost;
grant select (a), update (a),insert(a), references(a) on t1 to mysqltest_1@localhost;
grant all on test.* to mysqltest_1@localhost with grant option;
select * from information_schema.USER_PRIVILEGES where grantee like '%mysqltest_1%';
select * from information_schema.SCHEMA_PRIVILEGES where grantee like '%mysqltest_1%';
select * from information_schema.TABLE_PRIVILEGES where grantee like '%mysqltest_1%';
select * from information_schema.COLUMN_PRIVILEGES where grantee like '%mysqltest_1%';
239 240 241 242
delete from mysql.user where user like 'mysqltest%';
delete from mysql.db where user like 'mysqltest%';
delete from mysql.tables_priv where user like 'mysqltest%';
delete from mysql.columns_priv where user like 'mysqltest%';
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260
flush privileges;
drop table t1;


#
# Test for KEY_COLUMN_USAGE & TABLE_CONSTRAINTS tables
#

create table t1 (a int null, primary key(a));
alter table t1 add constraint constraint_1 unique (a);
alter table t1 add constraint unique key_1(a);
alter table t1 add constraint constraint_2 unique key_2(a);
show create table t1;
select * from information_schema.TABLE_CONSTRAINTS where
TABLE_SCHEMA= "test";
select * from information_schema.KEY_COLUMN_USAGE where
TABLE_SCHEMA= "test";

261
connection user2;
262 263 264
select table_name from information_schema.TABLES where table_schema like "test%";
select table_name,column_name from information_schema.COLUMNS where table_schema like "test%";
select ROUTINE_NAME from information_schema.ROUTINES;
265
disconnect user2;
266 267 268 269 270
connection default;
delete from mysql.user where user='mysqltest_1';
drop table t1;
drop procedure sel2;
drop function sub1;
unknown's avatar
unknown committed
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287

create table t1(a int);
create view v1 (c) as select a from t1 with check option;
create view v2 (c) as select a from t1 WITH LOCAL CHECK OPTION;
create view v3 (c) as select a from t1 WITH CASCADED CHECK OPTION;
select * from information_schema.views;
grant select (a) on test.t1 to joe@localhost with grant option;
select * from INFORMATION_SCHEMA.COLUMN_PRIVILEGES;
select * from INFORMATION_SCHEMA.TABLE_PRIVILEGES;
drop view v1, v2, v3;
drop table t1;
delete from mysql.user where user='joe';
delete from mysql.db where user='joe';
delete from mysql.tables_priv where user='joe';
delete from mysql.columns_priv where user='joe';
flush privileges;

288 289
# QQ This results in NULLs instead of the version numbers when
# QQ a LOCK TABLES is in effect when selecting from
290 291
# QQ information_schema.tables.

unknown's avatar
unknown committed
292
--disable_parsing # until bug is fixed
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310
delimiter //;
create procedure px5 ()
begin
declare v int;
declare c cursor for select version from
information_schema.tables where table_schema <> 'information_schema';
open c;
fetch c into v;
select v;
close c;
end;//

call px5()//
call px5()//
delimiter ;//
select sql_mode from information_schema.ROUTINES;
drop procedure px5;
--enable_parsing
unknown's avatar
unknown committed
311

312 313 314 315
create table t1 (a int not null auto_increment,b int, primary key (a));
insert into t1 values (1,1),(NULL,3),(NULL,4);
select AUTO_INCREMENT from information_schema.tables where table_name = 't1';
drop table t1;
unknown's avatar
unknown committed
316 317 318 319 320 321 322 323

create table t1 (s1 int);
insert into t1 values (0),(9),(0);
select s1 from t1 where s1 in (select version from
information_schema.tables) union select version from
information_schema.tables;
drop table t1;

unknown's avatar
unknown committed
324
SHOW CREATE TABLE INFORMATION_SCHEMA.character_sets;
unknown's avatar
unknown committed
325
set names latin2;
unknown's avatar
unknown committed
326
SHOW CREATE TABLE INFORMATION_SCHEMA.character_sets;
unknown's avatar
unknown committed
327 328 329 330 331 332 333
set names latin1;

create table t1 select * from information_schema.CHARACTER_SETS
where CHARACTER_SET_NAME like "latin1";
select * from t1;
alter table t1 default character set utf8;
show create table t1;
334
drop table t1;
unknown's avatar
unknown committed
335

336 337 338 339 340
create view v1 as select * from information_schema.TABLES;
drop view v1;
create table t1(a NUMERIC(5,3), b NUMERIC(5,1), c float(5,2),
 d NUMERIC(6,4), e float, f DECIMAL(6,3), g int(11), h DOUBLE(10,3),
 i DOUBLE);
341
select COLUMN_NAME,COLUMN_TYPE, CHARACTER_MAXIMUM_LENGTH,
342 343 344
 CHARACTER_OCTET_LENGTH, NUMERIC_PRECISION, NUMERIC_SCALE
from information_schema.columns where table_name= 't1';
drop table t1;
unknown's avatar
unknown committed
345 346 347 348 349 350 351 352 353

create table t115 as select table_name, column_name, column_type
from information_schema.columns where table_name = 'proc';
select * from t115;
drop table t115;

delimiter //;
create procedure p108 () begin declare c cursor for select data_type
from information_schema.columns;  open c; open c; end;//
354
--error ER_SP_CURSOR_ALREADY_OPEN
unknown's avatar
unknown committed
355 356 357
call p108()//
delimiter ;//
drop procedure p108;
unknown's avatar
unknown committed
358 359 360 361 362 363

create view v1 as select A1.table_name from information_schema.TABLES A1
where table_name= "user";
select * from v1;
drop view v1;

364
create view vo as select 'a' union select 'a';
unknown's avatar
unknown committed
365 366 367 368
show index from vo;
select * from information_schema.TABLE_CONSTRAINTS where
TABLE_NAME= "vo";
select * from information_schema.KEY_COLUMN_USAGE where
369
TABLE_NAME= "vo";
unknown's avatar
unknown committed
370
drop view vo;
371 372

select TABLE_NAME,TABLE_TYPE,ENGINE
373
from information_schema.tables
374
where table_schema='information_schema' limit 2;
375
--sorted_result
376
show tables from information_schema like "T%";
377

378
--error ER_DBACCESS_DENIED_ERROR
379 380
create database information_schema;
use information_schema;
381
--sorted_result
382
show full tables like "T%";
383
--error ER_DBACCESS_DENIED_ERROR
384 385 386 387
create table t1(a int);
use test;
show tables;
use information_schema;
388
--sorted_result
389
show tables like "T%";
390

391
#
392
# Bug#7210 information_schema: can't access when table-name = reserved word
393 394 395 396 397
#
select table_name from tables where table_name='user';
select column_name, privileges from columns
where table_name='user' and column_name like '%o%';

398
#
399 400
# Bug#7212 information_schema: "Can't find file" errors if storage engine gone
# Bug#7211 information_schema: crash if bad view
401 402 403 404 405
#
use test;
create function sub1(i int) returns int
  return i+1;
create table t1(f1 int);
unknown's avatar
unknown committed
406 407
create view v2 (c) as select f1 from t1;
create view v3 (c) as select sub1(1);
408 409 410
create table t4(f1 int, KEY f1_key (f1));
drop table t1;
drop function sub1;
411 412 413 414
select table_name from information_schema.views
where table_schema='test';
select table_name from information_schema.views
where table_schema='test';
415 416 417 418 419
select column_name from information_schema.columns
where table_schema='test';
select index_name from information_schema.statistics where table_schema='test';
select constraint_name from information_schema.table_constraints
where table_schema='test';
420 421
show create view v2;
show create table v3;
unknown's avatar
unknown committed
422 423
drop view v2;
drop view v3;
424
drop table t4;
425 426

#
427
# Bug#7213 information_schema: redundant non-standard TABLE_NAMES table
428
#
429
--error ER_UNKNOWN_TABLE
430
select * from information_schema.table_names;
431 432 433 434 435 436 437 438

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

439 440 441
#
# Bug#2718 information_schema: errors in "tables"
#
442
select TABLE_ROWS from information_schema.tables where
443 444 445
table_schema="information_schema" and table_name="COLUMNS";
select table_type from information_schema.tables
where table_schema="mysql" and table_name="user";
446 447 448 449

# test for 'show open tables ... where'
show open tables where `table` like "user";
# test for 'show status ... where'
450
show status where variable_name like "%database%";
451
# test for 'show variables ... where'
452
show variables where variable_name like "skip_show_databas";
453 454

#
455
# Bug#7981 SHOW GLOBAL STATUS crashes server
456
#
457 458
# We don't actually care about the value, just that it doesn't crash.
--replace_column 2 #
459
show global status like "Threads_running";
460 461

#
462
# Bug#7915 crash,JOIN VIEW, subquery,
463 464 465 466 467 468 469 470
# SELECT .. FROM INFORMATION_SCHEMA.COLUMNS
#
create table t1(f1 int);
create table t2(f2 int);
create view v1 as select * from t1, t2;
set @got_val= (select count(*) from information_schema.columns);
drop view v1;
drop table t1, t2;
471 472

#
473
# Bug#7476 crash on SELECT * FROM INFORMATION_SCHEMA.TABLES
474
#
475
use test;
476 477 478 479 480 481 482 483 484 485 486 487 488
CREATE TABLE t_crashme ( f1 BIGINT);
CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
let $tab_count= 65;
--disable_query_log
while ($tab_count)
{
     EVAL CREATE TABLE t_$tab_count (f1 BIGINT);
     dec $tab_count ;
}
--disable_result_log
SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES;
--enable_result_log
489
SELECT count(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test';
490 491 492 493 494 495 496 497 498
let $tab_count= 65;
while ($tab_count)
{
     EVAL DROP TABLE t_$tab_count;
     dec $tab_count ;
}
--enable_query_log
drop view a2, a1;
drop table t_crashme;
499 500

#
501 502
# Bug#7215 information_schema: columns are longtext instead of varchar
# Bug#7217 information_schema: columns are varbinary() instead of timestamp
503 504
#
select table_schema,table_name, column_name from
505
information_schema.columns
506
where data_type = 'longtext' and table_schema != 'performance_schema';
507
select table_name, column_name, data_type from information_schema.columns
508
where data_type = 'datetime' and table_name not like 'innodb_%';
509 510

#
511
# Bug#8164 subquery with INFORMATION_SCHEMA.COLUMNS, 100 % CPU
512 513
#
SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES A
514
WHERE NOT EXISTS
515 516 517
(SELECT * FROM INFORMATION_SCHEMA.COLUMNS B
  WHERE A.TABLE_SCHEMA = B.TABLE_SCHEMA
  AND A.TABLE_NAME = B.TABLE_NAME);
518 519

#
520
# Bug#9344 INFORMATION_SCHEMA, wrong content, numeric columns
521 522 523 524 525 526 527 528 529 530 531 532 533 534 535
#

create table t1
( x_bigint BIGINT,
  x_integer INTEGER,
  x_smallint SMALLINT,
  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 INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME= 't1';
drop table t1;
536 537

#
538
# Bug#10261 INFORMATION_SCHEMA.COLUMNS, incomplete result for non root user
539 540
#

541
grant select on test.* to mysqltest_4@localhost;
unknown's avatar
unknown committed
542 543
connect (user10261,localhost,mysqltest_4,,);
connection user10261;
544
--sorted_result
545
SELECT TABLE_NAME, COLUMN_NAME, PRIVILEGES FROM INFORMATION_SCHEMA.COLUMNS 
Sergei Golubchik's avatar
Sergei Golubchik committed
546
where COLUMN_NAME='TABLE_NAME' and table_name not like 'innodb%';
547
connection default;
548
disconnect user10261;
549
delete from mysql.user where user='mysqltest_4';
550
delete from mysql.db where user='mysqltest_4';
551
flush privileges;
unknown's avatar
unknown committed
552

553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577
#
# TRIGGERS table test
#
create table t1 (i int, j int);

delimiter |;
create trigger trg1 before insert on t1 for each row
begin
  if new.j > 10 then
    set new.j := 10;
  end if;
end|
create trigger trg2 before update on t1 for each row
begin
  if old.i % 2 = 0 then
    set new.j := -1;
  end if;
end|
create trigger trg3 after update on t1 for each row
begin
  if new.j = -1 then
    set @fired:= "Yes";
  end if;
end|
delimiter ;|
578
--replace_column 6 #
579
show triggers;
580
--replace_column 17 #
581
select * from information_schema.triggers where trigger_schema in ('mysql', 'information_schema', 'test', 'mysqltest');
582 583 584 585 586 587 588

drop trigger trg1;
drop trigger trg2;
drop trigger trg3;
drop table t1;


589
#
590
# Bug#10964 Information Schema:Authorization check on privilege tables is improper
591 592 593 594 595 596 597 598 599 600
#

create database mysqltest;
create table mysqltest.t1 (f1 int, f2 int);
create table mysqltest.t2 (f1 int);
grant select (f1) on mysqltest.t1 to user1@localhost;
grant select on mysqltest.t2 to user2@localhost;
grant select on mysqltest.* to user3@localhost;
grant select on *.* to user4@localhost;

601 602 603
connect (con1,localhost,user1,,mysqltest);
connect (con2,localhost,user2,,mysqltest);
connect (con3,localhost,user3,,mysqltest);
604 605
connect (con4,localhost,user4,,);
connection con1;
606 607 608 609
select * from information_schema.column_privileges order by grantee;
select * from information_schema.table_privileges order by grantee;
select * from information_schema.schema_privileges order by grantee;
select * from information_schema.user_privileges order by grantee;
610 611
show grants;
connection con2;
612 613 614 615
select * from information_schema.column_privileges order by grantee;
select * from information_schema.table_privileges order by grantee;
select * from information_schema.schema_privileges order by grantee;
select * from information_schema.user_privileges order by grantee;
616 617
show grants;
connection con3;
618 619 620 621
select * from information_schema.column_privileges order by grantee;
select * from information_schema.table_privileges order by grantee;
select * from information_schema.schema_privileges order by grantee;
select * from information_schema.user_privileges order by grantee;
622 623
show grants;
connection con4;
624
select * from information_schema.column_privileges where grantee like '\'user%'
625
order by grantee;
626
select * from information_schema.table_privileges where grantee like '\'user%'
627
order by grantee;
628
select * from information_schema.schema_privileges where grantee like '\'user%'
629
order by grantee;
630
select * from information_schema.user_privileges where grantee like '\'user%'
631
order by grantee;
632 633
show grants;
connection default;
634 635 636 637
disconnect con1;
disconnect con2;
disconnect con3;
disconnect con4;
638 639 640
drop user user1@localhost, user2@localhost, user3@localhost, user4@localhost;
use test;
drop database mysqltest;
641 642

#
643
# Bug#11055 information_schema: routines.sql_data_access has wrong value
644
#
unknown's avatar
unknown committed
645 646 647 648 649
--disable_warnings
drop procedure if exists p1;
drop procedure if exists p2;
--enable_warnings

650 651 652 653 654 655
create procedure p1 () modifies sql data set @a = 5;
create procedure p2 () set @a = 5;
select sql_data_access from information_schema.routines
where specific_name like 'p%';
drop procedure p1;
drop procedure p2;
656 657

#
658
# Bug#9434 SHOW CREATE DATABASE information_schema;
659 660
#
show create database information_schema;
661 662

#
663 664
# Bug#11057 information_schema: columns table has some questionable contents
# Bug#12301 information_schema: NUMERIC_SCALE must be 0 for integer columns
665 666 667 668 669 670 671 672 673 674 675 676 677
#
create table t1(f1 LONGBLOB, f2 LONGTEXT);
select column_name,data_type,CHARACTER_OCTET_LENGTH,
       CHARACTER_MAXIMUM_LENGTH
from information_schema.columns
where table_name='t1';
drop table t1;
create table t1(f1 tinyint, f2 SMALLINT, f3 mediumint, f4 int,
                f5 BIGINT, f6 BIT, f7 bit(64));
select column_name, NUMERIC_PRECISION, NUMERIC_SCALE
from information_schema.columns
where table_name='t1';
drop table t1;
678 679

#
680
# Bug#12127 triggers do not show in info_schema before they are used if set to the database
681 682 683 684 685 686 687 688
#
create table t1 (f1 integer);
create trigger tr1 after insert on t1 for each row set @test_var=42;
use information_schema;
select trigger_schema, trigger_name from triggers where
trigger_name='tr1';
use test;
drop table t1;
unknown's avatar
unknown committed
689 690 691 692 693 694 695 696 697

#
# Bug#12518 COLUMN_DEFAULT has wrong value if NOT NULL is set
#
create table t1 (a int not null, b int);
use information_schema;
select column_name, column_default from columns
  where table_schema='test' and table_name='t1';
use test;
698
show columns from t1;
unknown's avatar
unknown committed
699
drop table t1;
unknown's avatar
unknown committed
700 701

#
702
# Bug#12636 SHOW TABLE STATUS with where condition containing a subquery
Matthias Leich's avatar
Matthias Leich committed
703
#           over information schema
unknown's avatar
unknown committed
704 705 706 707 708 709 710 711 712 713
#

CREATE TABLE t1 (a int);
CREATE TABLE t2 (b int);

--replace_column 8 # 12 # 13 #
SHOW TABLE STATUS FROM test
  WHERE name IN ( SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES
                    WHERE TABLE_SCHEMA='test' AND TABLE_TYPE='BASE TABLE');

714 715 716
DROP TABLE t1,t2;

#
717
# Bug#12905 show fields from view behaving erratically with current database
718 719 720 721 722 723 724
#
create table t1(f1 int);
create view v1 (c) as select f1 from t1;
connect (con5,localhost,root,,*NO-ONE*);
select database();
show fields from test.v1;
connection default;
725
disconnect con5;
726 727
drop view v1;
drop table t1;
728 729

#
730
# Bug#9846 Inappropriate error displayed while dropping table from 'INFORMATION_SCHEMA'
731
#
732
--error ER_PARSE_ERROR
733
alter database information_schema;
734
--error ER_DBACCESS_DENIED_ERROR
735
drop database information_schema;
736
--error ER_DBACCESS_DENIED_ERROR
737
drop table information_schema.tables;
738
--error ER_DBACCESS_DENIED_ERROR
739 740
alter table information_schema.tables;
#
741
# Bug#9683 INFORMATION_SCH: Creation of temporary table allowed in Information_schema DB
742 743
#
use information_schema;
744
--error ER_DBACCESS_DENIED_ERROR
745 746
create temporary table schemata(f1 char(10));
#
747
# Bug#10708 SP's can use INFORMATION_SCHEMA as ROUTINE_SCHEMA
748 749
#
delimiter |;
750
--error ER_DBACCESS_DENIED_ERROR
751 752 753 754 755
CREATE PROCEDURE p1 ()
BEGIN
  SELECT 'foo' FROM DUAL;
END |
delimiter ;|
Matthias Leich's avatar
Matthias Leich committed
756
select ROUTINE_NAME from routines where ROUTINE_SCHEMA='information_schema';
757
#
758
# Bug#10734 Grant of privileges other than 'select' and 'create view' should fail on schema
759
#
760
--error ER_DBACCESS_DENIED_ERROR
761
grant all on information_schema.* to 'user1'@'localhost';
762
--error ER_DBACCESS_DENIED_ERROR
763
grant select on information_schema.* to 'user1'@'localhost';
764 765 766 767 768 769 770 771 772 773 774 775

#
# Bug#14089 FROM list subquery always fails when information_schema 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 information_schema;
select 1 from (select 1 from test.t1) a;
use test;
drop table t1;
776

777 778 779 780 781 782 783 784 785
#
# Bug#14476 `information_schema`.`TABLES`.`TABLE_TYPE` with empty value
#
create table t1 (f1 int(11));
create view v1 as select * from t1;
drop table t1;
select table_type from information_schema.tables
where table_name="v1";
drop view v1;
unknown's avatar
unknown committed
786

787
#
788 789 790
# 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
791 792 793 794 795 796
#
create temporary table t1(f1 int, index(f1));
show columns from t1;
describe t1;
show indexes from t1;
drop table t1;
797 798 799 800 801 802 803 804

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

unknown's avatar
unknown committed
806
#
807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827
# Bug#15533 crash, information_schema, function, view
#
CREATE TABLE t1 (f1 BIGINT, f2 VARCHAR(20), f3 BIGINT);
INSERT INTO t1 SET f1 = 1, f2 = 'Schoenenbourg', f3 = 1;

CREATE FUNCTION func2() RETURNS BIGINT RETURN 1;

delimiter //;
CREATE FUNCTION func1() RETURNS BIGINT
BEGIN
  RETURN ( SELECT COUNT(*) FROM INFORMATION_SCHEMA.VIEWS);
END//
delimiter ;//

CREATE VIEW v1 AS SELECT 1 FROM t1
                    WHERE f3 = (SELECT func2 ());
SELECT func1();
DROP TABLE t1;
DROP VIEW v1;
DROP FUNCTION func1;
DROP FUNCTION func2;
828

829 830 831 832 833 834 835

#
# Bug#15307 GROUP_CONCAT() with ORDER BY returns empty set on information_schema
#
select column_type, group_concat(table_schema, '.', table_name), count(*) as num
from information_schema.columns where
table_schema='information_schema' and
836 837
(column_type = 'varchar(7)' or column_type = 'varchar(20)'
 or column_type = 'varchar(27)')
838
group by column_type order by num;
839

840 841 842 843 844 845 846 847
#
# Bug#19236 bad COLUMNS.CHARACTER_MAXIMUM_LENGHT and CHARACTER_OCTET_LENGTH
#
create table t1(f1 char(1) not null, f2 char(9) not null)
default character set utf8;
select CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH from
information_schema.columns where table_schema='test' and table_name = 't1';
drop table t1;
848 849 850 851 852 853 854

#
# Bug#18177 any access to INFORMATION_SCHEMA.ROUTINES crashes
#
use mysql;
INSERT INTO `proc` VALUES ('test','','PROCEDURE','','SQL','CONTAINS_SQL',
'NO','DEFINER','','','BEGIN\r\n  \r\nEND','root@%','2006-03-02 18:40:03',
unknown's avatar
unknown committed
855
'2006-03-02 18:40:03','','','utf8','utf8_general_ci','utf8_general_ci','n/a');
856
select routine_name from information_schema.routines where ROUTINE_SCHEMA='test';
857 858
delete from proc where name='';
use test;
859

860 861 862 863 864 865 866 867 868 869 870 871 872 873 874
#
# Bug#16681 information_schema shows forbidden VIEW details
#
grant select on test.* to mysqltest_1@localhost;
create table t1 (id int);
create view v1 as select * from t1;
create definer = mysqltest_1@localhost
sql security definer view v2 as select 1;

connect (con16681,localhost,mysqltest_1,,test);
connection con16681;

select * from information_schema.views
where table_name='v1' or table_name='v2';
connection default;
875
disconnect con16681;
876 877 878
drop view v1, v2;
drop table t1;
drop user mysqltest_1@localhost;
879

880 881 882 883 884 885 886 887 888
#
# Bug#19599 duplication of information_schema 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 information_schema.tables where table_schema = 'test';
drop table t1,t2;
unknown's avatar
unknown committed
889

890 891

#
892
# Bug#20230 routine_definition is not null
893 894 895 896 897 898 899 900 901 902 903 904
#
--disable_warnings
DROP PROCEDURE IF EXISTS p1;
DROP FUNCTION IF EXISTS f1;
--enable_warnings

CREATE PROCEDURE p1() SET @a= 1;
CREATE FUNCTION f1() RETURNS INT RETURN @a + 1;
CREATE USER mysql_bug20230@localhost;
GRANT EXECUTE ON PROCEDURE p1 TO mysql_bug20230@localhost;
GRANT EXECUTE ON FUNCTION f1 TO mysql_bug20230@localhost;

905
SELECT ROUTINE_NAME, ROUTINE_DEFINITION FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_SCHEMA='test';
906 907 908 909 910
SHOW CREATE PROCEDURE p1;
SHOW CREATE FUNCTION f1;

connect (conn1, localhost, mysql_bug20230,,);

911
SELECT ROUTINE_NAME, ROUTINE_DEFINITION FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_SCHEMA='test';
912 913 914 915 916 917 918 919 920 921 922 923
SHOW CREATE PROCEDURE p1;
SHOW CREATE FUNCTION f1;
CALL p1();
SELECT f1();

disconnect conn1;
connection default;

DROP FUNCTION f1;
DROP PROCEDURE p1;
DROP USER mysql_bug20230@localhost;

924
#
925 926
# Bug#21231 query with a simple non-correlated subquery over
#           INFORMARTION_SCHEMA.TABLES
927 928
#

Sergei Golubchik's avatar
Sergei Golubchik committed
929
SELECT MAX(table_name) FROM information_schema.tables WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test') and table_name not like 'xtradb%';
930 931
SELECT table_name from information_schema.tables
  WHERE table_name=(SELECT MAX(table_name)
Sergei Golubchik's avatar
Sergei Golubchik committed
932
                      FROM information_schema.tables WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test') and table_name not like 'xtradb%');
933
#
934
# Bug #23037 Bug in field "Default" of query "SHOW COLUMNS FROM table"
935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951
#
# Note, MyISAM/InnoDB can't take more that 65532 chars, because the row
# size is limited to 65535 bytes (BLOBs not counted)
#
--disable_warnings
DROP TABLE IF EXISTS bug23037;
DROP FUNCTION IF EXISTS get_value;
--enable_warnings
--disable_query_log
DELIMITER |;
CREATE FUNCTION get_value()
  RETURNS TEXT
  DETERMINISTIC
BEGIN
  DECLARE col1, col2, col3, col4, col6 CHAR(255);
  DECLARE default_val VARCHAR(65532);
  DECLARE done INT DEFAULT 0;
952
  DECLARE cur1 CURSOR FOR SELECT COLUMN_NAME, COLUMN_TYPE, IS_NULLABLE, COLUMN_KEY, COLUMN_DEFAULT, EXTRA FROM INFORMATION_SCHEMA.COLUMNS where TABLE_NAME='bug23037';
953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969
  DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;
  OPEN cur1;
  FETCH cur1 INTO col1, col2, col3, col4, default_val, col6;
  CLOSE cur1;
  RETURN default_val;
end|
DELIMITER ;|

let $body=`SELECT REPEAT('A', 65532)`;
eval CREATE TABLE bug23037(fld1 VARCHAR(65532) CHARACTER SET latin1 DEFAULT "$body");
--enable_query_log

SELECT COLUMN_NAME, MD5(COLUMN_DEFAULT), LENGTH(COLUMN_DEFAULT) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='bug23037';

SELECT MD5(get_value());

SELECT COLUMN_NAME, MD5(COLUMN_DEFAULT), LENGTH(COLUMN_DEFAULT), COLUMN_DEFAULT=get_value() FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='bug23037';
970

971 972 973
DROP TABLE bug23037;
DROP FUNCTION get_value;

974
#
975
# Bug#22413 EXPLAIN SELECT FROM view with ORDER BY yield server crash
976
#
977 978
set @tmp_optimizer_switch=@@optimizer_switch;
set optimizer_switch='derived_merge=off,derived_with_keys=off';
979 980 981 982 983 984 985 986
create view v1 as
select table_schema as object_schema,
       table_name   as object_name,
       table_type   as object_type
from information_schema.tables
order by object_schema;
explain select * from v1;
explain select * from (select table_name from information_schema.tables) as a;
987
set optimizer_switch=@tmp_optimizer_switch;
988 989
drop view v1;

990 991 992 993 994 995 996 997 998 999 1000 1001
#
# Bug#23299 Some queries against INFORMATION_SCHEMA with subqueries fail
#
create table t1 (f1 int(11));
create table t2 (f1 int(11), f2 int(11));

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

1002

1003 1004 1005 1006 1007
#
# Bug#28266 IS_UPDATABLE field on VIEWS table in I_S database is wrong
#
create table t1(f1 int);
create view v1 as select f1+1 as a from t1;
1008 1009
create table t2 (f1 int, f2 int);
create view v2 as select f1+1 as a, f2 as b from t2;
1010 1011 1012 1013 1014 1015 1016 1017
select table_name, is_updatable from information_schema.views;
#
# Note: we can perform 'delete' for non updatable view.
#
delete from v1;
drop view v1,v2;
drop table t1,t2;

1018
#
1019
# Bug#25859 ALTER DATABASE works w/o parameters
1020 1021 1022 1023 1024
#
--error ER_PARSE_ERROR
alter database;
--error ER_PARSE_ERROR
alter database test;
1025

1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037
#
# Bug#27629 Possible security flaw in INFORMATION_SCHEMA and SHOW statements
#

create database mysqltest;
create table mysqltest.t1(a int, b int, c int);
create trigger mysqltest.t1_ai after insert on mysqltest.t1
  for each row set @a = new.a + new.b + new.c;
grant select(b) on mysqltest.t1 to mysqltest_1@localhost;

select trigger_name from information_schema.triggers
where event_object_table='t1';
1038
--replace_column 6 #
1039 1040 1041 1042 1043 1044
show triggers from mysqltest;

connect (con27629,localhost,mysqltest_1,,mysqltest);
show columns from t1;
select column_name from information_schema.columns where table_name='t1';

1045
--replace_column 6 #
1046 1047 1048 1049
show triggers;
select trigger_name from information_schema.triggers
where event_object_table='t1';
connection default;
1050
disconnect con27629;
1051 1052 1053
drop user mysqltest_1@localhost;
drop database mysqltest;

1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070
#
# 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 information_schema.columns where table_name= 't1';
show columns from t1;
drop table t1;

1071 1072 1073
#
# Bug#30079 A check for "hidden" I_S tables is flawed
#
1074
--error ER_UNKNOWN_TABLE
unknown's avatar
unknown committed
1075
show fields from information_schema.table_names;
1076
--error ER_UNKNOWN_TABLE
unknown's avatar
unknown committed
1077
show keys from information_schema.table_names;
1078

1079
#
1080
# Bug#34529 Crash on complex Falcon I_S select after ALTER .. PARTITION BY
1081 1082 1083 1084 1085 1086 1087 1088
#
USE information_schema;
SET max_heap_table_size = 16384;

CREATE TABLE test.t1( a INT );

# What we need to create here is a bit of a corner case:
# We need a star query with information_schema tables, where the first
1089
# branch of the star join produces zero rows, so that reading of the
1090
# second branch never happens. At the same time we have to make sure
1091
# that data for at least the last table is swapped from MEMORY/HEAP to
1092 1093 1094 1095 1096 1097 1098 1099
# MyISAM. This and only this triggers the bug.
SELECT *
FROM tables ta
JOIN collations co ON ( co.collation_name = ta.table_catalog )
JOIN character_sets cs ON ( cs.character_set_name = ta.table_catalog );

DROP TABLE test.t1;
SET max_heap_table_size = DEFAULT;
1100 1101 1102 1103
USE test;

--echo End of 5.0 tests.

unknown's avatar
unknown committed
1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118
#
# Show engines
#

select * from information_schema.engines WHERE ENGINE="MyISAM";

#
# INFORMATION_SCHEMA.PROCESSLIST
#

grant select on *.* to user3148@localhost;
connect (con3148,localhost,user3148,,test);
connection con3148;
select user,db from information_schema.processlist;
connection default;
Matthias Leich's avatar
Matthias Leich committed
1119
disconnect con3148;
unknown's avatar
unknown committed
1120 1121
drop user user3148@localhost;

1122 1123 1124 1125 1126 1127 1128
#
# `time` and `time_ms` columns of INFORMATION_SCHEMA.PROCESSLIST.
#
connect (pslistcon,localhost,root,,test);
let $ID= `select connection_id()`;
SELECT 'other connection here' AS who;
connection default;
1129
sleep 2;
1130 1131 1132 1133 1134
--disable_query_log
eval SET @tid=$ID;
--enable_query_log
SELECT IF(`time` > 0, 'OK', `time`) AS time_low,
       IF(`time` < 1000, 'OK', `time`) AS time_high,
1135
       IF(time_ms >= 1000, 'OK', time_ms) AS time_ms_low,
1136 1137 1138 1139 1140
       IF(time_ms < 1000000, 'OK', time_ms) AS time_ms_high
  FROM INFORMATION_SCHEMA.PROCESSLIST
 WHERE ID=@tid;
disconnect pslistcon;

1141
#
Matthias Leich's avatar
Matthias Leich committed
1142
# Bug#26174 Server Crash: INSERT ... SELECT ... FROM I_S.GLOBAL_STATUS
1143
# in Event (see also openssl_1.test)
1144 1145
#
--disable_warnings
1146 1147
DROP TABLE IF EXISTS server_status;
DROP EVENT IF EXISTS event_status;
1148 1149
--enable_warnings

1150 1151
SET GLOBAL event_scheduler=1;

1152 1153
DELIMITER $$;

1154
CREATE EVENT event_status
1155
 ON SCHEDULE AT NOW()
1156
 ON COMPLETION NOT PRESERVE
1157
 DO
1158 1159 1160 1161 1162 1163 1164
BEGIN
  CREATE TABLE server_status
  SELECT variable_name
  FROM information_schema.global_status
  WHERE variable_name LIKE 'ABORTED_CONNECTS' OR
  variable_name LIKE 'BINLOG_CACHE_DISK_USE';
END$$
1165 1166 1167

DELIMITER ;$$

1168
let $wait_timeout= 300;
1169
let $wait_condition=select count(*) = 0 from information_schema.events where event_name='event_status';
1170
--source include/wait_condition.inc
1171

1172 1173
SELECT variable_name FROM server_status;

1174 1175 1176
DROP TABLE server_status;
SET GLOBAL event_scheduler=0;

1177 1178 1179

#
# WL#3732 Information schema optimization
Matthias Leich's avatar
Matthias Leich committed
1180
#
1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196

explain select table_name from information_schema.views where
table_schema='test' and table_name='v1';

explain select * from information_schema.tables;
explain select * from information_schema.collations;

explain select * from information_schema.tables where
table_schema='test' and table_name= 't1';
explain select table_name, table_type from information_schema.tables
where table_schema='test';

explain select b.table_name
from information_schema.tables a, information_schema.columns b
where a.table_name='t1' and a.table_schema='test' and b.table_name=a.table_name;

1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212
#
# Bug#30310 wrong result on SELECT * FROM INFORMATION_SCHEMA.SCHEMATA WHERE ..
#
SELECT * FROM INFORMATION_SCHEMA.SCHEMATA
WHERE SCHEMA_NAME = 'mysqltest';

SELECT * FROM INFORMATION_SCHEMA.SCHEMATA
WHERE SCHEMA_NAME = '';

SELECT * FROM INFORMATION_SCHEMA.SCHEMATA
WHERE SCHEMA_NAME = 'test';

select count(*) from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='mysql' AND TABLE_NAME='nonexisting';
select count(*) from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='mysql' AND TABLE_NAME='';
select count(*) from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='' AND TABLE_NAME='';
select count(*) from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='' AND TABLE_NAME='nonexisting';
1213 1214 1215 1216 1217 1218

#
# Bug#30689 Wrong content in I_S.VIEWS.VIEW_DEFINITION if VIEW is based on I_S
#
CREATE VIEW v1
AS SELECT *
1219
FROM information_schema.tables;
1220 1221 1222
SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS where TABLE_NAME = 'v1';
DROP VIEW v1;

1223 1224 1225 1226 1227
#
# Bug#30795 Query on INFORMATION_SCHEMA.SCHEMATA, wrong result
#
SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA
WHERE SCHEMA_NAME ='information_schema';
Matthias Leich's avatar
Matthias Leich committed
1228

1229 1230 1231 1232 1233
#
# Bug#31381 Error in retrieving Data from INFORMATION_SCHEMA
#
SELECT TABLE_COLLATION FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA='mysql' and TABLE_NAME= 'db';
1234

1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258
#
# Bug#31633 Information schema = NULL queries crash the server
#
select * from information_schema.columns where table_schema = NULL;
select * from `information_schema`.`COLUMNS` where `TABLE_NAME` = NULL;
select * from `information_schema`.`KEY_COLUMN_USAGE` where `TABLE_SCHEMA` = NULL;
select * from `information_schema`.`KEY_COLUMN_USAGE` where `TABLE_NAME` = NULL;
select * from `information_schema`.`PARTITIONS` where `TABLE_SCHEMA` = NULL;
select * from `information_schema`.`PARTITIONS` where `TABLE_NAME` = NULL;
select * from `information_schema`.`REFERENTIAL_CONSTRAINTS` where `CONSTRAINT_SCHEMA` = NULL;
select * from `information_schema`.`REFERENTIAL_CONSTRAINTS` where `TABLE_NAME` = NULL;
select * from information_schema.schemata where schema_name = NULL;
select * from `information_schema`.`STATISTICS` where `TABLE_SCHEMA` = NULL;
select * from `information_schema`.`STATISTICS` where `TABLE_NAME` = NULL;
select * from information_schema.tables where table_schema = NULL;
select * from information_schema.tables where table_catalog = NULL;
select * from information_schema.tables where table_name = NULL;
select * from `information_schema`.`TABLE_CONSTRAINTS` where `TABLE_SCHEMA` = NULL;
select * from `information_schema`.`TABLE_CONSTRAINTS` where `TABLE_NAME` = NULL;
select * from `information_schema`.`TRIGGERS` where `EVENT_OBJECT_SCHEMA` = NULL;
select * from `information_schema`.`TRIGGERS` where `EVENT_OBJECT_TABLE` = NULL;
select * from `information_schema`.`VIEWS` where `TABLE_SCHEMA` = NULL;
select * from `information_schema`.`VIEWS` where `TABLE_NAME` = NULL;

1259 1260 1261
#
# Bug#31630 debug assert with explain extended select ... from i_s
#
1262
explain extended select 1 from information_schema.tables;
1263

1264 1265 1266 1267 1268 1269 1270
#
# Bug#32775 problems with SHOW EVENTS and Information_Schema
#
use information_schema;
show events;
show events from information_schema;
show events where Db= 'information_schema';
unknown's avatar
unknown committed
1271
use test;
1272

1273
--echo #
Matthias Leich's avatar
Matthias Leich committed
1274
--echo # Bug#34166 Server crash in SHOW OPEN TABLES and prelocking
1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294
--echo #
--disable_warnings
drop table if exists t1;
drop function if exists f1;
--enable_warnings
create table t1 (a int);
delimiter |;
create function f1() returns int
begin
  insert into t1 (a) values (1);
  return 0;
end|
delimiter ;|
--disable_result_log
show open tables where f1()=0;
show open tables where f1()=0;
--enable_result_log
drop table t1;
drop function f1;

1295
#
Matthias Leich's avatar
Matthias Leich committed
1296 1297
# Bug#34656 KILL a query = Assertion failed: m_status == DA_ERROR ||
#           m_status == DA_OK
1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316
#
connect (conn1, localhost, root,,);
connection conn1;
let $ID= `select connection_id()`;
send select * from information_schema.tables where 1=sleep(100000);
connection default;
let $wait_timeout= 10;
let $wait_condition=select count(*)=1 from information_schema.processlist
where state='User sleep' and
info='select * from information_schema.tables where 1=sleep(100000)';
--source include/wait_condition.inc
disable_query_log;
eval kill $ID;
enable_query_log;
let $wait_timeout= 10;
let $wait_condition=select count(*)=0 from information_schema.processlist
where state='User sleep' and
info='select * from information_schema.tables where 1=sleep(100000)';
--source include/wait_condition.inc
1317 1318 1319 1320 1321
connection conn1;
--error 2013,ER_CONNECTION_KILLED
reap;
connection default;
disconnect conn1;
1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340

connect (conn1, localhost, root,,);
connection conn1;
let $ID= `select connection_id()`;
send select * from information_schema.columns where 1=sleep(100000);
connection default;
let $wait_timeout= 10;
let $wait_condition=select count(*)=1 from information_schema.processlist
where state='User sleep' and
info='select * from information_schema.columns where 1=sleep(100000)';
--source include/wait_condition.inc
disable_query_log;
eval kill $ID;
enable_query_log;
let $wait_timeout= 10;
let $wait_condition=select count(*)=0 from information_schema.processlist
where state='User sleep' and
info='select * from information_schema.columns where 1=sleep(100000)';
--source include/wait_condition.inc
1341 1342 1343 1344 1345
connection conn1;
--error 2013,ER_CONNECTION_KILLED
reap;
connection default;
disconnect conn1;
1346

1347 1348 1349 1350 1351 1352 1353 1354

#
# Bug#38918 selecting from information_schema.columns is disproportionately slow
#
explain select count(*) from information_schema.tables;
explain select count(*) from information_schema.columns;
explain select count(*) from information_schema.views;

1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379
#
# Bug#39955 SELECT on INFORMATION_SCHEMA.GLOBAL_VARIABLES takes too long
#
set global init_connect="drop table if exists t1;drop table if exists t1;\
drop table if exists t1;drop table if exists t1;\
drop table if exists t1;drop table if exists t1;\
drop table if exists t1;drop table if exists t1;\
drop table if exists t1;drop table if exists t1;\
drop table if exists t1;drop table if exists t1;\
drop table if exists t1;drop table if exists t1;\
drop table if exists t1;drop table if exists t1;\
drop table if exists t1;drop table if exists t1;\
drop table if exists t1;drop table if exists t1;\
drop table if exists t1;drop table if exists t1;\
drop table if exists t1;drop table if exists t1;\
drop table if exists t1;drop table if exists t1;\
drop table if exists t1;drop table if exists t1;\
drop table if exists t1;drop table if exists t1;\
drop table if exists t1;drop table if exists t1;\
drop table if exists t1;drop table if exists t1;\
drop table if exists t1;drop table if exists t1;\
drop table if exists t1;drop table if exists t1;\
drop table if exists t1;drop table if exists t1;\
drop table if exists t1;drop table if exists t1;";
select * from information_schema.global_variables where variable_name='init_connect';
1380 1381
--replace_regex /at row [123]/at row #/
select * from information_schema.global_variables where variable_name like 'init%' order by variable_name;
1382 1383
set global init_connect="";

1384
#
Matthias Leich's avatar
Matthias Leich committed
1385
# Bug#34517 SHOW GLOBAL STATUS does not work properly in embedded server.
1386 1387 1388 1389 1390
#

create table t0 select * from information_schema.global_status where VARIABLE_NAME='COM_SELECT';
SELECT 1;
select a.VARIABLE_VALUE - b.VARIABLE_VALUE from t0 b, information_schema.global_status a
Matthias Leich's avatar
Matthias Leich committed
1391
   where a.VARIABLE_NAME = b.VARIABLE_NAME;
1392 1393
drop table t0;

1394 1395 1396 1397 1398 1399 1400
#
# Bug#35275 INFORMATION_SCHEMA.TABLES.CREATE_OPTIONS omits KEY_BLOCK_SIZE
#
CREATE TABLE t1(a INT) KEY_BLOCK_SIZE=1;
SELECT CREATE_OPTIONS FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='t1';
DROP TABLE t1;

1401 1402 1403 1404
#
# Bug #22047: Time in SHOW PROCESSLIST for SQL thread in replication seems
# to become negative
#
1405 1406 1407 1408 1409 1410 1411
# Note that at the time of writing, MariaDB differs in behaviour from MySQL on
# the `time` column. In MySQL this changes depending on the setting of
# @TIMESTAMP, which is contrary to the documented (and sensible) behaviour.
# In MariaDB, the `time` column is independent of @TIMESTAMP.
# (The rationale for this is to keep `time` and `time_ms` consistent;
# @TIMESTAMP has no microsecond precision).
#
1412 1413

SET TIMESTAMP=@@TIMESTAMP + 10000000;
1414
SELECT 'NOT_OK' AS TEST_RESULT FROM INFORMATION_SCHEMA.PROCESSLIST WHERE time < 0;
1415 1416
SET TIMESTAMP=DEFAULT;

1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442

--echo #
--echo # Bug #50276: Security flaw in INFORMATION_SCHEMA.TABLES
--echo #
CREATE DATABASE db1;
USE db1;
CREATE TABLE t1 (id INT);
CREATE USER nonpriv;
USE test;

connect (nonpriv_con, localhost, nonpriv,,);
connection nonpriv_con;
--echo # connected as nonpriv
--echo # Should return 0
SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='t1';
USE INFORMATION_SCHEMA;
--echo # Should return 0
SELECT COUNT(*) FROM TABLES WHERE TABLE_NAME='t1';

connection default;
--echo # connected as root
disconnect nonpriv_con;
DROP USER nonpriv;
DROP TABLE db1.t1;
DROP DATABASE db1;

1443 1444 1445 1446 1447 1448 1449 1450 1451
--echo
--echo Bug#54422 query with = 'variables'
--echo

CREATE TABLE variables(f1 INT);
SELECT COLUMN_DEFAULT, TABLE_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE INFORMATION_SCHEMA.COLUMNS.TABLE_NAME = 'variables';
DROP TABLE variables;
1452

1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467
--echo #
--echo # Bug #53814: NUMERIC_PRECISION for unsigned bigint field is 19, 
--echo # should be 20
--echo #

CREATE TABLE ubig (a BIGINT, b BIGINT UNSIGNED);

SELECT TABLE_NAME, COLUMN_NAME, NUMERIC_PRECISION 
  FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='ubig';

INSERT INTO ubig VALUES (0xFFFFFFFFFFFFFFFF,0xFFFFFFFFFFFFFFFF);
SELECT length(CAST(b AS CHAR)) FROM ubig;

DROP TABLE ubig;

1468 1469 1470 1471
#
# Bug #13889741: HANDLE_FATAL_SIGNAL IN _DB_ENTER_ | HANDLE_FATAL_SIGNAL IN STRNLEN
#
select 1 from information_schema.tables where table_schema=repeat('a', 2000);
1472 1473 1474 1475 1476 1477 1478
grant usage on *.* to mysqltest_1@localhost;
connect (con1, localhost, mysqltest_1,,);
connection con1;
select 1 from information_schema.tables where table_schema=repeat('a', 2000);
connection default;
disconnect con1;
drop user mysqltest_1@localhost;
1479

1480
--echo End of 5.1 tests.
Matthias Leich's avatar
Matthias Leich committed
1481

1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504
--echo #
--echo # Additional test for WL#3726 "DDL locking for all metadata objects"
--echo # To avoid possible deadlocks process of filling of I_S tables should
--echo # use high-priority metadata lock requests when opening tables.
--echo # Below we just test that we really use high-priority lock request
--echo # since reproducing a deadlock will require much more complex test.
--echo #
--disable_warnings
drop tables if exists t1, t2, t3;
--enable_warnings
create table t1 (i int);
create table t2 (j int primary key auto_increment);
connect (con3726_1,localhost,root,,test);
connection con3726_1;
lock table t2 read;
connect (con3726_2,localhost,root,,test);
connection con3726_2;
--echo # RENAME below will be blocked by 'lock table t2 read' above but
--echo # will add two pending requests for exclusive metadata locks.
--send rename table t2 to t3
connection default;
let $wait_condition=
  select count(*) = 1 from information_schema.processlist
1505 1506
  where state = "Waiting for table metadata lock" and
        info like "rename table t2 to t3";
1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533
--source include/wait_condition.inc
--echo # These statements should not be blocked by pending lock requests
select table_name, column_name, data_type from information_schema.columns
  where table_schema = 'test' and table_name in ('t1', 't2');
select table_name, auto_increment from information_schema.tables
  where table_schema = 'test' and table_name in ('t1', 't2');
connection con3726_1;
unlock tables;
connection con3726_2;
--reap
connection default;
disconnect con3726_1;
disconnect con3726_2;
drop tables t1, t3;

#
# Bug#39270 I_S optimization algorithm does not work properly in some cases
#
EXPLAIN SELECT * FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE;
EXPLAIN SELECT * FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME='t1';
EXPLAIN SELECT * FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS
  WHERE CONSTRAINT_SCHEMA='test';
EXPLAIN SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS
  WHERE TABLE_NAME='t1' and TABLE_SCHEMA='test';
EXPLAIN SELECT * FROM INFORMATION_SCHEMA.TRIGGERS
  WHERE EVENT_OBJECT_SCHEMA='test';

1534 1535
#
# Bug#24062 Incorrect error msg after execute DROP TABLE IF EXISTS on information_schema
1536
#
1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570
--error ER_DBACCESS_DENIED_ERROR
create table information_schema.t1 (f1 INT);
--error ER_DBACCESS_DENIED_ERROR
drop table information_schema.t1;
--error ER_DBACCESS_DENIED_ERROR
drop temporary table if exists information_schema.t1;
--error ER_DBACCESS_DENIED_ERROR
create temporary table information_schema.t1 (f1 INT);
--error ER_DBACCESS_DENIED_ERROR
drop view information_schema.v1;
--error ER_DBACCESS_DENIED_ERROR
create view information_schema.v1;
--error ER_DBACCESS_DENIED_ERROR
create trigger mysql.trg1 after insert on information_schema.t1 for each row set @a=1;
--error 1109
create table t1 select * from information_schema.t1;

CREATE TABLE t1(f1 char(100));
--error ER_DBACCESS_DENIED_ERROR
REPAIR TABLE t1, information_schema.tables;
CHECKSUM TABLE t1, information_schema.tables;
--error ER_DBACCESS_DENIED_ERROR
ANALYZE TABLE t1, information_schema.tables;
CHECK TABLE t1, information_schema.tables;
--error ER_DBACCESS_DENIED_ERROR
OPTIMIZE TABLE t1, information_schema.tables;
--error ER_DBACCESS_DENIED_ERROR
RENAME TABLE v1 to v2, information_schema.tables to t2;
--error ER_DBACCESS_DENIED_ERROR
DROP TABLE t1, information_schema.tables;

--error ER_DBACCESS_DENIED_ERROR
LOCK TABLES t1 READ, information_schema.tables READ;
DROP TABLE t1;
1571 1572


1573
#
1574
# Bug #43834    Assertion in Natural_join_column::db_name() on an I_S query
1575
#
1576

1577
SELECT *
1578 1579 1580 1581 1582 1583
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
LEFT JOIN INFORMATION_SCHEMA.COLUMNS
USING (TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME)
WHERE COLUMNS.TABLE_SCHEMA = 'test'
AND COLUMNS.TABLE_NAME = 't1';

1584

1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630
--echo #
--echo # A test case for Bug#56540 "Exception (crash) in sql_show.cc
--echo # during rqg_info_schema test on Windows"
--echo # Ensure that we never access memory of a closed table,
--echo # in particular, never access table->field[] array.
--echo # Before the fix, the below test case, produced
--echo # valgrind errors.
--echo #

--disable_warnings
drop table if exists t1;
drop view if exists v1;
--enable_warnings

create table t1 (a int, b int);
create view v1 as select t1.a, t1.b from t1;
alter table t1 change b c int;
lock table t1 read;
connect(con1, localhost, root,,);
connection con1;
send flush tables;
connection default;
let $wait_condition=
  select count(*) = 1 from information_schema.processlist
    where state = "Waiting for table flush" and
          info = "flush tables";
--source include/wait_condition.inc
--vertical_results
select * from information_schema.views;
--horizontal_results
unlock tables;

--echo #
--echo # Cleanup.
--echo #

connection con1;
--echo # Reaping 'flush tables'
reap;
disconnect con1;
--source include/wait_until_disconnected.inc
connection default;
drop table t1;
drop view v1;


1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760
--echo #
--echo # Test for bug #12828477 - "MDL SUBSYSTEM CREATES BIG OVERHEAD FOR
--echo #                           CERTAIN QUERIES TO INFORMATION_SCHEMA".
--echo #
--echo # Check that metadata locks which are acquired during the process
--echo # of opening tables/.FRMs/.TRG files while filling I_S table are
--echo # not kept to the end of statement. Keeping the locks has caused
--echo # performance problems in cases when big number of tables (.FRMs
--echo # or .TRG files) were scanned as cost of new lock acquisition has
--echo # increased linearly.
--disable_warnings
drop database if exists mysqltest;
--enable_warnings
create database mysqltest;
use mysqltest;
create table t0 (i int);
create table t1 (j int);
create table t2 (k int);

--echo #
--echo # Test that we don't keep locks in case when we to fill
--echo # I_S table we perform full-blown table open.
--echo #

--echo # Acquire lock on 't2' so upcoming RENAME is
--echo # blocked.
lock tables t2 read;

connect (con12828477_1, localhost, root,,mysqltest);
--echo # The below RENAME should wait on 't2' while
--echo # keeping X lock on 't1'.
--send rename table t1 to t3, t2 to t1, t3 to t2

connect (con12828477_2, localhost, root,,mysqltest);
--echo # Wait while the above RENAME is blocked.
let $wait_condition=
  select count(*) = 1 from information_schema.processlist
  where state = "Waiting for table metadata lock" and
        info = "rename table t1 to t3, t2 to t1, t3 to t2";
--source include/wait_condition.inc

--echo # Issue query to I_S which will open 't0' and get
--echo # blocked on 't1' because of RENAME.
--send select table_name, auto_increment from information_schema.tables where table_schema='mysqltest'

connect (con12828477_3, localhost, root,,mysqltest);
--echo # Wait while the above SELECT is blocked.
let $wait_condition=
  select count(*) = 1 from information_schema.processlist
  where state = "Waiting for table metadata lock" and
        info = "select table_name, auto_increment from information_schema.tables where table_schema='mysqltest'";
--source include/wait_condition.inc

--echo #
--echo # Check that it holds no lock on 't0' so it can be renamed.
rename table t0 to t4;

connection default;
--echo #
--echo # Unblock the first RENAME.
unlock tables;

connection con12828477_1;
--echo # Reap the first RENAME
--reap

connection con12828477_2;
--echo # Reap SELECT to I_S.
--reap

connection default;

--echo #
--echo # Now test that we don't keep locks in case when we to fill
--echo # I_S table we read .FRM or .TRG file only (this was the case
--echo # for which problem existed).
--echo #

rename table t4 to t0;
--echo # Acquire lock on 't2' so upcoming RENAME is
--echo # blocked.
lock tables t2 read;

connection con12828477_1;
--echo # The below RENAME should wait on 't2' while
--echo # keeping X lock on 't1'.
--send rename table t1 to t3, t2 to t1, t3 to t2

connection con12828477_2;
--echo # Wait while the above RENAME is blocked.
let $wait_condition=
  select count(*) = 1 from information_schema.processlist
  where state = "Waiting for table metadata lock" and
        info = "rename table t1 to t3, t2 to t1, t3 to t2";
--source include/wait_condition.inc

--echo # Issue query to I_S which will open 't0' and get
--echo # blocked on 't1' because of RENAME.
--send select event_object_table, trigger_name from information_schema.triggers where event_object_schema='mysqltest'

connection con12828477_3;
--echo # Wait while the above SELECT is blocked.
let $wait_condition=
  select count(*) = 1 from information_schema.processlist
  where state = "Waiting for table metadata lock" and
        info = "select event_object_table, trigger_name from information_schema.triggers where event_object_schema='mysqltest'";
--source include/wait_condition.inc

--echo #
--echo # Check that it holds no lock on 't0' so it can be renamed.
rename table t0 to t4;

connection default;
--echo #
--echo # Unblock the first RENAME.
unlock tables;

connection con12828477_1;
--echo # Reap the first RENAME
--reap

connection con12828477_2;
--echo # Reap SELECT to I_S.
--reap

connection default;
disconnect con12828477_1;
disconnect con12828477_2;
disconnect con12828477_3;

1761 1762 1763 1764 1765

--echo #
--echo # MDEV-3818: Query against view over IS tables worse than equivalent query without view
--echo #

1766
create view v1 as select table_schema, table_name, column_name from information_schema.columns;
1767 1768

explain extended
1769 1770
select column_name from v1
where (table_schema = "osm") and (table_name = "test");
1771 1772

explain extended
1773 1774 1775
select information_schema.columns.column_name as column_name
from information_schema.columns
where (information_schema.columns.table_schema = 'osm') and (information_schema.columns.table_name = 'test');
1776 1777 1778

drop view v1;

1779 1780 1781 1782
--echo #
--echo # Clean-up.
drop database mysqltest;

1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799
--echo #
--echo # Test for bug #16869534 - "QUERYING SUBSET OF COLUMNS DOESN'T USE TABLE
--echo #                           CACHE; OPENED_TABLES INCREASES"
--echo #
--disable_result_log
SELECT * FROM INFORMATION_SCHEMA.TABLES;
--enable_result_log
SELECT VARIABLE_VALUE INTO @val1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE
  VARIABLE_NAME LIKE 'Opened_tables';
--disable_result_log
SELECT ENGINE FROM INFORMATION_SCHEMA.TABLES;
--enable_result_log
--echo # The below SELECT query should give same output as above SELECT query.
SELECT VARIABLE_VALUE INTO @val2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE
  VARIABLE_NAME LIKE 'Opened_tables';
--echo # The below select should return '1'
SELECT @val1 = @val2;
1800

1801 1802 1803
--echo #
--echo # End of 5.5 tests
--echo #
1804

1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859
--echo # 
--echo # MDEV-5723: mysqldump -uroot unusable for multi-database operations, checks all databases
--echo # 

--disable_warnings
drop database if exists db1;
--enable_warnings

connect (con1,localhost,root,,);
connection con1;

create database db1;
use db1;
create table t1 (a int);
create table t2 (a int);
create table t3 (a int);

create database mysqltest;
use mysqltest;
create table t1 (a int);
create table t2 (a int);
create table t3 (a int);

flush tables;
flush status;

SELECT 
  LOGFILE_GROUP_NAME, FILE_NAME, TOTAL_EXTENTS, INITIAL_SIZE, ENGINE, EXTRA 
FROM 
  INFORMATION_SCHEMA.FILES 
WHERE 
  FILE_TYPE = 'UNDO LOG' AND FILE_NAME IS NOT NULL AND 
  LOGFILE_GROUP_NAME IN (SELECT DISTINCT LOGFILE_GROUP_NAME 
                         FROM INFORMATION_SCHEMA.FILES 
                         WHERE 
                           FILE_TYPE = 'DATAFILE' AND 
                           TABLESPACE_NAME IN (SELECT DISTINCT TABLESPACE_NAME 
                                               FROM INFORMATION_SCHEMA.PARTITIONS 
                                               WHERE TABLE_SCHEMA IN ('db1')
                                              )
                        ) 
GROUP BY 
  LOGFILE_GROUP_NAME, FILE_NAME, ENGINE 
ORDER BY 
  LOGFILE_GROUP_NAME;

--echo # This must have Opened_tables=3, not 6.
show status like 'Opened_tables';

drop database mysqltest;
drop database db1;

connection default;
disconnect con1;

1860 1861
# Wait till all disconnects are completed
--source include/wait_until_count_sessions.inc
1862

1863
set global sql_mode=default;