DROP TABLE IF EXISTS t1;
#
# Bug#13737949: CRASH IN HA_PARTITION::INDEX_INIT
# Bug#18694052: SERVER CRASH IN HA_PARTITION::INIT_RECORD_PRIORITY_QUEUE
#
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";
SELECT * FROM t1 WHERE b = "Seven";
ERROR HY000: Table has no partition for value 0
SET SESSION debug="-d,ha_partition_fail_index_init";
SELECT * FROM t1 WHERE b = "Seven";
a	b
7	Seven
DROP TABLE t1;
#
# WL#4445: EXCHANGE PARTITION WITH TABLE
# 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!');
SET SESSION debug="+d,exchange_partition_abort_1";
CREATE TABLE t2 (a INT, b VARCHAR(64));
INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2");
SHOW CREATE TABLE t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM t2;
a	b
5	Original from table t2
6	Original from table t2
7	Original from table t2
8	Original from table t2
CREATE TABLE t1 (a INT, b VARCHAR(64)) PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10),
PARTITION p1 VALUES LESS THAN MAXVALUE);
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");
# State before crash
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
t1#P#p1.MYI
t1.frm
t1.par
t2.MYD
t2.MYI
t2.frm
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10) ENGINE = MyISAM,
 PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
SELECT * FROM t1;
a	b
1	Original from partition p0
11	Original from partition p1
12	Original from partition p1
13	Original from partition p1
14	Original from partition p1
2	Original from partition p0
21	Original from partition p1
22	Original from partition p1
23	Original from partition p1
24	Original from partition p1
3	Original from partition p0
4	Original from partition p0
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
ERROR HY000: Lost connection to MySQL server during query
# State after crash (before recovery)
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
t1#P#p1.MYI
t1.frm
t1.par
t2.MYD
t2.MYI
t2.frm
# State after crash recovery
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
t1#P#p1.MYI
t1.frm
t1.par
t2.MYD
t2.MYI
t2.frm
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10) ENGINE = MyISAM,
 PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
SELECT * FROM t1;
a	b
1	Original from partition p0
11	Original from partition p1
12	Original from partition p1
13	Original from partition p1
14	Original from partition p1
2	Original from partition p0
21	Original from partition p1
22	Original from partition p1
23	Original from partition p1
24	Original from partition p1
3	Original from partition p0
4	Original from partition p0
DROP TABLE t1;
SHOW CREATE TABLE t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM t2;
a	b
5	Original from table t2
6	Original from table t2
7	Original from table t2
8	Original from table t2
DROP TABLE t2;
SET SESSION debug="-d,exchange_partition_abort_1";
SET SESSION debug="+d,exchange_partition_abort_2";
CREATE TABLE t2 (a INT, b VARCHAR(64));
INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2");
SHOW CREATE TABLE t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM t2;
a	b
5	Original from table t2
6	Original from table t2
7	Original from table t2
8	Original from table t2
CREATE TABLE t1 (a INT, b VARCHAR(64)) PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10),
PARTITION p1 VALUES LESS THAN MAXVALUE);
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");
# State before crash
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
t1#P#p1.MYI
t1.frm
t1.par
t2.MYD
t2.MYI
t2.frm
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10) ENGINE = MyISAM,
 PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
SELECT * FROM t1;
a	b
1	Original from partition p0
11	Original from partition p1
12	Original from partition p1
13	Original from partition p1
14	Original from partition p1
2	Original from partition p0
21	Original from partition p1
22	Original from partition p1
23	Original from partition p1
24	Original from partition p1
3	Original from partition p0
4	Original from partition p0
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
ERROR HY000: Lost connection to MySQL server during query
# State after crash (before recovery)
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
t1#P#p1.MYI
t1.frm
t1.par
t2.MYD
t2.MYI
t2.frm
# State after crash recovery
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
t1#P#p1.MYI
t1.frm
t1.par
t2.MYD
t2.MYI
t2.frm
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10) ENGINE = MyISAM,
 PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
SELECT * FROM t1;
a	b
1	Original from partition p0
11	Original from partition p1
12	Original from partition p1
13	Original from partition p1
14	Original from partition p1
2	Original from partition p0
21	Original from partition p1
22	Original from partition p1
23	Original from partition p1
24	Original from partition p1
3	Original from partition p0
4	Original from partition p0
DROP TABLE t1;
SHOW CREATE TABLE t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM t2;
a	b
5	Original from table t2
6	Original from table t2
7	Original from table t2
8	Original from table t2
DROP TABLE t2;
SET SESSION debug="-d,exchange_partition_abort_2";
SET SESSION debug="+d,exchange_partition_abort_3";
CREATE TABLE t2 (a INT, b VARCHAR(64));
INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2");
SHOW CREATE TABLE t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM t2;
a	b
5	Original from table t2
6	Original from table t2
7	Original from table t2
8	Original from table t2
CREATE TABLE t1 (a INT, b VARCHAR(64)) PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10),
PARTITION p1 VALUES LESS THAN MAXVALUE);
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");
# State before crash
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
t1#P#p1.MYI
t1.frm
t1.par
t2.MYD
t2.MYI
t2.frm
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10) ENGINE = MyISAM,
 PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
SELECT * FROM t1;
a	b
1	Original from partition p0
11	Original from partition p1
12	Original from partition p1
13	Original from partition p1
14	Original from partition p1
2	Original from partition p0
21	Original from partition p1
22	Original from partition p1
23	Original from partition p1
24	Original from partition p1
3	Original from partition p0
4	Original from partition p0
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
ERROR HY000: Lost connection to MySQL server during query
# State after crash (before recovery)
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
t1#P#p1.MYI
t1.frm
t1.par
t2.MYD
t2.MYI
t2.frm
# State after crash recovery
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
t1#P#p1.MYI
t1.frm
t1.par
t2.MYD
t2.MYI
t2.frm
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10) ENGINE = MyISAM,
 PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
SELECT * FROM t1;
a	b
1	Original from partition p0
11	Original from partition p1
12	Original from partition p1
13	Original from partition p1
14	Original from partition p1
2	Original from partition p0
21	Original from partition p1
22	Original from partition p1
23	Original from partition p1
24	Original from partition p1
3	Original from partition p0
4	Original from partition p0
DROP TABLE t1;
SHOW CREATE TABLE t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM t2;
a	b
5	Original from table t2
6	Original from table t2
7	Original from table t2
8	Original from table t2
DROP TABLE t2;
SET SESSION debug="-d,exchange_partition_abort_3";
SET SESSION debug="+d,exchange_partition_abort_4";
CREATE TABLE t2 (a INT, b VARCHAR(64));
INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2");
SHOW CREATE TABLE t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM t2;
a	b
5	Original from table t2
6	Original from table t2
7	Original from table t2
8	Original from table t2
CREATE TABLE t1 (a INT, b VARCHAR(64)) PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10),
PARTITION p1 VALUES LESS THAN MAXVALUE);
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");
# State before crash
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
t1#P#p1.MYI
t1.frm
t1.par
t2.MYD
t2.MYI
t2.frm
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10) ENGINE = MyISAM,
 PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
SELECT * FROM t1;
a	b
1	Original from partition p0
11	Original from partition p1
12	Original from partition p1
13	Original from partition p1
14	Original from partition p1
2	Original from partition p0
21	Original from partition p1
22	Original from partition p1
23	Original from partition p1
24	Original from partition p1
3	Original from partition p0
4	Original from partition p0
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
ERROR HY000: Lost connection to MySQL server during query
# State after crash (before recovery)
#sqlx-nnnn_nnnn.MYD
#sqlx-nnnn_nnnn.MYI
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
t1#P#p1.MYI
t1.frm
t1.par
t2.frm
# State after crash recovery
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
t1#P#p1.MYI
t1.frm
t1.par
t2.MYD
t2.MYI
t2.frm
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10) ENGINE = MyISAM,
 PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
SELECT * FROM t1;
a	b
1	Original from partition p0
11	Original from partition p1
12	Original from partition p1
13	Original from partition p1
14	Original from partition p1
2	Original from partition p0
21	Original from partition p1
22	Original from partition p1
23	Original from partition p1
24	Original from partition p1
3	Original from partition p0
4	Original from partition p0
DROP TABLE t1;
SHOW CREATE TABLE t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM t2;
a	b
5	Original from table t2
6	Original from table t2
7	Original from table t2
8	Original from table t2
DROP TABLE t2;
SET SESSION debug="-d,exchange_partition_abort_4";
SET SESSION debug="+d,exchange_partition_abort_5";
CREATE TABLE t2 (a INT, b VARCHAR(64));
INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2");
SHOW CREATE TABLE t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM t2;
a	b
5	Original from table t2
6	Original from table t2
7	Original from table t2
8	Original from table t2
CREATE TABLE t1 (a INT, b VARCHAR(64)) PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10),
PARTITION p1 VALUES LESS THAN MAXVALUE);
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");
# State before crash
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
t1#P#p1.MYI
t1.frm
t1.par
t2.MYD
t2.MYI
t2.frm
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10) ENGINE = MyISAM,
 PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
SELECT * FROM t1;
a	b
1	Original from partition p0
11	Original from partition p1
12	Original from partition p1
13	Original from partition p1
14	Original from partition p1
2	Original from partition p0
21	Original from partition p1
22	Original from partition p1
23	Original from partition p1
24	Original from partition p1
3	Original from partition p0
4	Original from partition p0
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
ERROR HY000: Lost connection to MySQL server during query
# State after crash (before recovery)
#sqlx-nnnn_nnnn.MYD
#sqlx-nnnn_nnnn.MYI
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
t1#P#p1.MYI
t1.frm
t1.par
t2.frm
# State after crash recovery
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
t1#P#p1.MYI
t1.frm
t1.par
t2.MYD
t2.MYI
t2.frm
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10) ENGINE = MyISAM,
 PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
SELECT * FROM t1;
a	b
1	Original from partition p0
11	Original from partition p1
12	Original from partition p1
13	Original from partition p1
14	Original from partition p1
2	Original from partition p0
21	Original from partition p1
22	Original from partition p1
23	Original from partition p1
24	Original from partition p1
3	Original from partition p0
4	Original from partition p0
DROP TABLE t1;
SHOW CREATE TABLE t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM t2;
a	b
5	Original from table t2
6	Original from table t2
7	Original from table t2
8	Original from table t2
DROP TABLE t2;
SET SESSION debug="-d,exchange_partition_abort_5";
SET SESSION debug="+d,exchange_partition_abort_6";
CREATE TABLE t2 (a INT, b VARCHAR(64));
INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2");
SHOW CREATE TABLE t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM t2;
a	b
5	Original from table t2
6	Original from table t2
7	Original from table t2
8	Original from table t2
CREATE TABLE t1 (a INT, b VARCHAR(64)) PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10),
PARTITION p1 VALUES LESS THAN MAXVALUE);
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");
# State before crash
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
t1#P#p1.MYI
t1.frm
t1.par
t2.MYD
t2.MYI
t2.frm
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10) ENGINE = MyISAM,
 PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
SELECT * FROM t1;
a	b
1	Original from partition p0
11	Original from partition p1
12	Original from partition p1
13	Original from partition p1
14	Original from partition p1
2	Original from partition p0
21	Original from partition p1
22	Original from partition p1
23	Original from partition p1
24	Original from partition p1
3	Original from partition p0
4	Original from partition p0
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
ERROR HY000: Lost connection to MySQL server during query
# State after crash (before recovery)
#sqlx-nnnn_nnnn.MYD
#sqlx-nnnn_nnnn.MYI
t1#P#p1.MYD
t1#P#p1.MYI
t1.frm
t1.par
t2.MYD
t2.MYI
t2.frm
# State after crash recovery
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
t1#P#p1.MYI
t1.frm
t1.par
t2.MYD
t2.MYI
t2.frm
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10) ENGINE = MyISAM,
 PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
SELECT * FROM t1;
a	b
1	Original from partition p0
11	Original from partition p1
12	Original from partition p1
13	Original from partition p1
14	Original from partition p1
2	Original from partition p0
21	Original from partition p1
22	Original from partition p1
23	Original from partition p1
24	Original from partition p1
3	Original from partition p0
4	Original from partition p0
DROP TABLE t1;
SHOW CREATE TABLE t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM t2;
a	b
5	Original from table t2
6	Original from table t2
7	Original from table t2
8	Original from table t2
DROP TABLE t2;
SET SESSION debug="-d,exchange_partition_abort_6";
SET SESSION debug="+d,exchange_partition_abort_7";
CREATE TABLE t2 (a INT, b VARCHAR(64));
INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2");
SHOW CREATE TABLE t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM t2;
a	b
5	Original from table t2
6	Original from table t2
7	Original from table t2
8	Original from table t2
CREATE TABLE t1 (a INT, b VARCHAR(64)) PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10),
PARTITION p1 VALUES LESS THAN MAXVALUE);
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");
# State before crash
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
t1#P#p1.MYI
t1.frm
t1.par
t2.MYD
t2.MYI
t2.frm
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10) ENGINE = MyISAM,
 PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
SELECT * FROM t1;
a	b
1	Original from partition p0
11	Original from partition p1
12	Original from partition p1
13	Original from partition p1
14	Original from partition p1
2	Original from partition p0
21	Original from partition p1
22	Original from partition p1
23	Original from partition p1
24	Original from partition p1
3	Original from partition p0
4	Original from partition p0
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
ERROR HY000: Lost connection to MySQL server during query
# State after crash (before recovery)
#sqlx-nnnn_nnnn.MYD
#sqlx-nnnn_nnnn.MYI
t1#P#p1.MYD
t1#P#p1.MYI
t1.frm
t1.par
t2.MYD
t2.MYI
t2.frm
# State after crash recovery
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
t1#P#p1.MYI
t1.frm
t1.par
t2.MYD
t2.MYI
t2.frm
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10) ENGINE = MyISAM,
 PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
SELECT * FROM t1;
a	b
1	Original from partition p0
11	Original from partition p1
12	Original from partition p1
13	Original from partition p1
14	Original from partition p1
2	Original from partition p0
21	Original from partition p1
22	Original from partition p1
23	Original from partition p1
24	Original from partition p1
3	Original from partition p0
4	Original from partition p0
DROP TABLE t1;
SHOW CREATE TABLE t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM t2;
a	b
5	Original from table t2
6	Original from table t2
7	Original from table t2
8	Original from table t2
DROP TABLE t2;
SET SESSION debug="-d,exchange_partition_abort_7";
SET SESSION debug="+d,exchange_partition_abort_8";
CREATE TABLE t2 (a INT, b VARCHAR(64));
INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2");
SHOW CREATE TABLE t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM t2;
a	b
5	Original from table t2
6	Original from table t2
7	Original from table t2
8	Original from table t2
CREATE TABLE t1 (a INT, b VARCHAR(64)) PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10),
PARTITION p1 VALUES LESS THAN MAXVALUE);
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");
# State before crash
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
t1#P#p1.MYI
t1.frm
t1.par
t2.MYD
t2.MYI
t2.frm
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10) ENGINE = MyISAM,
 PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
SELECT * FROM t1;
a	b
1	Original from partition p0
11	Original from partition p1
12	Original from partition p1
13	Original from partition p1
14	Original from partition p1
2	Original from partition p0
21	Original from partition p1
22	Original from partition p1
23	Original from partition p1
24	Original from partition p1
3	Original from partition p0
4	Original from partition p0
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
ERROR HY000: Lost connection to MySQL server during query
# State after crash (before recovery)
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
t1#P#p1.MYI
t1.frm
t1.par
t2.MYD
t2.MYI
t2.frm
# State after crash recovery
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
t1#P#p1.MYI
t1.frm
t1.par
t2.MYD
t2.MYI
t2.frm
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10) ENGINE = MyISAM,
 PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
SELECT * FROM t1;
a	b
1	Original from partition p0
11	Original from partition p1
12	Original from partition p1
13	Original from partition p1
14	Original from partition p1
2	Original from partition p0
21	Original from partition p1
22	Original from partition p1
23	Original from partition p1
24	Original from partition p1
3	Original from partition p0
4	Original from partition p0
DROP TABLE t1;
SHOW CREATE TABLE t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM t2;
a	b
5	Original from table t2
6	Original from table t2
7	Original from table t2
8	Original from table t2
DROP TABLE t2;
SET SESSION debug="-d,exchange_partition_abort_8";
SET SESSION debug="+d,exchange_partition_abort_9";
CREATE TABLE t2 (a INT, b VARCHAR(64));
INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2");
SHOW CREATE TABLE t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM t2;
a	b
5	Original from table t2
6	Original from table t2
7	Original from table t2
8	Original from table t2
CREATE TABLE t1 (a INT, b VARCHAR(64)) PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10),
PARTITION p1 VALUES LESS THAN MAXVALUE);
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");
# State before crash
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
t1#P#p1.MYI
t1.frm
t1.par
t2.MYD
t2.MYI
t2.frm
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10) ENGINE = MyISAM,
 PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
SELECT * FROM t1;
a	b
1	Original from partition p0
11	Original from partition p1
12	Original from partition p1
13	Original from partition p1
14	Original from partition p1
2	Original from partition p0
21	Original from partition p1
22	Original from partition p1
23	Original from partition p1
24	Original from partition p1
3	Original from partition p0
4	Original from partition p0
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
ERROR HY000: Lost connection to MySQL server during query
# State after crash (before recovery)
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
t1#P#p1.MYI
t1.frm
t1.par
t2.MYD
t2.MYI
t2.frm
# State after crash recovery
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
t1#P#p1.MYI
t1.frm
t1.par
t2.MYD
t2.MYI
t2.frm
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10) ENGINE = MyISAM,
 PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
SELECT * FROM t1;
a	b
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
5	Original from table t2
6	Original from table t2
7	Original from table t2
8	Original from table t2
DROP TABLE t1;
SHOW CREATE TABLE t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM t2;
a	b
1	Original from partition p0
2	Original from partition p0
3	Original from partition p0
4	Original from partition p0
DROP TABLE t2;
SET SESSION debug="-d,exchange_partition_abort_9";
SET SESSION debug="+d,exchange_partition_fail_1";
CREATE TABLE t2 (a INT, b VARCHAR(64));
INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2");
SHOW CREATE TABLE t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM t2;
a	b
5	Original from table t2
6	Original from table t2
7	Original from table t2
8	Original from table t2
CREATE TABLE t1 (a INT, b VARCHAR(64)) PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10),
PARTITION p1 VALUES LESS THAN MAXVALUE);
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");
# State before failure
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
t1#P#p1.MYI
t1.frm
t1.par
t2.MYD
t2.MYI
t2.frm
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10) ENGINE = MyISAM,
 PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
SELECT * FROM t1;
a	b
1	Original from partition p0
11	Original from partition p1
12	Original from partition p1
13	Original from partition p1
14	Original from partition p1
2	Original from partition p0
21	Original from partition p1
22	Original from partition p1
23	Original from partition p1
24	Original from partition p1
3	Original from partition p0
4	Original from partition p0
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
ERROR HY000: Error in DDL log
# State after failure
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
t1#P#p1.MYI
t1.frm
t1.par
t2.MYD
t2.MYI
t2.frm
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10) ENGINE = MyISAM,
 PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
SELECT * FROM t1;
a	b
1	Original from partition p0
11	Original from partition p1
12	Original from partition p1
13	Original from partition p1
14	Original from partition p1
2	Original from partition p0
21	Original from partition p1
22	Original from partition p1
23	Original from partition p1
24	Original from partition p1
3	Original from partition p0
4	Original from partition p0
DROP TABLE t1;
SHOW CREATE TABLE t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM t2;
a	b
5	Original from table t2
6	Original from table t2
7	Original from table t2
8	Original from table t2
DROP TABLE t2;
SET SESSION debug="-d,exchange_partition_fail_1";
SET SESSION debug="+d,exchange_partition_fail_2";
CREATE TABLE t2 (a INT, b VARCHAR(64));
INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2");
SHOW CREATE TABLE t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM t2;
a	b
5	Original from table t2
6	Original from table t2
7	Original from table t2
8	Original from table t2
CREATE TABLE t1 (a INT, b VARCHAR(64)) PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10),
PARTITION p1 VALUES LESS THAN MAXVALUE);
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");
# State before failure
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
t1#P#p1.MYI
t1.frm
t1.par
t2.MYD
t2.MYI
t2.frm
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10) ENGINE = MyISAM,
 PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
SELECT * FROM t1;
a	b
1	Original from partition p0
11	Original from partition p1
12	Original from partition p1
13	Original from partition p1
14	Original from partition p1
2	Original from partition p0
21	Original from partition p1
22	Original from partition p1
23	Original from partition p1
24	Original from partition p1
3	Original from partition p0
4	Original from partition p0
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
ERROR HY000: Error in DDL log
# State after failure
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
t1#P#p1.MYI
t1.frm
t1.par
t2.MYD
t2.MYI
t2.frm
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10) ENGINE = MyISAM,
 PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
SELECT * FROM t1;
a	b
1	Original from partition p0
11	Original from partition p1
12	Original from partition p1
13	Original from partition p1
14	Original from partition p1
2	Original from partition p0
21	Original from partition p1
22	Original from partition p1
23	Original from partition p1
24	Original from partition p1
3	Original from partition p0
4	Original from partition p0
DROP TABLE t1;
SHOW CREATE TABLE t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM t2;
a	b
5	Original from table t2
6	Original from table t2
7	Original from table t2
8	Original from table t2
DROP TABLE t2;
SET SESSION debug="-d,exchange_partition_fail_2";
SET SESSION debug="+d,exchange_partition_fail_3";
CREATE TABLE t2 (a INT, b VARCHAR(64));
INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2");
SHOW CREATE TABLE t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM t2;
a	b
5	Original from table t2
6	Original from table t2
7	Original from table t2
8	Original from table t2
CREATE TABLE t1 (a INT, b VARCHAR(64)) PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10),
PARTITION p1 VALUES LESS THAN MAXVALUE);
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");
# State before failure
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
t1#P#p1.MYI
t1.frm
t1.par
t2.MYD
t2.MYI
t2.frm
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10) ENGINE = MyISAM,
 PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
SELECT * FROM t1;
a	b
1	Original from partition p0
11	Original from partition p1
12	Original from partition p1
13	Original from partition p1
14	Original from partition p1
2	Original from partition p0
21	Original from partition p1
22	Original from partition p1
23	Original from partition p1
24	Original from partition p1
3	Original from partition p0
4	Original from partition p0
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
ERROR HY000: Error on rename of './test/t2' to './test/#sqlx-nnnn_nnnn' (errno: 0 - n/a)
# State after failure
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
t1#P#p1.MYI
t1.frm
t1.par
t2.MYD
t2.MYI
t2.frm
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10) ENGINE = MyISAM,
 PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
SELECT * FROM t1;
a	b
1	Original from partition p0
11	Original from partition p1
12	Original from partition p1
13	Original from partition p1
14	Original from partition p1
2	Original from partition p0
21	Original from partition p1
22	Original from partition p1
23	Original from partition p1
24	Original from partition p1
3	Original from partition p0
4	Original from partition p0
DROP TABLE t1;
SHOW CREATE TABLE t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM t2;
a	b
5	Original from table t2
6	Original from table t2
7	Original from table t2
8	Original from table t2
DROP TABLE t2;
SET SESSION debug="-d,exchange_partition_fail_3";
SET SESSION debug="+d,exchange_partition_fail_4";
CREATE TABLE t2 (a INT, b VARCHAR(64));
INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2");
SHOW CREATE TABLE t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM t2;
a	b
5	Original from table t2
6	Original from table t2
7	Original from table t2
8	Original from table t2
CREATE TABLE t1 (a INT, b VARCHAR(64)) PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10),
PARTITION p1 VALUES LESS THAN MAXVALUE);
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");
# State before failure
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
t1#P#p1.MYI
t1.frm
t1.par
t2.MYD
t2.MYI
t2.frm
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10) ENGINE = MyISAM,
 PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
SELECT * FROM t1;
a	b
1	Original from partition p0
11	Original from partition p1
12	Original from partition p1
13	Original from partition p1
14	Original from partition p1
2	Original from partition p0
21	Original from partition p1
22	Original from partition p1
23	Original from partition p1
24	Original from partition p1
3	Original from partition p0
4	Original from partition p0
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
ERROR HY000: Error in DDL log
# State after failure
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
t1#P#p1.MYI
t1.frm
t1.par
t2.MYD
t2.MYI
t2.frm
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10) ENGINE = MyISAM,
 PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
SELECT * FROM t1;
a	b
1	Original from partition p0
11	Original from partition p1
12	Original from partition p1
13	Original from partition p1
14	Original from partition p1
2	Original from partition p0
21	Original from partition p1
22	Original from partition p1
23	Original from partition p1
24	Original from partition p1
3	Original from partition p0
4	Original from partition p0
DROP TABLE t1;
SHOW CREATE TABLE t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM t2;
a	b
5	Original from table t2
6	Original from table t2
7	Original from table t2
8	Original from table t2
DROP TABLE t2;
SET SESSION debug="-d,exchange_partition_fail_4";
SET SESSION debug="+d,exchange_partition_fail_5";
CREATE TABLE t2 (a INT, b VARCHAR(64));
INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2");
SHOW CREATE TABLE t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM t2;
a	b
5	Original from table t2
6	Original from table t2
7	Original from table t2
8	Original from table t2
CREATE TABLE t1 (a INT, b VARCHAR(64)) PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10),
PARTITION p1 VALUES LESS THAN MAXVALUE);
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");
# State before failure
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
t1#P#p1.MYI
t1.frm
t1.par
t2.MYD
t2.MYI
t2.frm
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10) ENGINE = MyISAM,
 PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
SELECT * FROM t1;
a	b
1	Original from partition p0
11	Original from partition p1
12	Original from partition p1
13	Original from partition p1
14	Original from partition p1
2	Original from partition p0
21	Original from partition p1
22	Original from partition p1
23	Original from partition p1
24	Original from partition p1
3	Original from partition p0
4	Original from partition p0
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
ERROR HY000: Error on rename of './test/t1#P#p0' to './test/t2' (errno: 0 - n/a)
# State after failure
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
t1#P#p1.MYI
t1.frm
t1.par
t2.MYD
t2.MYI
t2.frm
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10) ENGINE = MyISAM,
 PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
SELECT * FROM t1;
a	b
1	Original from partition p0
11	Original from partition p1
12	Original from partition p1
13	Original from partition p1
14	Original from partition p1
2	Original from partition p0
21	Original from partition p1
22	Original from partition p1
23	Original from partition p1
24	Original from partition p1
3	Original from partition p0
4	Original from partition p0
DROP TABLE t1;
SHOW CREATE TABLE t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM t2;
a	b
5	Original from table t2
6	Original from table t2
7	Original from table t2
8	Original from table t2
DROP TABLE t2;
SET SESSION debug="-d,exchange_partition_fail_5";
SET SESSION debug="+d,exchange_partition_fail_6";
CREATE TABLE t2 (a INT, b VARCHAR(64));
INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2");
SHOW CREATE TABLE t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM t2;
a	b
5	Original from table t2
6	Original from table t2
7	Original from table t2
8	Original from table t2
CREATE TABLE t1 (a INT, b VARCHAR(64)) PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10),
PARTITION p1 VALUES LESS THAN MAXVALUE);
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");
# State before failure
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
t1#P#p1.MYI
t1.frm
t1.par
t2.MYD
t2.MYI
t2.frm
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10) ENGINE = MyISAM,
 PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
SELECT * FROM t1;
a	b
1	Original from partition p0
11	Original from partition p1
12	Original from partition p1
13	Original from partition p1
14	Original from partition p1
2	Original from partition p0
21	Original from partition p1
22	Original from partition p1
23	Original from partition p1
24	Original from partition p1
3	Original from partition p0
4	Original from partition p0
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
ERROR HY000: Error in DDL log
# State after failure
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
t1#P#p1.MYI
t1.frm
t1.par
t2.MYD
t2.MYI
t2.frm
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10) ENGINE = MyISAM,
 PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
SELECT * FROM t1;
a	b
1	Original from partition p0
11	Original from partition p1
12	Original from partition p1
13	Original from partition p1
14	Original from partition p1
2	Original from partition p0
21	Original from partition p1
22	Original from partition p1
23	Original from partition p1
24	Original from partition p1
3	Original from partition p0
4	Original from partition p0
DROP TABLE t1;
SHOW CREATE TABLE t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM t2;
a	b
5	Original from table t2
6	Original from table t2
7	Original from table t2
8	Original from table t2
DROP TABLE t2;
SET SESSION debug="-d,exchange_partition_fail_6";
SET SESSION debug="+d,exchange_partition_fail_7";
CREATE TABLE t2 (a INT, b VARCHAR(64));
INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2");
SHOW CREATE TABLE t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM t2;
a	b
5	Original from table t2
6	Original from table t2
7	Original from table t2
8	Original from table t2
CREATE TABLE t1 (a INT, b VARCHAR(64)) PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10),
PARTITION p1 VALUES LESS THAN MAXVALUE);
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");
# State before failure
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
t1#P#p1.MYI
t1.frm
t1.par
t2.MYD
t2.MYI
t2.frm
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10) ENGINE = MyISAM,
 PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
SELECT * FROM t1;
a	b
1	Original from partition p0
11	Original from partition p1
12	Original from partition p1
13	Original from partition p1
14	Original from partition p1
2	Original from partition p0
21	Original from partition p1
22	Original from partition p1
23	Original from partition p1
24	Original from partition p1
3	Original from partition p0
4	Original from partition p0
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
ERROR HY000: Error on rename of './test/#sqlx-nnnn_nnnn' to './test/t1#P#p0' (errno: 0 - n/a)
# State after failure
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
t1#P#p1.MYI
t1.frm
t1.par
t2.MYD
t2.MYI
t2.frm
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10) ENGINE = MyISAM,
 PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
SELECT * FROM t1;
a	b
1	Original from partition p0
11	Original from partition p1
12	Original from partition p1
13	Original from partition p1
14	Original from partition p1
2	Original from partition p0
21	Original from partition p1
22	Original from partition p1
23	Original from partition p1
24	Original from partition p1
3	Original from partition p0
4	Original from partition p0
DROP TABLE t1;
SHOW CREATE TABLE t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM t2;
a	b
5	Original from table t2
6	Original from table t2
7	Original from table t2
8	Original from table t2
DROP TABLE t2;
SET SESSION debug="-d,exchange_partition_fail_7";
SET SESSION debug="+d,exchange_partition_fail_8";
CREATE TABLE t2 (a INT, b VARCHAR(64));
INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2");
SHOW CREATE TABLE t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM t2;
a	b
5	Original from table t2
6	Original from table t2
7	Original from table t2
8	Original from table t2
CREATE TABLE t1 (a INT, b VARCHAR(64)) PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10),
PARTITION p1 VALUES LESS THAN MAXVALUE);
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");
# State before failure
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
t1#P#p1.MYI
t1.frm
t1.par
t2.MYD
t2.MYI
t2.frm
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10) ENGINE = MyISAM,
 PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
SELECT * FROM t1;
a	b
1	Original from partition p0
11	Original from partition p1
12	Original from partition p1
13	Original from partition p1
14	Original from partition p1
2	Original from partition p0
21	Original from partition p1
22	Original from partition p1
23	Original from partition p1
24	Original from partition p1
3	Original from partition p0
4	Original from partition p0
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
ERROR HY000: Error in DDL log
# State after failure
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
t1#P#p1.MYI
t1.frm
t1.par
t2.MYD
t2.MYI
t2.frm
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10) ENGINE = MyISAM,
 PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
SELECT * FROM t1;
a	b
1	Original from partition p0
11	Original from partition p1
12	Original from partition p1
13	Original from partition p1
14	Original from partition p1
2	Original from partition p0
21	Original from partition p1
22	Original from partition p1
23	Original from partition p1
24	Original from partition p1
3	Original from partition p0
4	Original from partition p0
DROP TABLE t1;
SHOW CREATE TABLE t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM t2;
a	b
5	Original from table t2
6	Original from table t2
7	Original from table t2
8	Original from table t2
DROP TABLE t2;
SET SESSION debug="-d,exchange_partition_fail_8";
SET SESSION debug="+d,exchange_partition_fail_9";
CREATE TABLE t2 (a INT, b VARCHAR(64));
INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2");
SHOW CREATE TABLE t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM t2;
a	b
5	Original from table t2
6	Original from table t2
7	Original from table t2
8	Original from table t2
CREATE TABLE t1 (a INT, b VARCHAR(64)) PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10),
PARTITION p1 VALUES LESS THAN MAXVALUE);
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");
# State before failure
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
t1#P#p1.MYI
t1.frm
t1.par
t2.MYD
t2.MYI
t2.frm
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10) ENGINE = MyISAM,
 PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
SELECT * FROM t1;
a	b
1	Original from partition p0
11	Original from partition p1
12	Original from partition p1
13	Original from partition p1
14	Original from partition p1
2	Original from partition p0
21	Original from partition p1
22	Original from partition p1
23	Original from partition p1
24	Original from partition p1
3	Original from partition p0
4	Original from partition p0
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
ERROR HY000: Error in DDL log
# State after failure
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p1.MYD
t1#P#p1.MYI
t1.frm
t1.par
t2.MYD
t2.MYI
t2.frm
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10) ENGINE = MyISAM,
 PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
SELECT * FROM t1;
a	b
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
5	Original from table t2
6	Original from table t2
7	Original from table t2
8	Original from table t2
DROP TABLE t1;
SHOW CREATE TABLE t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `a` int(11) DEFAULT NULL,
  `b` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM t2;
a	b
1	Original from partition p0
2	Original from partition p0
3	Original from partition p0
4	Original from partition p0
DROP TABLE t2;
SET SESSION debug="-d,exchange_partition_fail_9";
