config root man

Current Path : /usr/opt/mysql57/mysql-test/t/

FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64
Upload File :
Current File : //usr/opt/mysql57/mysql-test/t/mysql_upgrade.test

-- source include/no_valgrind_without_big.inc
-- source include/mysql_upgrade_preparation.inc

#
# Basic test that we can run mysql_upgrde and that it finds the
# expected binaries it uses.
#
--echo Run mysql_upgrade once
--exec $MYSQL_UPGRADE --skip-verbose --force 2>&1

# It should have created a file in the MySQL Servers datadir
let $MYSQLD_DATADIR= `select @@datadir`;
file_exists $MYSQLD_DATADIR/mysql_upgrade_info;

--echo Run it again - should say already completed
--replace_result $MYSQL_SERVER_VERSION VERSION
--error 2
--exec $MYSQL_UPGRADE --skip-verbose 2>&1

# It should have created a file in the MySQL Servers datadir
file_exists $MYSQLD_DATADIR/mysql_upgrade_info;

--echo Force should run it regardless of wether it's been run before
--exec $MYSQL_UPGRADE --skip-verbose --force 2>&1

# It should have created a file in the MySQL Servers datadir
file_exists $MYSQLD_DATADIR/mysql_upgrade_info;


#
# Bug #25452 mysql_upgrade access denied.
#

# Password protect a root account and run mysql_upgrade

CREATE USER mysqltest1@'%' IDENTIFIED by 'sakila';
GRANT ALL ON *.* TO mysqltest1@'%';
--echo Run mysql_upgrade with password protected account
--exec $MYSQL_UPGRADE --skip-verbose --force --user=mysqltest1 --password=sakila 2>&1

DROP USER mysqltest1@'%';


#
# Bug #26639 mysql_upgrade exits successfully even if external command failed
#

--echo Run mysql_upgrade with a non existing server socket
--replace_result $MYSQLTEST_VARDIR var
--replace_regex /.*mysqlcheck.*: Got/mysqlcheck: Got/ /\([0-9]*\)/(errno)/
--error 11
# NC: Added --skip-version-check, as the version check would fail when
# mysql_upgrade tries to get the server version.
--exec $MYSQL_UPGRADE --skip-verbose --force --host=not_existing_host --skip-version-check 2>&1

#
# Bug #28401 mysql_upgrade Failed with STRICT_ALL_TABLES, ANSI_QUOTES and NO_ZERO_DATE
#

# The SQL commands used by mysql_upgrade are written to be run
# with sql_mode set to '' - thus the scripts should change sql_mode
# for the session to make sure the SQL is legal.

# Test by setting sql_mode before running mysql_upgrade
--exec $MYSQL_UPGRADE --skip-verbose --force 2>&1

--echo #
--echo # Bug #41569 mysql_upgrade (ver 5.1) add 3 fields to mysql.proc table
--echo # but does not set values.
--echo #

# Create a stored procedure and set the fields in question to null.
# When running mysql_upgrade, a warning should be written.

CREATE PROCEDURE testproc() BEGIN END;
UPDATE mysql.proc SET character_set_client = NULL WHERE name LIKE 'testproc';
UPDATE mysql.proc SET collation_connection = NULL WHERE name LIKE 'testproc';
UPDATE mysql.proc SET db_collation = NULL WHERE name LIKE 'testproc';
--exec $MYSQL_UPGRADE --skip-verbose --force 2> $MYSQLTEST_VARDIR/tmp/41569.txt
CALL testproc();
DROP PROCEDURE testproc;
--cat_file $MYSQLTEST_VARDIR/tmp/41569.txt
--remove_file $MYSQLTEST_VARDIR/tmp/41569.txt


--echo #
--echo # Bug #53613: mysql_upgrade incorrectly revokes
--echo #   TRIGGER privilege on given table
--echo #

SET @orig_sql_mode= @@sql_mode;
SET sql_mode= (SELECT replace(@@sql_mode,'NO_AUTO_CREATE_USER',''));
GRANT USAGE ON *.* TO 'user3'@'%';
SET sql_mode= @orig_sql_mode;
GRANT ALL PRIVILEGES ON `roelt`.`test2` TO 'user3'@'%';
--echo Run mysql_upgrade with all privileges on a user
--exec $MYSQL_UPGRADE --skip-verbose --force 2>&1
SHOW GRANTS FOR 'user3'@'%';

DROP USER 'user3'@'%';

--echo End of 5.1 tests


#
# Test the --upgrade-system-tables option
#
--replace_result $MYSQLTEST_VARDIR var
--exec $MYSQL_UPGRADE --skip-verbose --force --upgrade-system-tables

--echo #
--echo # Bug#12688860 : SECURITY RECOMMENDATION: PASSWORDS ON CLI
--echo #
--exec $MYSQL_UPGRADE -uroot --password= --skip-verbose --force 2>&1


--echo #
--echo # Bug#11827359 60223: MYSQL_UPGRADE PROBLEM WITH OPTION
--echo #                     SKIP-WRITE-BINLOG
--echo #

let $MYSQLD_DATADIR= `select @@datadir`;

--echo # Droping the previously created mysql_upgrade_info file..
--remove_file $MYSQLD_DATADIR/mysql_upgrade_info

--echo # Running mysql_upgrade with --skip-write-binlog..
--replace_result $MYSQLTEST_VARDIR var
--exec $MYSQL_UPGRADE --skip-verbose --skip-write-binlog

# mysql_upgrade must have created mysql_upgrade_info file,
# so the following command should never fail.
--remove_file $MYSQLD_DATADIR/mysql_upgrade_info

--echo # Running mysql_upgrade with --write-binlog..
--replace_result $MYSQLTEST_VARDIR var
--exec $MYSQL_UPGRADE --skip-verbose --write-binlog

--echo # Running mysql_upgrade with --max-allowed-packet=4096..
--exec $MYSQL_UPGRADE --max-allowed-packet=4096 --skip-verbose --force 2>&1

--echo # Running mysql_upgrade with --max-allowed-packet=2147483648..
--exec $MYSQL_UPGRADE --max-allowed-packet=2147483648 --skip-verbose --force 2>&1

--echo # Running mysql_upgrade with --max-allowed-packet=4095..
--exec $MYSQL_UPGRADE --max-allowed-packet=4095 --skip-verbose --force 2>&1

--echo # Running mysql_upgrade with --max-allowed-packet=1000..
--exec $MYSQL_UPGRADE --max-allowed-packet=1000 --skip-verbose --force 2>&1

--echo # Running mysql_upgrade with --max-allowed-packet=2147483649..
--exec $MYSQL_UPGRADE --max-allowed-packet=2147483649 --skip-verbose --force 2>&1

--echo # Running mysql_upgrade with --max-allowed-packet=21474836480..
--exec $MYSQL_UPGRADE --max-allowed-packet=2147484652 --skip-verbose --force 2>&1

--echo # Running mysql_upgrade with --net-buffer-length=4096..
--exec $MYSQL_UPGRADE --net-buffer-length=4096 --skip-verbose --force 2>&1

--echo # Running mysql_upgrade with --net-buffer-length=16777216..
--exec $MYSQL_UPGRADE --net-buffer-length=16777216 --skip-verbose --force 2>&1

--echo # Running mysql_upgrade with --net-buffer-length=4095..
--exec $MYSQL_UPGRADE --net-buffer-length=4095 --skip-verbose --force 2>&1

--echo # Running mysql_upgrade with --net-buffer-length=1024..
--exec $MYSQL_UPGRADE --net-buffer-length=1024 --skip-verbose --force 2>&1

--echo # Running mysql_upgrade with --net-buffer-length=16777217..
--exec $MYSQL_UPGRADE --net-buffer-length=16777217 --skip-verbose --force 2>&1

--echo # Running mysql_upgrade with --net-buffer-length=167772160..
--exec $MYSQL_UPGRADE --net-buffer-length=167772160 --skip-verbose --force 2>&1

--echo # Running mysql_upgrade with --bind-address..
--exec $MYSQL_UPGRADE --bind-address=127.0.0.1 --skip-verbose --force 2>&1

--echo # Running mysql_upgrade with -C option..
--exec $MYSQL_UPGRADE -C --skip-verbose --force 2>&1

--echo # Running mysql_upgrade with --compress..
--exec $MYSQL_UPGRADE --compress --skip-verbose --force 2>&1

--echo # Running mysql_upgrade with --verbose..
--exec $MYSQL_UPGRADE --verbose --force 2>&1

--echo # Running mysql_upgrade with --protocol..
--exec $MYSQL_UPGRADE --protocol=TCP --skip-verbose --force 2>&1

--echo # Test positional arguments
--exec $MYSQL_UPGRADE --force --skip-verbose not_used_positional_argument 2>&1

--echo #
--echo # WL#7010: Remove unused --basedir and --datadir options
--echo #   from mysql_upgrade
--echo #

--echo Run mysql_upgrade with --datadir : should fail
--replace_regex /.*mysql_upgrade.*: unk/mysql_upgrade: unk/
--error 7
--exec $MYSQL_UPGRADE --skip-verbose --force --datadir=somedir 2>&1

--echo Run mysql_upgrade with --basedir : should fail
--replace_regex /.*mysql_upgrade.*: unk/mysql_upgrade: unk/
--error 7
--exec $MYSQL_UPGRADE --skip-verbose --force --basedir=somedir 2>&1

--echo # Running mysql_upgrade with invalid/incorrect options
--error 2
--exec $MYSQL_UPGRADE -c --force 2>&1

--error 2
--exec $MYSQL_UPGRADE -t --force 2>&1

--error 1
--exec $MYSQL_UPGRADE --protocol=AAA --force 2>&1


--echo #
--echo # Bug #19011337: UPGRADE TO 5.7 DISABLES USER ACCOUNTS
--echo #

# Backup mysql.user table
CREATE TABLE backup_user AS SELECT * FROM mysql.user;

# Create 5.6 mysql.user table layout

--source include/user_57_to_56.inc

INSERT INTO mysql.user VALUES
('localhost','B19011337_nhash','*46ABF58B20022A84DF7B2E8B1AC8219C8DA71553','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0,'','','N'),
('localhost','B19011337_ohash','0f0ea7602c473904','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0,'','','N');

call mtr.add_suppression("Some of the user accounts with SUPER");
call mtr.add_suppression("1. Stop");
call mtr.add_suppression("2. Run");
call mtr.add_suppression("3. Restart");
call mtr.add_suppression("For complete");
call mtr.add_suppression("User entry .B19011337");

--echo # expect a warning in the error log
FLUSH PRIVILEGES;

--echo # let's check for the presense of the warning
let server_log= $MYSQLTEST_VARDIR/log/mysqld.1.err;
# $server_log has to be processed by include/search_pattern_in_file.inc which
# contains Perl code requiring that the environment variable SEARCH_FILE points
# to this file.
let SEARCH_FILE= $server_log;

--let SEARCH_PATTERN= User entry 'B19011337_ohash'@'localhost' has a deprecated pre-4.1 password. The user will be ignored and no one can login with this user anymore.
--source include/search_pattern_in_file.inc

--let SEARCH_PATTERN= 1. Stop
--source include/search_pattern_in_file.inc

--let SEARCH_PATTERN= 2. Run
--source include/search_pattern_in_file.inc

--let SEARCH_PATTERN= 3. Restart
--source include/search_pattern_in_file.inc

--let SEARCH_PATTERN= For complete instructions on how to upgrade MySQL
--source include/search_pattern_in_file.inc
--echo # end of check for the presense of the warning

--echo # repair the user's plugin
--exec $MYSQL_UPGRADE --skip-verbose --force 2>&1

--echo # expect mysql_native_password
SELECT plugin FROM mysql.user WHERE user='B19011337_nhash';

--echo # expect empty plugin
SELECT plugin FROM mysql.user WHERE user='B19011337_ohash';

--echo # cleanup
DROP USER B19011337_nhash@localhost;
DROP USER B19011337_ohash@localhost;

# Restore mysql.user content
TRUNCATE TABLE mysql.user;
INSERT INTO mysql.user SELECT * FROM backup_user;
DROP TABLE backup_user;

--echo #
--echo # Upgrading of sys schema tests
--echo #

# Save a copy of the user/tables_priv tables, to restore later
# Otherwise the final mysql_upgrade will REPLACE and update timestamps etc.
--let $backup= 1
--source include/backup_tables_priv_and_users.inc

--echo # Remove the sys schema, and check the --skip-sys-schema option
DROP DATABASE sys;
--exec $MYSQL_UPGRADE --skip-verbose --skip-sys-schema --force
SHOW DATABASES;

--echo # Now run it normally, to ensure the sys schema is created
--exec $MYSQL_UPGRADE --skip-verbose --force
SHOW DATABASES;

--echo # Now drop procedures and make sure re-install is done
DROP PROCEDURE sys.ps_setup_save;
DROP PROCEDURE sys.ps_setup_reload_saved;
--exec $MYSQL_UPGRADE --skip-verbose --force
SELECT ROUTINE_NAME FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_SCHEMA = 'sys' AND ROUTINE_TYPE = 'PROCEDURE';

--echo # Now drop functions and make sure re-install is done
DROP FUNCTION sys.format_bytes;
DROP FUNCTION sys.format_time;
--exec $MYSQL_UPGRADE --skip-verbose --force
SELECT ROUTINE_NAME FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_SCHEMA = 'sys' AND ROUTINE_TYPE = 'FUNCTION';

--echo # Now drop views and make sure re-install is done
DROP VIEW sys.host_summary;
DROP VIEW sys.processlist;
--exec $MYSQL_UPGRADE --skip-verbose --force
SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'sys' AND TABLE_TYPE = 'VIEW';

--echo # Now drop triggers and make sure re-install is done
DROP TRIGGER sys.sys_config_insert_set_user;
DROP TRIGGER sys.sys_config_update_set_user;
--exec $MYSQL_UPGRADE --skip-verbose --force
SELECT TRIGGER_NAME FROM INFORMATION_SCHEMA.TRIGGERS WHERE TRIGGER_SCHEMA = 'sys';

--echo # Now drop the sys_config table and make sure re-install is done
DROP TABLE sys.sys_config;
--exec $MYSQL_UPGRADE --skip-verbose --force
SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'sys' AND TABLE_TYPE = 'BASE TABLE';

# Restore the saved contents of mysql.user and mysql.tables_priv
--let $restore= 1
--source include/backup_tables_priv_and_users.inc

--echo #
--echo # BUG#18985579: "CHECK TABLE .. FOR UPGRADE" FAILS TO REPORT
--echo #                OLD DATETIME FORMAT. 

let $MYSQLD_DATADIR= `select @@datadir`;
--copy_file std_data/55_temporal.frm $MYSQLD_DATADIR/test/t1.frm
--copy_file std_data/55_temporal.MYD $MYSQLD_DATADIR/test/t1.MYD
--copy_file std_data/55_temporal.MYI $MYSQLD_DATADIR/test/t1.MYI

--echo #Test case with 'avoid_temporal_upgrade' enabled.
SET @save_avoid_temporal_upgrade= @@global.avoid_temporal_upgrade;
SET GLOBAL avoid_temporal_upgrade= ON;

SELECT f_time, f_datetime, f_timestamp, HEX(WEIGHT_STRING(f_time)),
HEX(WEIGHT_STRING(f_datetime)), HEX(WEIGHT_STRING(f_timestamp)) FROM t1;

--echo #mysql_upgrade does not upgrade the old temporal types since
--echo #'avoid_temporal_upgrade' is enabled..
--exec $MYSQL_UPGRADE --skip-verbose --force 2>&1

SELECT f_time, f_datetime, f_timestamp, HEX(WEIGHT_STRING(f_time)),
HEX(WEIGHT_STRING(f_datetime)), HEX(WEIGHT_STRING(f_timestamp)) FROM t1;

SET @@global.avoid_temporal_upgrade= @save_avoid_temporal_upgrade;


--echo #Test case with 'avoid_temporal_upgrade' disabled.
SELECT f_time, f_datetime, f_timestamp, HEX(WEIGHT_STRING(f_time)),
HEX(WEIGHT_STRING(f_datetime)), HEX(WEIGHT_STRING(f_timestamp)) FROM t1;

--echo #mysql_upgrade upgrades the old temporal types.
--exec $MYSQL_UPGRADE --skip-verbose --force 2>&1

SELECT f_time, f_datetime, f_timestamp, HEX(WEIGHT_STRING(f_time)),
HEX(WEIGHT_STRING(f_datetime)), HEX(WEIGHT_STRING(f_timestamp)) FROM t1;

#Cleanup.
DROP TABLE t1;

--echo #
--echo # WL #8350 ENSURE 5.7 SUPPORTS SMOOTH LIVE UPGRADE FROM 5.6
--echo #

call mtr.add_suppression("Column count of mysql.* is wrong. "
                         "Expected .*, found .*. "
                         "The table is probably corrupted");

let server_log= $MYSQLTEST_VARDIR/log/mysqld.1.err;
# Backup mysql.user table
CREATE TABLE backup_user AS SELECT * FROM mysql.user;

# Create 5.6 mysql.user table layout

--source include/user_57_to_56.inc

call mtr.add_suppression("The plugin 'mysql_old_password' used to authenticate user 'user_old_pass_wp'@'%' is not loaded. Nobody can currently login using this account.");

--echo # Because su_old_pass_pn is a super user without plugin name but with pre 4.1
--echo # hash password we generate instruction on how one can proceed with
--echo # the upgrade using this account.
call mtr.add_suppression("Some of the user accounts with SUPER");
call mtr.add_suppression("1. Stop");
call mtr.add_suppression("2. Run");
call mtr.add_suppression("3. Restart");
call mtr.add_suppression("For complete");

# Password for each user is 'lala'

INSERT INTO mysql.user VALUES
('%','user_old_pass_wp','0f0ea7602c473904','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','','','','',0,0,0,0,'mysql_old_password','','N');
INSERT INTO mysql.user VALUES
('%','user_old_pass_pn','0f0ea7602c473904','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','','','','',0,0,0,0,'','','N'),
('%','su_old_pass_pn','0f0ea7602c473904','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0,'','','N'),
('%','user_nat_pass_pn','*46ABF58B20022A84DF7B2E8B1AC8219C8DA71553','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','','','','',0,0,0,0,NULL,'','N'),
('%','user_nat_pass_wp','*46ABF58B20022A84DF7B2E8B1AC8219C8DA71553','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','','','','',0,0,0,0,'mysql_native_password','','N');

FLUSH PRIVILEGES;

--echo # check the presents of the warnings in the log file
let SEARCH_FILE= $server_log;

--let SEARCH_PATTERN= User entry 'user_old_pass_pn'@'%' has a deprecated pre-4.1 password. The user will be ignored and no one can login with this user anymore.
--source include/search_pattern_in_file.inc

--let SEARCH_PATTERN= User entry 'su_old_pass_pn'@'%' has a deprecated pre-4.1 password. The user will be ignored and no one can login with this user anymore.
--source include/search_pattern_in_file.inc

--echo # end of check for the presense of the warning

--echo #Connect using root account - should succeed
connect (con0,localhost,root,,);

--echo #Connecting user with pre 4.1 hash and empty plugin- should fail
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
--error ER_ACCESS_DENIED_ERROR
connect (con1,localhost,user_old_pass_pn,lala,);

--echo #Connecting user with pre 4.1 hash and mysql_old_password plugin set -
--echo #should fail - the mysql_old_password was removed in 5.7
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
--error ER_PLUGIN_IS_NOT_LOADED
connect (con2,localhost,user_old_pass_wp,lala,);

--echo #Connecting user with 4.1 hash and empty plugin - should succeed
connect (con3,localhost,user_nat_pass_pn,lala,);

--echo #Connecting user with 4.1 hash and mysql_native_plugin plugin set -
--echo #should succeed
connect (con4,localhost,user_nat_pass_wp,lala,);

connection con3;
--echo #Trying to do select on mysql.user table - should fail as
--echo #user_nat_pass_pn is not a super user
--error ER_TABLEACCESS_DENIED_ERROR
SELECT * FROM mysql.user WHERE user="user_nat_pass_pn";

--echo #Try granting all privileges on mysql db to user_nat_pass_pn using root
--echo #account - this should fail since mysql.user table has 5.6 layout.
connection con0;
--error ER_COL_COUNT_DOESNT_MATCH_CORRUPTED_V2
GRANT ALL PRIVILEGES ON mysql.* TO 'user_nat_pass_pn'@'%' WITH GRANT OPTION;

connection con3;
--echo #Select on mysql.user should not be possible since user_nat_pass_pn has
--echo #no select privileges on mysql database
--error ER_TABLEACCESS_DENIED_ERROR
SELECT * FROM mysql.user WHERE user="user_nat_pass_pn";

--echo #Revoke all privileges from 'user_nat_pass_pn'@'%' - this should fail
--echo #since mysql.user table has 5.6 layout.
connection con0;
--error ER_COL_COUNT_DOESNT_MATCH_CORRUPTED_V2
REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user_nat_pass_pn'@'%';

connection con3;
--echo #Trying to do select on mysql.user table - this should fail since
--echo #user_nat_pass_pn has no select prvileleges on mysql db.
--error ER_TABLEACCESS_DENIED_ERROR
SELECT * FROM mysql.user WHERE user="user_nat_pass_pn";

connection con0;
--echo #All alter user commands should fail since mysql.user has 5.6 layout.
SELECT authentication_string FROM mysql.user where user='user_nat_pass_pn';
SELECT password_expired FROM mysql.user where user='user_nat_pass_pn';

--error ER_COL_COUNT_DOESNT_MATCH_CORRUPTED_V2
ALTER USER 'user_nat_pass_pn'@'%' PASSWORD EXPIRE;

SELECT authentication_string FROM mysql.user WHERE user='user_nat_pass_pn';
SELECT password_expired FROM mysql.user WHERE user='user_nat_pass_pn';

--echo #Fix authentication string
UPDATE mysql.user SET authentication_string='' WHERE user='user_nat_pass_pn';

--echo #"Manualy" grant super user privileges to user_nat_pass_pn, note we are
--echo #now updating mysql_user to get all privileges on *.*
connection con0;

UPDATE mysql.user SET Select_priv='Y', Insert_priv='Y', Update_priv='Y', Delete_priv='Y', Create_priv='Y', Drop_priv='Y', Reload_priv='Y', Shutdown_priv='Y', Process_priv='Y', File_priv='Y', Grant_priv='Y', References_priv='Y', Index_priv='Y', Alter_priv='Y', Show_db_priv='Y', Super_priv='Y', Create_tmp_table_priv='Y', Lock_tables_priv='Y', Execute_priv='Y', Repl_slave_priv='Y', Repl_client_priv='Y', Create_view_priv='Y', Show_view_priv='Y', Create_routine_priv='Y', Alter_routine_priv='Y', Create_user_priv='Y', Event_priv='Y', Trigger_priv='Y', Create_tablespace_priv='Y' where user="user_nat_pass_pn";

FLUSH PRIVILEGES;

#connection con3;
--echo #Select on mysql.user should now be possible
SELECT * FROM mysql.user WHERE user="user_nat_pass_pn";

connection default;

--echo #Run mysql_upgrade with user_nat_pass_pn - i.e. user with empty plugin
--echo #column and 4.1 hash password. After mysql_upgrade finishes the
--echo #mysql.user table should have 5.7 layout thus no need to restore the
--echo #dropped columns from the begining of the test
--exec $MYSQL_UPGRADE --skip-verbose --force --user=user_nat_pass_pn --password=lala 2>&1

call mtr.add_suppression("User entry 'user_old_pass_pn'@'%' has an empty plugin value. The user will be ignored and no one can login with this user anymore.");
call mtr.add_suppression("User entry 'su_old_pass_pn'@'%' has an empty plugin value. The user will be ignored and no one can login with this user anymore.");

--echo # check the presents of the warnings in the log file
let SEARCH_FILE= $server_log;

--let SEARCH_PATTERN= User entry 'user_old_pass_pn'@'%' has an empty plugin value.
--source include/search_pattern_in_file.inc

--let SEARCH_PATTERN= User entry 'su_old_pass_pn'@'%' has an empty plugin value.
--source include/search_pattern_in_file.inc

--echo # end of check for the presense of the warning

disconnect con0;
disconnect con3;
disconnect con4;

--echo #Restart the server
--source include/restart_mysqld.inc

--echo #After the update all acl commands should be working fine. Trying out
--echo #some of them

ALTER USER 'user_nat_pass_pn'@'%' PASSWORD EXPIRE;
SELECT password_expired FROM mysql.user WHERE user='user_nat_pass_pn';
SET PASSWORD FOR user_nat_pass_pn@'%' = 'lala';
SELECT password_expired FROM mysql.user WHERE user='user_nat_pass_pn';

ALTER USER 'user_nat_pass_wp'@'%' ACCOUNT LOCK;
SELECT account_locked FROM mysql.user WHERE user='user_nat_pass_wp';
ALTER USER 'user_nat_pass_wp'@'%' ACCOUNT UNLOCK;
SELECT account_locked FROM mysql.user WHERE user='user_nat_pass_wp';

--echo #Connecting with user using mysql_old_password plugin should not be
--echo #possible
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
--error ER_PLUGIN_IS_NOT_LOADED
connect (con5,localhost,user_old_pass_wp,lala,);

--echo #Creating super user and assigning all privileges to it. This updates
--echo #mysql.user table so should now be possible.
CREATE USER super@localhost IDENTIFIED BY 'lala';
GRANT ALL PRIVILEGES ON *.* TO super@localhost WITH GRANT OPTION;
SELECT user FROM mysql.user WHERE user='super';

# Cleanup

DROP USER 'super'@'localhost';
DROP USER 'user_old_pass_pn'@'%';
DROP USER 'su_old_pass_pn'@'%';
DROP USER 'user_old_pass_wp'@'%';
DROP USER 'user_nat_pass_pn'@'%';
DROP USER 'user_nat_pass_wp'@'%';

# Restore mysql.user content
TRUNCATE TABLE mysql.user;
INSERT INTO mysql.user SELECT * FROM backup_user;
DROP TABLE backup_user;


--echo #
--echo # BUG#20614545: USERS WITH OLD-PASSWORD=1 CHANGED TO
--echo # MYSQL_NATIVE_PASSWORD AFTER UPGRADE
--echo #

let server_log= $MYSQLTEST_VARDIR/log/mysqld.1.err;
# Backup mysql.user table
CREATE TABLE backup_user AS SELECT * FROM mysql.user;

# Create 5.6 mysql.user table layout

--source include/user_57_to_56.inc

INSERT INTO mysql.user VALUES
('localhost','B20614545','0f0ea7602c473904','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','','','','',0,0,0,0,'','','N');

FLUSH PRIVILEGES;

--echo # check the presents of the warnings in the log file
let SEARCH_FILE= $server_log;

--let SEARCH_PATTERN= User entry 'B20614545'@'localhost' has a deprecated pre-4.1 password. The user will be ignored and no one can login with this user anymore.
--source include/search_pattern_in_file.inc

--echo # end of check for the presense of the warning

--exec $MYSQL_UPGRADE --skip-verbose --force 2>&1

call mtr.add_suppression("User entry 'B20614545'@'localhost' has an empty plugin value. The user will be ignored and no one can login with this user anymore.");

--echo # check the presents of the warnings in the log file
let SEARCH_FILE= $server_log;

--let SEARCH_PATTERN= User entry 'B20614545'@'localhost' has an empty plugin value.
--source include/search_pattern_in_file.inc

--echo # end of check for the presense of the warning

--echo #Restart the server
--source include/restart_mysqld.inc

--echo # expect empty plugin
SELECT plugin FROM mysql.user WHERE user='B20614545';

DROP USER B20614545@localhost;

# Restore mysql.user content
TRUNCATE TABLE mysql.user;
INSERT INTO mysql.user SELECT * FROM backup_user;
DROP TABLE backup_user;

--echo #
--echo # WL#2284: Increase the length of a user name
--echo #


--echo # First downgrade all tables with user name columnd to 5.6

SET @orig_sql_mode= @@sql_mode;
SET sql_mode= (SELECT replace(@@sql_mode,'NO_ZERO_DATE',''));

#This user is not compatible with 5.6 tables
let $date_to_restore=`SELECT password_last_changed from mysql.user where user='mysql.session'`;
let $sess_user_account_priv=`SELECT timestamp from mysql.tables_priv where user='mysql.session'`;
DELETE FROM mysql.tables_priv WHERE user='mysql.session';
DELETE FROM mysql.user WHERE user='mysql.session';
DELETE FROM mysql.db WHERE user='mysql.session';

ALTER TABLE mysql.tables_priv
  MODIFY User char(16) NOT NULL default '',
  MODIFY Grantor char(77) DEFAULT '' NOT NULL;
ALTER TABLE mysql.columns_priv
  MODIFY User char(16) NOT NULL default '';
ALTER TABLE mysql.user
  MODIFY User char(16) NOT NULL default '';
ALTER TABLE mysql.db
  MODIFY User char(16) NOT NULL default '';
ALTER TABLE mysql.procs_priv
  MODIFY User char(16) binary DEFAULT '' NOT NULL,
  MODIFY Grantor char(77) DEFAULT '' NOT NULL;
ALTER TABLE mysql.proc
  MODIFY definer char(77) collate utf8_bin DEFAULT '' NOT NULL;
ALTER TABLE mysql.event
  MODIFY definer char(77) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '';

SET sql_mode= @orig_sql_mode;

--echo #
--echo # Downgrade performance_schema tables
--echo #

set @have_pfs= (select count(engine) from information_schema.engines where engine='PERFORMANCE_SCHEMA' and support != 'NO');

--echo #
--echo # TABLE USERS
--echo #

SET @cmd="DROP TABLE IF EXISTS performance_schema.users;";

SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

SET @cmd="CREATE TABLE performance_schema.users("
  "USER CHAR(16) collate utf8_bin default null,"
  "CURRENT_CONNECTIONS bigint not null,"
  "TOTAL_CONNECTIONS bigint not null"
  ")ENGINE=PERFORMANCE_SCHEMA;";

SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

--echo #
--echo # TABLE ACCOUNTS
--echo #

SET @cmd="DROP TABLE IF EXISTS performance_schema.accounts;";

SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

SET @cmd="CREATE TABLE performance_schema.accounts("
  "USER CHAR(16) collate utf8_bin default null,"
  "HOST CHAR(60) collate utf8_bin default null,"
  "CURRENT_CONNECTIONS bigint not null,"
  "TOTAL_CONNECTIONS bigint not null"
  ")ENGINE=PERFORMANCE_SCHEMA;";

SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

--echo #
--echo # TABLE SETUP_ACTORS
--echo #

SET @cmd="DROP TABLE IF EXISTS performance_schema.setup_actors;";

SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

SET @cmd="CREATE TABLE performance_schema.setup_actors("
  "HOST CHAR(60) collate utf8_bin default '%' not null,"
  "USER CHAR(16) collate utf8_bin default '%' not null,"
  "ROLE CHAR(16) collate utf8_bin default '%' not null,"
  "ENABLED ENUM ('YES', 'NO') not null default 'YES',"
  "HISTORY ENUM ('YES', 'NO') not null default 'YES'"
  ")ENGINE=PERFORMANCE_SCHEMA;";

SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

--echo #
--echo # TABLE EVENTS_STAGES_SUMMARY_BY_USER_BY_EVENT_NAME
--echo #

SET @cmd="DROP TABLE IF EXISTS performance_schema.events_stages_summary_by_user_by_event_name;";

SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

SET @cmd="CREATE TABLE performance_schema.events_stages_summary_by_user_by_event_name("
  "USER CHAR(16) collate utf8_bin default null,"
  "EVENT_NAME VARCHAR(128) not null,"
  "COUNT_STAR BIGINT unsigned not null,"
  "SUM_TIMER_WAIT BIGINT unsigned not null,"
  "MIN_TIMER_WAIT BIGINT unsigned not null,"
  "AVG_TIMER_WAIT BIGINT unsigned not null,"
  "MAX_TIMER_WAIT BIGINT unsigned not null"
  ")ENGINE=PERFORMANCE_SCHEMA;";

SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

--echo #
--echo # TABLE EVENTS_WAITS_SUMMARY_BY_USER_BY_EVENT_NAME
--echo #

SET @cmd="DROP TABLE IF EXISTS performance_schema.events_waits_summary_by_user_by_event_name;";

SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

SET @cmd="CREATE TABLE performance_schema.events_waits_summary_by_user_by_event_name("
  "USER CHAR(16) collate utf8_bin default null,"
  "EVENT_NAME VARCHAR(128) not null,"
  "COUNT_STAR BIGINT unsigned not null,"
  "SUM_TIMER_WAIT BIGINT unsigned not null,"
  "MIN_TIMER_WAIT BIGINT unsigned not null,"
  "AVG_TIMER_WAIT BIGINT unsigned not null,"
  "MAX_TIMER_WAIT BIGINT unsigned not null"
  ")ENGINE=PERFORMANCE_SCHEMA;";

SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

--echo #
--echo # TABLE EVENTS_WAITS_SUMMARY_BY_ACCOUNT_BY_EVENT_NAME
--echo #

SET @cmd="DROP TABLE IF EXISTS performance_schema.events_waits_summary_by_account_by_event_name;";

SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

SET @cmd="CREATE TABLE performance_schema.events_waits_summary_by_account_by_event_name("
  "USER CHAR(16) collate utf8_bin default null,"
  "HOST CHAR(60) collate utf8_bin default null,"
  "EVENT_NAME VARCHAR(128) not null,"
  "COUNT_STAR BIGINT unsigned not null,"
  "SUM_TIMER_WAIT BIGINT unsigned not null,"
  "MIN_TIMER_WAIT BIGINT unsigned not null,"
  "AVG_TIMER_WAIT BIGINT unsigned not null,"
  "MAX_TIMER_WAIT BIGINT unsigned not null"
  ")ENGINE=PERFORMANCE_SCHEMA;";

SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

--echo #
--echo # TABLE EVENTS_STATEMENTS_SUMMARY_BY_ACCOUNT_BY_EVENT_NAME
--echo #

SET @cmd="DROP TABLE IF EXISTS performance_schema.events_statements_summary_by_account_by_event_name;";

SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

SET @cmd="CREATE TABLE performance_schema.events_statements_summary_by_account_by_event_name("
  "USER CHAR(16) collate utf8_bin default null,"
  "HOST CHAR(60) collate utf8_bin default null,"
  "EVENT_NAME VARCHAR(128) not null,"
  "COUNT_STAR BIGINT unsigned not null,"
  "SUM_TIMER_WAIT BIGINT unsigned not null,"
  "MIN_TIMER_WAIT BIGINT unsigned not null,"
  "AVG_TIMER_WAIT BIGINT unsigned not null,"
  "MAX_TIMER_WAIT BIGINT unsigned not null,"
  "SUM_LOCK_TIME BIGINT unsigned not null,"
  "SUM_ERRORS BIGINT unsigned not null,"
  "SUM_WARNINGS BIGINT unsigned not null,"
  "SUM_ROWS_AFFECTED BIGINT unsigned not null,"
  "SUM_ROWS_SENT BIGINT unsigned not null,"
  "SUM_ROWS_EXAMINED BIGINT unsigned not null,"
  "SUM_CREATED_TMP_DISK_TABLES BIGINT unsigned not null,"
  "SUM_CREATED_TMP_TABLES BIGINT unsigned not null,"
  "SUM_SELECT_FULL_JOIN BIGINT unsigned not null,"
  "SUM_SELECT_FULL_RANGE_JOIN BIGINT unsigned not null,"
  "SUM_SELECT_RANGE BIGINT unsigned not null,"
  "SUM_SELECT_RANGE_CHECK BIGINT unsigned not null,"
  "SUM_SELECT_SCAN BIGINT unsigned not null,"
  "SUM_SORT_MERGE_PASSES BIGINT unsigned not null,"
  "SUM_SORT_RANGE BIGINT unsigned not null,"
  "SUM_SORT_ROWS BIGINT unsigned not null,"
  "SUM_SORT_SCAN BIGINT unsigned not null,"
  "SUM_NO_INDEX_USED BIGINT unsigned not null,"
  "SUM_NO_GOOD_INDEX_USED BIGINT unsigned not null"
  ")ENGINE=PERFORMANCE_SCHEMA;";

SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

--echo #
--echo # TABLE EVENTS_STATEMENTS_SUMMARY_BY_USER_BY_EVENT_NAME
--echo #

SET @cmd="DROP TABLE IF EXISTS performance_schema.events_statements_summary_by_user_by_event_name;";

SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

SET @cmd="CREATE TABLE performance_schema.events_statements_summary_by_user_by_event_name("
  "USER CHAR(16) collate utf8_bin default null,"
  "EVENT_NAME VARCHAR(128) not null,"
  "COUNT_STAR BIGINT unsigned not null,"
  "SUM_TIMER_WAIT BIGINT unsigned not null,"
  "MIN_TIMER_WAIT BIGINT unsigned not null,"
  "AVG_TIMER_WAIT BIGINT unsigned not null,"
  "MAX_TIMER_WAIT BIGINT unsigned not null,"
  "SUM_LOCK_TIME BIGINT unsigned not null,"
  "SUM_ERRORS BIGINT unsigned not null,"
  "SUM_WARNINGS BIGINT unsigned not null,"
  "SUM_ROWS_AFFECTED BIGINT unsigned not null,"
  "SUM_ROWS_SENT BIGINT unsigned not null,"
  "SUM_ROWS_EXAMINED BIGINT unsigned not null,"
  "SUM_CREATED_TMP_DISK_TABLES BIGINT unsigned not null,"
  "SUM_CREATED_TMP_TABLES BIGINT unsigned not null,"
  "SUM_SELECT_FULL_JOIN BIGINT unsigned not null,"
  "SUM_SELECT_FULL_RANGE_JOIN BIGINT unsigned not null,"
  "SUM_SELECT_RANGE BIGINT unsigned not null,"
  "SUM_SELECT_RANGE_CHECK BIGINT unsigned not null,"
  "SUM_SELECT_SCAN BIGINT unsigned not null,"
  "SUM_SORT_MERGE_PASSES BIGINT unsigned not null,"
  "SUM_SORT_RANGE BIGINT unsigned not null,"
  "SUM_SORT_ROWS BIGINT unsigned not null,"
  "SUM_SORT_SCAN BIGINT unsigned not null,"
  "SUM_NO_INDEX_USED BIGINT unsigned not null,"
  "SUM_NO_GOOD_INDEX_USED BIGINT unsigned not null"
  ")ENGINE=PERFORMANCE_SCHEMA;";

SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

--echo #
--echo # TABLE EVENTS_STAGES_SUMMARY_BY_ACCOUNT_BY_EVENT_NAME
--echo #

SET @cmd="DROP TABLE IF EXISTS performance_schema.events_stages_summary_by_account_by_event_name;";

SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

SET @cmd="CREATE TABLE performance_schema.events_stages_summary_by_account_by_event_name("
  "USER CHAR(16) collate utf8_bin default null,"
  "HOST CHAR(60) collate utf8_bin default null,"
  "EVENT_NAME VARCHAR(128) not null,"
  "COUNT_STAR BIGINT unsigned not null,"
  "SUM_TIMER_WAIT BIGINT unsigned not null,"
  "MIN_TIMER_WAIT BIGINT unsigned not null,"
  "AVG_TIMER_WAIT BIGINT unsigned not null,"
  "MAX_TIMER_WAIT BIGINT unsigned not null"
  ")ENGINE=PERFORMANCE_SCHEMA;";

SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

--echo #
--echo # TABLE EVENTS_STAGES_SUMMARY_BY_USER_BY_EVENT_NAME
--echo #

SET @cmd="DROP TABLE IF EXISTS performance_schema.events_stages_summary_by_user_by_event_name;";

SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

SET @cmd="CREATE TABLE performance_schema.events_stages_summary_by_user_by_event_name("
  "USER CHAR(16) collate utf8_bin default null,"
  "EVENT_NAME VARCHAR(128) not null,"
  "COUNT_STAR BIGINT unsigned not null,"
  "SUM_TIMER_WAIT BIGINT unsigned not null,"
  "MIN_TIMER_WAIT BIGINT unsigned not null,"
  "AVG_TIMER_WAIT BIGINT unsigned not null,"
  "MAX_TIMER_WAIT BIGINT unsigned not null"
  ")ENGINE=PERFORMANCE_SCHEMA;";

SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

--echo #
--echo # TABLE THREADS
--echo #

SET @cmd="DROP TABLE IF EXISTS performance_schema.threads;";

SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

SET @cmd="CREATE TABLE performance_schema.threads("
  "THREAD_ID BIGINT unsigned not null,"
  "NAME VARCHAR(128) not null,"
  "TYPE VARCHAR(10) not null,"
  "PROCESSLIST_ID BIGINT unsigned,"
  "PROCESSLIST_USER VARCHAR(16),"
  "PROCESSLIST_HOST VARCHAR(60),"
  "PROCESSLIST_DB VARCHAR(64),"
  "PROCESSLIST_COMMAND VARCHAR(16),"
  "PROCESSLIST_TIME BIGINT,"
  "PROCESSLIST_STATE VARCHAR(64),"
  "PROCESSLIST_INFO LONGTEXT,"
  "PARENT_THREAD_ID BIGINT unsigned,"
  "ROLE VARCHAR(64),"
  "INSTRUMENTED ENUM ('YES', 'NO') not null,"
  "HISTORY ENUM ('YES', 'NO') not null"
  ")ENGINE=PERFORMANCE_SCHEMA;";

SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

--echo #
--echo # TABLE MEMORY_SUMMARY_BY_USER_BY_EVENT_NAME
--echo #

SET @cmd="DROP TABLE IF EXISTS performance_schema.memory_summary_by_user_by_event_name;";

SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;


SET @cmd="CREATE TABLE performance_schema.memory_summary_by_user_by_event_name("
  "USER CHAR(16) collate utf8_bin default null,"
  "EVENT_NAME VARCHAR(128) not null,"
  "COUNT_ALLOC BIGINT unsigned not null,"
  "COUNT_FREE BIGINT unsigned not null,"
  "SUM_NUMBER_OF_BYTES_ALLOC BIGINT unsigned not null,"
  "SUM_NUMBER_OF_BYTES_FREE BIGINT unsigned not null,"
  "LOW_COUNT_USED BIGINT not null,"
  "CURRENT_COUNT_USED BIGINT not null,"
  "HIGH_COUNT_USED BIGINT not null,"
  "LOW_NUMBER_OF_BYTES_USED BIGINT not null,"
  "CURRENT_NUMBER_OF_BYTES_USED BIGINT not null,"
  "HIGH_NUMBER_OF_BYTES_USED BIGINT not null"
  ")ENGINE=PERFORMANCE_SCHEMA;";

SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

--echo #
--echo # TABLE MEMORY_SUMMARY_BY_ACCOUNT_BY_EVENT_NAME
--echo #

SET @cmd="DROP TABLE IF EXISTS performance_schema.memory_summary_by_account_by_event_name;";

SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

SET @cmd="CREATE TABLE performance_schema.memory_summary_by_account_by_event_name("
  "USER CHAR(16) collate utf8_bin default null,"
  "HOST CHAR(60) collate utf8_bin default null,"
  "EVENT_NAME VARCHAR(128) not null,"
  "COUNT_ALLOC BIGINT unsigned not null,"
  "COUNT_FREE BIGINT unsigned not null,"
  "SUM_NUMBER_OF_BYTES_ALLOC BIGINT unsigned not null,"
  "SUM_NUMBER_OF_BYTES_FREE BIGINT unsigned not null,"
  "LOW_COUNT_USED BIGINT not null,"
  "CURRENT_COUNT_USED BIGINT not null,"
  "HIGH_COUNT_USED BIGINT not null,"
  "LOW_NUMBER_OF_BYTES_USED BIGINT not null,"
  "CURRENT_NUMBER_OF_BYTES_USED BIGINT not null,"
  "HIGH_NUMBER_OF_BYTES_USED BIGINT not null"
  ")ENGINE=PERFORMANCE_SCHEMA;";

SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

--echo #
--echo # TABLE EVENTS_TRANSACTIONS_SUMMARY_BY_USER_BY_EVENT_NAME
--echo #

SET @cmd="DROP TABLE IF EXISTS performance_schema.events_transactions_summary_by_user_by_event_name;";

SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

SET @cmd="CREATE TABLE performance_schema.events_transactions_summary_by_user_by_event_name("
  "USER CHAR(16) collate utf8_bin default null,"
  "EVENT_NAME VARCHAR(128) not null,"
  "COUNT_STAR BIGINT unsigned not null,"
  "SUM_TIMER_WAIT BIGINT unsigned not null,"
  "MIN_TIMER_WAIT BIGINT unsigned not null,"
  "AVG_TIMER_WAIT BIGINT unsigned not null,"
  "MAX_TIMER_WAIT BIGINT unsigned not null,"
  "COUNT_READ_WRITE BIGINT unsigned not null,"
  "SUM_TIMER_READ_WRITE BIGINT unsigned not null,"
  "MIN_TIMER_READ_WRITE BIGINT unsigned not null,"
  "AVG_TIMER_READ_WRITE BIGINT unsigned not null,"
  "MAX_TIMER_READ_WRITE BIGINT unsigned not null,"
  "COUNT_READ_ONLY BIGINT unsigned not null,"
  "SUM_TIMER_READ_ONLY BIGINT unsigned not null,"
  "MIN_TIMER_READ_ONLY BIGINT unsigned not null,"
  "AVG_TIMER_READ_ONLY BIGINT unsigned not null,"
  "MAX_TIMER_READ_ONLY BIGINT unsigned not null"
  ")ENGINE=PERFORMANCE_SCHEMA;";

SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

--echo #
--echo # TABLE EVENTS_TRANSACTIONS_SUMMARY_BY_ACCOUNT_BY_EVENT_NAME
--echo #

SET @cmd="DROP TABLE IF EXISTS performance_schema.events_transactions_summary_by_account_by_event_name;";

SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

SET @cmd="CREATE TABLE performance_schema.events_transactions_summary_by_account_by_event_name("
  "USER CHAR(16) collate utf8_bin default null,"
  "HOST CHAR(60) collate utf8_bin default null,"
  "EVENT_NAME VARCHAR(128) not null,"
  "COUNT_STAR BIGINT unsigned not null,"
  "SUM_TIMER_WAIT BIGINT unsigned not null,"
  "MIN_TIMER_WAIT BIGINT unsigned not null,"
  "AVG_TIMER_WAIT BIGINT unsigned not null,"
  "MAX_TIMER_WAIT BIGINT unsigned not null,"
  "COUNT_READ_WRITE BIGINT unsigned not null,"
  "SUM_TIMER_READ_WRITE BIGINT unsigned not null,"
  "MIN_TIMER_READ_WRITE BIGINT unsigned not null,"
  "AVG_TIMER_READ_WRITE BIGINT unsigned not null,"
  "MAX_TIMER_READ_WRITE BIGINT unsigned not null,"
  "COUNT_READ_ONLY BIGINT unsigned not null,"
  "SUM_TIMER_READ_ONLY BIGINT unsigned not null,"
  "MIN_TIMER_READ_ONLY BIGINT unsigned not null,"
  "AVG_TIMER_READ_ONLY BIGINT unsigned not null,"
  "MAX_TIMER_READ_ONLY BIGINT unsigned not null"
  ")ENGINE=PERFORMANCE_SCHEMA;";

SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

--echo #
--echo # Bug #21762656 AFTER RUNNING MYSQL_UPGRADE PROXIES_PRIV USER COLUMNS
--echo # ARE NOT UPDATED TO 32
--echo #

ALTER TABLE mysql.proxies_priv MODIFY User char(16) binary DEFAULT '' NOT NULL;
ALTER TABLE mysql.proxies_priv MODIFY Proxied_user char(16) binary DEFAULT '' NOT NULL;
ALTER TABLE mysql.proxies_priv MODIFY Grantor char(77) DEFAULT '' NOT NULL;

--echo # Tables with user name column downgraded to 5.6, now run mysql_upgrade

--exec $MYSQL_UPGRADE --skip-verbose --force 2>&1

--echo # After downgrading all tables with user columns to 5.6 schema and then
--echo # running mysql_upgrade check if all tables have correct 5.7 structure

SHOW CREATE TABLE performance_schema.users;
SHOW CREATE TABLE performance_schema.accounts;
SHOW CREATE TABLE performance_schema.setup_actors;
SHOW CREATE TABLE performance_schema.events_stages_summary_by_user_by_event_name;
SHOW CREATE TABLE performance_schema.events_waits_summary_by_user_by_event_name;
SHOW CREATE TABLE performance_schema.events_waits_summary_by_account_by_event_name;
SHOW CREATE TABLE performance_schema.events_statements_summary_by_account_by_event_name;
SHOW CREATE TABLE performance_schema.events_statements_summary_by_user_by_event_name;
SHOW CREATE TABLE performance_schema.events_stages_summary_by_account_by_event_name;
SHOW CREATE TABLE performance_schema.events_stages_summary_by_user_by_event_name;
SHOW CREATE TABLE performance_schema.threads;
SHOW CREATE TABLE performance_schema.memory_summary_by_user_by_event_name;
SHOW CREATE TABLE performance_schema.memory_summary_by_account_by_event_name;
SHOW CREATE TABLE performance_schema.events_transactions_summary_by_user_by_event_name;
SHOW CREATE TABLE performance_schema.events_transactions_summary_by_account_by_event_name;

#restore the state of the session user
--disable_query_log ONCE
--eval UPDATE mysql.tables_priv SET timestamp ='$sess_user_account_priv' WHERE USER= 'mysql.session'
--disable_query_log ONCE
--eval UPDATE mysql.user SET password_last_changed= '$date_to_restore' WHERE USER= 'mysql.session'


--echo #
--echo # Bug #20968596: MYSQL_UPGRADE IN 5.7 FAILS ON MYSQL.PROC TABLE, WORKS WHEN RUN AGAIN
--echo #
--echo Abuse mysql.proc
SET @orig_sql_mode= @@sql_mode;
SET sql_mode='';
ALTER TABLE mysql.proc
  MODIFY comment BLOB NOT NULL;
#  MODIFY modified TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL;
SET sql_mode= @orig_sql_mode;
--echo Run mysql_upgrade
--exec $MYSQL_UPGRADE --skip-verbose --force 2>&1

--echo Check mysql.proc structure
SHOW CREATE TABLE mysql.proc;

--echo #
--echo # BUG#26727481: SEGMENTATION FAULT DURING MYSQL_UPGRADE IN 8.0.3
--echo #

let $MYSQLD_DATADIR= `select @@datadir`;
--copy_file std_data/41_decimal.frm $MYSQLD_DATADIR/test/t1.frm
--copy_file std_data/41_decimal.MYD $MYSQLD_DATADIR/test/t1.MYD
--copy_file std_data/41_decimal.MYI $MYSQLD_DATADIR/test/t1.MYI

--echo #mysql_upgrade will not fix pre 5.0 decimal types.
--exec $MYSQL_UPGRADE --skip-verbose --force 2>&1

--echo #re-execute mysql_upgrade to check consistency
--exec $MYSQL_UPGRADE --skip-verbose --force 2>&1

DROP TABLE t1;

--source include/mysql_upgrade_cleanup.inc

--echo
--echo End of tests

Man Man