SET DEBUG_SYNC= 'RESET';
USE test;
DROP DATABASE IF EXISTS mysqltest;
CREATE DATABASE mysqltest;
USE mysqltest;
CREATE TABLE t1 (c1 LONGTEXT);

connection backup: Start backup
SET DEBUG_SYNC= 'before_backup_data_prepare SIGNAL bup_sync
                     WAIT_FOR bup_finish';
BACKUP DATABASE mysqltest TO 'bup_myisam_sync.bak';

connection default: Wait for BACKUP to reach its sync point
SET DEBUG_SYNC= 'now WAIT_FOR bup_sync';
Insert data
INSERT INTO t1 VALUES ("text");
UPDATE t1 SET c1=concat(c1,c1);
UPDATE t1 SET c1=concat(c1,c1);
UPDATE t1 SET c1=concat(c1,c1);
UPDATE t1 SET c1=concat(c1,c1);
UPDATE t1 SET c1=concat(c1,c1);
UPDATE t1 SET c1=concat(c1,c1);
UPDATE t1 SET c1=concat(c1,c1);
UPDATE t1 SET c1=concat(c1,c1);
UPDATE t1 SET c1=concat(c1,c1);
UPDATE t1 SET c1=concat(c1,c1);
UPDATE t1 SET c1=concat(c1,c1);
UPDATE t1 SET c1=concat(c1,c1);
UPDATE t1 SET c1=concat(c1,c1);
UPDATE t1 SET c1=concat(c1,c1);
UPDATE t1 SET c1=concat(c1,c1);
UPDATE t1 SET c1=concat(c1,c1);
SELECT LENGTH(c1) FROM t1;
LENGTH(c1)
262144
CHECKSUM TABLE t1;
Table	Checksum
mysqltest.t1	1728069308

# Verify that the MyISAM Key Cache is enabled.
# See Bug#44068 (RESTORE can disable the MyISAM Key Cache).
SELECT SUM(VARIABLE_VALUE) > 0 AS key_cache_is_enabled
FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE
VARIABLE_NAME LIKE 'Key_blocks_%used';
key_cache_is_enabled
1

Signal BACKUP to finish
SET DEBUG_SYNC= 'now SIGNAL bup_finish';

connection backup: Fetch result
backup_id
#
DROP DATABASE mysqltest;
RESTORE FROM 'bup_myisam_sync.bak';
backup_id
#
SELECT LENGTH(c1) FROM t1;
LENGTH(c1)
262144
CHECKSUM TABLE t1;
Table	Checksum
mysqltest.t1	1728069308
CHECK TABLE t1 EXTENDED;
Table	Op	Msg_type	Msg_text
mysqltest.t1	check	status	OK

connection default: cleanup
SET DEBUG_SYNC= 'RESET';

# Verify that the MyISAM Key Cache is still enabled.
# See Bug#44068 (RESTORE can disable the MyISAM Key Cache).
SELECT SUM(VARIABLE_VALUE) > 0 AS key_cache_is_enabled
FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE
VARIABLE_NAME LIKE 'Key_blocks_%used';
key_cache_is_enabled
1

# final cleanup
USE test;
DROP DATABASE mysqltest;
SET DEBUG_SYNC= 'RESET';
