#
# MyISAM keycache coverage tests.
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c1 VARCHAR(5), c2 int) ENGINE=MyISAM;
CREATE INDEX i1 ON t1 (c1, c2);
INSERT INTO t1 VALUES ('A',1);
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
#
# Positive tests.
#
SELECT COUNT(*) FROM t1 FORCE INDEX(i1) WHERE c2 < 5;
COUNT(*)
8
LOAD INDEX INTO CACHE t1;
Table	Op	Msg_type	Msg_text
test.t1	preload_keys	status	OK
UPDATE t1 SET c2=2;
#
# Close table and clear cache.
#
FLUSH TABLE t1;
#
# Inject error key_cache_read_block_error
#
SET debug='+d,key_cache_read_block_error';
SELECT COUNT(*) FROM t1 FORCE INDEX(i1) WHERE c2 < 5;
ERROR HY000: Incorrect key file for table 't1.MYI'; try to repair it
# Reset debug variable to its original value.
FLUSH TABLE t1;
#
# Inject error key_cache_insert_block_error
#
SET debug='+d,key_cache_insert_block_error';
LOAD INDEX INTO CACHE t1;
Table	Op	Msg_type	Msg_text
test.t1	preload_keys	error	Failed to read from index file (errno: 5)
test.t1	preload_keys	status	Operation failed
# Reset debug variable to its original value.
FLUSH TABLE t1;
#
# Inject error key_cache_write_block_error
#
SET debug='+d,key_cache_write_block_error';
UPDATE t1 SET c2=1;
ERROR HY000: Incorrect key file for table 't1.MYI'; try to repair it
# Reset debug variable to its original value.
FLUSH TABLE t1;
#
# Cleanup
#
DROP TABLE t1;
