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

--source include/have_debug.inc
--source include/have_partition.inc
# Don't test this under valgrind, memory leaks will occur
--source include/not_valgrind.inc
# Crash tests don't work with embedded
--source include/not_embedded.inc

--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings

# Partitioning test that require debug features

--echo #
--echo # Bug#13737949: CRASH IN HA_PARTITION::INDEX_INIT
--echo # Bug#18694052: SERVER CRASH IN HA_PARTITION::INIT_RECORD_PRIORITY_QUEUE
--echo #
CREATE TABLE t1 (a INT, b VARCHAR(64), KEY(b,a))
  PARTITION BY HASH (a) PARTITIONS 3;
  INSERT INTO t1 VALUES (1, "1"), (2, "2"), (3, "3"), (4, "Four"), (5, "Five"),
  (6, "Six"), (7, "Seven"), (8, "Eight"), (9, "Nine");
SET SESSION debug="+d,ha_partition_fail_index_init";
--error ER_NO_PARTITION_FOR_GIVEN_VALUE
SELECT * FROM t1 WHERE b = "Seven";
SET SESSION debug="-d,ha_partition_fail_index_init";
SELECT * FROM t1 WHERE b = "Seven";
DROP TABLE t1;


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

--echo #
--echo # WL#4445: EXCHANGE PARTITION WITH TABLE
--echo # Verify ddl_log in case of crashing.
call mtr.add_suppression("Attempting backtrace. You can use the following information to find out");
call mtr.add_suppression('InnoDB: The log sequence numbers [0-9]+ and [0-9]+ in ibdata files do not match the log sequence number [0-9]+ in the ib_logfiles!');

let $create_statement= CREATE TABLE t1 (a INT, b VARCHAR(64)) PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10),
 PARTITION p1 VALUES LESS THAN MAXVALUE);
let $insert_statement= INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"), (21, "Original from partition p1"), (22, "Original from partition p1"), (23, "Original from partition p1"), (24, "Original from partition p1");

let $create_statement2= CREATE TABLE t2 (a INT, b VARCHAR(64));
let $insert_statement2= INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2");
let $crash_statement= ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
--source suite/parts/inc/partition_crash_exchange.inc
let $fail_statement= $crash_statement;
--source suite/parts/inc/partition_fail_exchange.inc
