# ********************************************************************
# wl#13065 : Restrict All InnoDB Tablespaces To Known Directories
# ********************************************************************

--echo # This test upgrades tables from 5.7 to 8.0.x where
--echo # datafiles are not known directories.
--echo # a warning message will be put into the error log

--source include/have_debug.inc
--source include/not_valgrind.inc
--source include/have_case_sensitive_file_system.inc

--disable_query_log
call mtr.add_suppression("The datafile .* for tablespace .* is in an unprotected location. This file cannot be recovered after a crash until this location is added to innodb_directories");
call mtr.add_suppression("Unable to open partition file with new name .*. Please check if innodb_directories is set to include all external file paths");
--enable_query_log

--echo # Stop the running the server
--source include/shutdown_mysqld.inc

--echo ######################################################################
--echo # Unzip a 5.7 datadir with tables where datafiles are at
--echo # unknown directories
--echo # start the server using this directory
--echo ######################################################################

--echo ######################################################################
--echo # Copy and unzip the datadir.
--echo ######################################################################
--copy_file $MYSQLTEST_VARDIR/std_data/data57_unknown_dir.zip $MYSQL_TMP_DIR/data57_unknown_dir.zip
--file_exists $MYSQL_TMP_DIR/data57_unknown_dir.zip
--exec unzip -qo $MYSQL_TMP_DIR/data57_unknown_dir.zip -d $MYSQL_TMP_DIR
let $DATADIR = $MYSQL_TMP_DIR/datadir;

--echo # Restart the server against the unzipped datadir
--replace_result $DATADIR DATADIR
--let $restart_parameters = restart: --datadir=$DATADIR --innodb-page-size=16k
--let $wait_counter=3000
--source include/start_mysqld.inc

--echo # Verify tables after upgrade
USE test;
SHOW CREATE TABLE t1;
SHOW CREATE TABLE t2;
SHOW CREATE TABLE t3;
SELECT * FROM t1;
SELECT * FROM t2;
SELECT * FROM t3;

--echo # Run some DML statements
INSERT INTO t1 VALUES (207, "Tom", "Kim");
DELETE FROM t2 WHERE c1=337;
UPDATE t3 SET purchased='2001-01-31' WHERE id=6;

--echo # Verify results
SELECT * FROM t1;
SELECT * FROM t2;
SELECT * FROM t3;

--echo # Cleanup
--echo # Shutdown server
--source include/shutdown_mysqld.inc

--echo # Remove copied files
--file_exists $MYSQL_TMP_DIR/data57_unknown_dir.zip
--force-rmdir $MYSQL_TMP_DIR/datadir
--force-rmdir $MYSQL_TMP_DIR/unknown
--remove_file $MYSQL_TMP_DIR/data57_unknown_dir.zip

--echo # Resart the server
let $restart_parameters =;
--source include/start_mysqld.inc
