# Partitioning test that require debug features
# including crashing tests.

--source include/have_debug.inc
--source include/have_innodb.inc
--source include/have_partition.inc
--source include/not_valgrind.inc
--source include/not_embedded.inc

--let $DATADIR= `SELECT @@datadir;`

--echo #
--echo # Bug#12696518/Bug#11766879/60106:DIFF BETWEEN # OF INDEXES IN MYSQL
--echo # VS INNODB, PARTITONING, ON INDEX CREATE
--echo #
CREATE TABLE t1
(a INT PRIMARY KEY,
 b VARCHAR(64))
ENGINE = InnoDB
PARTITION BY HASH (a) PARTITIONS 3;
INSERT INTO t1 VALUES (0, 'first row'), (1, 'second row'), (2, 'Third row');
INSERT INTO t1 VALUES (3, 'row id 3'), (4, '4 row'), (5, 'row5');
INSERT INTO t1 VALUES (6, 'X 6 row'), (7, 'Seventh row'), (8, 'Last row');

ALTER TABLE t1 ADD INDEX new_b_index (b);
ALTER TABLE t1 DROP INDEX new_b_index;

SET @save_dbug=@@debug_dbug;
SET SESSION debug_dbug = "+d,ha_partition_fail_final_add_index";

--error ER_NO_PARTITION_FOR_GIVEN_VALUE
ALTER TABLE t1 ADD INDEX (b);
SHOW CREATE TABLE t1;
--sorted_result
SELECT * FROM t1;

FLUSH TABLES;
--error ER_NO_PARTITION_FOR_GIVEN_VALUE
CREATE INDEX new_index ON t1 (b);
SHOW CREATE TABLE t1;
--sorted_result
SELECT * FROM t1;

SET SESSION debug_dbug = @save_dbug;
SHOW CREATE TABLE t1;
DROP TABLE t1;

# Checking with #innodb what this is...
call mtr.add_suppression("InnoDB: Warning: allocated tablespace .*, old maximum was");
# If there is a crash or failure between the ddl_log is written and the
# operation is completed, mysql will try to drop a not yet created partition
call mtr.add_suppression("InnoDB: Error: table .* does not exist in the InnoDB internal");
call mtr.add_suppression("InnoDB: Warning: MySQL is trying to drop table ");


let $engine= 'InnoDB';

--echo # Test crash and failure recovery in fast_alter_partition_table.
--source suite/parts/inc/partition_mgm_crash.inc
