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

--echo #
--echo # Bug#27014083 - 8.0 CRASH RECOVERY FAILS FOR UPGRADED 5.7 COMPRESSED TABLES WITH SIZE < 96K
--echo #

--echo # Set different paths for --datadir
let $MYSQLD_DATADIR1 = $MYSQL_TMP_DIR/data57;

--copy_file $MYSQLTEST_VARDIR/std_data/data57.zip $MYSQL_TMP_DIR/data57.zip

--echo # Check that the file exists in the working folder.
--file_exists $MYSQL_TMP_DIR/data57.zip

--echo # Extract 5.7 datadir
--exec unzip -qo $MYSQL_TMP_DIR/data57.zip -d $MYSQL_TMP_DIR

--echo # These files are added to test error scenario, delete from for upgrade testing.
--remove_file $MYSQL_TMP_DIR/data57/test/55_temporal.frm
--remove_file $MYSQL_TMP_DIR/data57/test/55_temporal.MYD
--remove_file $MYSQL_TMP_DIR/data57/test/55_temporal.MYI
--echo # Remove myisam partitioned tables. There are used for negative testing.
--remove_files_wildcard $MYSQL_TMP_DIR/data57/partitions *
--rmdir $MYSQL_TMP_DIR/data57/partitions
--force-rmdir $MYSQL_TMP_DIR/data57/mismatch_frms

let $MYSQLD_LOG= $MYSQLTEST_VARDIR/log/innodb_upgrade_compressed.log;

--source include/shutdown_mysqld.inc

--echo # start mysqld on the 5.7 datadir
--replace_result $MYSQLD_DATADIR1 MYSQLD_DATADIR1 $MYSQLD_LOG MYSQLD_LOG
let $restart_parameters = "restart: --loose-skip-log-bin --skip-log-replica-updates --skip-replica-preserve-commit-order --datadir=$MYSQLD_DATADIR1 --log-error=$MYSQLD_LOG --innodb_page_size=16k";
--let $wait_counter= 10000
--source include/start_mysqld.inc

SELECT * FROM test.t_compressed;
SHOW CREATE TABLE test.t_compressed;

--echo # Disable background threads that disturb.

SET GLOBAL innodb_log_checkpoint_now=ON;
SET GLOBAL innodb_page_cleaner_disabled_debug = 1;
SET GLOBAL innodb_dict_stats_disabled_debug = 1;
SET GLOBAL innodb_master_thread_disabled_debug = 1;

INSERT INTO test.t_compressed VALUES (1, 'hello'), (2, 'hi');
INSERT INTO test.t_compressed VALUES (3, 'satya'), (4, 'bodapati');

INSERT INTO test.t_blob VALUES ('hello', 'hi', 'satya', 'bodapati');
INSERT INTO test.t_blob VALUES ('hi', 'hello', 'satya', 'bodapati');

--replace_result $MYSQLD_DATADIR1 MYSQLD_DATADIR1 $MYSQLD_LOG MYSQLD_LOG
--let $wait_counter= 3000
--source include/kill_and_restart_mysqld.inc
SELECT * FROM test.t_compressed;
SELECT * FROM test.t_blob;

let $restart_parameters =;
--echo # Restart the server with default options.
--let $shutdown_server_timeout= 300
--let $wait_counter= 3000
--source include/restart_mysqld.inc
--force-rmdir $MYSQLD_DATADIR1
--remove_file $MYSQL_TMP_DIR/data57.zip

