1# Tests for PERFORMANCE_SCHEMA 2# Make sure mysql_upgrade does not destroy data in a 'performance_schema' 3# database. 4# 5 6# Some initial settings + Preemptive cleanup 7let $MYSQLD_DATADIR= `SELECT @@datadir`; 8let $err_file= $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err; 9let $out_file= $MYSQLTEST_VARDIR/tmp/pfs_upgrade.out; 10--error 0,1 11--remove_file $out_file 12--error 0,1 13--remove_file $err_file 14 15--disable_warnings 16drop table if exists test.user_table; 17drop procedure if exists test.user_proc; 18drop function if exists test.user_func; 19drop event if exists test.user_event; 20--enable_warnings 21 22 23--echo "Testing mysql_upgrade with TABLE performance_schema.user_table" 24 25create table test.user_table(a int); 26 27--error 0,1 28--remove_file $MYSQLD_DATADIR/performance_schema/user_table.frm 29--copy_file $MYSQLD_DATADIR/test/user_table.frm $MYSQLD_DATADIR/performance_schema/user_table.frm 30 31# Make sure the table is visible 32use performance_schema; 33show tables like "user_table"; 34 35--source suite/perfschema/include/upgrade_check.inc 36 37# Make sure the table is still visible 38show tables like "user_table"; 39 40use test; 41 42--remove_file $MYSQLD_DATADIR/performance_schema/user_table.frm 43drop table test.user_table; 44 45 46--echo "Testing mysql_upgrade with VIEW performance_schema.user_view" 47 48create view test.user_view as select "Not supposed to be here"; 49 50--error 0,1 51--remove_file $MYSQLD_DATADIR/performance_schema/user_view.frm 52--copy_file $MYSQLD_DATADIR/test/user_view.frm $MYSQLD_DATADIR/performance_schema/user_view.frm 53 54# Make sure the view is visible 55use performance_schema; 56show tables like "user_view"; 57 58--source suite/perfschema/include/upgrade_check.inc 59 60# Make sure the view is still visible 61show tables like "user_view"; 62 63use test; 64 65--remove_file $MYSQLD_DATADIR/performance_schema/user_view.frm 66drop view test.user_view; 67 68 69--echo "Testing mysql_upgrade with PROCEDURE performance_schema.user_proc" 70 71create procedure test.user_proc() 72 select "Not supposed to be here"; 73 74update mysql.proc set db='performance_schema' where name='user_proc'; 75 76--source suite/perfschema/include/upgrade_check.inc 77 78select name from mysql.proc where db='performance_schema'; 79 80update mysql.proc set db='test' where name='user_proc'; 81drop procedure test.user_proc; 82 83 84--echo "Testing mysql_upgrade with FUNCTION performance_schema.user_func" 85 86create function test.user_func() returns integer 87 return 0; 88 89update mysql.proc set db='performance_schema' where name='user_func'; 90 91--source suite/perfschema/include/upgrade_check.inc 92 93select name from mysql.proc where db='performance_schema'; 94 95update mysql.proc set db='test' where name='user_func'; 96drop function test.user_func; 97 98 99--echo "Testing mysql_upgrade with EVENT performance_schema.user_event" 100 101create event test.user_event on schedule every 1 day do 102 select "not supposed to be here"; 103 104update mysql.event set db='performance_schema' where name='user_event'; 105 106--source suite/perfschema/include/upgrade_check.inc 107 108select name from mysql.event where db='performance_schema'; 109 110update mysql.event set db='test' where name='user_event'; 111drop event test.user_event; 112 113