--source include/have_sequence.inc
--source include/test_db_charset_latin1.inc

#
# MDEV-11539 test_if_reopen: Assertion `strcmp(share->unique_file_name,filename) || share->last_version' failed upon select from I_S
#
CREATE TABLE t1 (i INT) ENGINE=Aria TRANSACTIONAL=1;
INSERT t1 VALUES (1);
LOCK TABLE t1 WRITE;
REPAIR TABLE t1;
--disable_result_log
SELECT * FROM INFORMATION_SCHEMA.TABLES;
--enable_result_log
SELECT * FROM t1;
UNLOCK TABLES;
DROP TABLE t1;

CREATE TABLE t1 (i INT) ENGINE=Aria TRANSACTIONAL=1;
INSERT t1 VALUES (1);
LOCK TABLE t1 WRITE;
OPTIMIZE TABLE t1;
--disable_result_log
SELECT * FROM INFORMATION_SCHEMA.TABLES;
--enable_result_log
SELECT * FROM t1;
UNLOCK TABLES;
DROP TABLE t1;

--echo
--echo # MDEV-17223 Assertion `thd->killed != 0' failed in
--echo # ha_maria::enable_indexes
--echo #

CREATE OR REPLACE TABLE t1 (c VARCHAR(1024) NOT NULL) ENGINE=Aria ROW_FORMAT FIXED;
insert into t1 select char(seq) from seq_65_to_256;
insert into t1 values ("a");
--error ER_DUP_ENTRY
ALTER TABLE t1 ADD PRIMARY KEY(c(67));
select count(*) from t1;
drop table t1;

--echo
--echo # MDEV-17223 Assertion `thd->killed != 0' failed in
--echo # ha_maria::enable_indexes
--echo #

SET SESSION aria_sort_buffer_size=1023;
CREATE TABLE t2 (c TEXT,INDEX(c(1000))) ENGINE=Aria;
--disable_warnings
INSERT INTO t2 select char(seq) from seq_65_to_255;
--enable_warnings
SELECT COUNT(*) FROM t2;
DROP TABLE t2;
SET SESSION aria_sort_buffer_size=default;

--echo #
--echo # End of 10.3 tests
--echo #

--echo #
--echo # MDEV-34055 Assertion `readbytes != (size_t)-1 ||
--echo # (*__errno_location ()) != 9' failure or corruption errors upon
--echo # REPAIR on Aria tables
--echo #

CREATE OR REPLACE TABLE t1 (a INT, b INT, UNIQUE(b), UNIQUE(a)) ENGINE=Aria;
INSERT INTO t1 VALUES (1,2);
REPAIR TABLE t1 EXTENDED QUICK USE_FRM;
CREATE TABLE t2 (c INT) ENGINE=Aria;
SELECT * FROM t2;
REPLACE INTO t1 VALUES (1,3);
REPAIR TABLE t2, t1 QUICK;
DROP TABLE t1, t2;

--echo #
--echo # End of 10.5 tests
--echo #

--source include/test_db_charset_restore.inc
