summaryrefslogtreecommitdiff
path: root/mysql-test/suite/parts
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test/suite/parts')
-rw-r--r--mysql-test/suite/parts/disabled.def4
-rw-r--r--mysql-test/suite/parts/inc/part_exch_drop_tabs.inc15
-rw-r--r--mysql-test/suite/parts/inc/part_exch_qa.inc148
-rw-r--r--mysql-test/suite/parts/inc/part_exch_qa_1.inc62
-rw-r--r--mysql-test/suite/parts/inc/part_exch_qa_13.inc202
-rw-r--r--mysql-test/suite/parts/inc/part_exch_qa_4.inc45
-rw-r--r--mysql-test/suite/parts/inc/part_exch_qa_5.inc89
-rw-r--r--mysql-test/suite/parts/inc/part_exch_qa_7.inc63
-rw-r--r--mysql-test/suite/parts/inc/part_exch_qa_8.inc71
-rw-r--r--mysql-test/suite/parts/inc/part_exch_tabs.inc139
-rw-r--r--mysql-test/suite/parts/inc/partition.pre8
-rw-r--r--mysql-test/suite/parts/inc/partition_alter3.inc2
-rw-r--r--mysql-test/suite/parts/inc/partition_binary.inc3
-rw-r--r--mysql-test/suite/parts/inc/partition_char.inc3
-rw-r--r--mysql-test/suite/parts/inc/partition_crash_exchange.inc29
-rw-r--r--mysql-test/suite/parts/inc/partition_crash_t2.inc12
-rw-r--r--mysql-test/suite/parts/inc/partition_enum.inc3
-rw-r--r--mysql-test/suite/parts/inc/partition_exchange.inc361
-rw-r--r--mysql-test/suite/parts/inc/partition_fail_exchange.inc27
-rw-r--r--mysql-test/suite/parts/inc/partition_fail_t2.inc31
-rw-r--r--mysql-test/suite/parts/inc/partition_mgm.inc30
-rw-r--r--mysql-test/suite/parts/inc/partition_varbinary.inc3
-rw-r--r--mysql-test/suite/parts/inc/partition_varchar.inc3
-rw-r--r--mysql-test/suite/parts/r/part_ctype_utf32.result2
-rw-r--r--mysql-test/suite/parts/r/partition_alter1_1_2_innodb.result2
-rw-r--r--mysql-test/suite/parts/r/partition_alter1_1_2_myisam.result2
-rw-r--r--mysql-test/suite/parts/r/partition_alter1_1_innodb.result2
-rw-r--r--mysql-test/suite/parts/r/partition_alter1_1_myisam.result2
-rw-r--r--mysql-test/suite/parts/r/partition_alter1_2_innodb.result2
-rw-r--r--mysql-test/suite/parts/r/partition_alter1_2_myisam.result2
-rw-r--r--mysql-test/suite/parts/r/partition_alter2_1_1_innodb.result2
-rw-r--r--mysql-test/suite/parts/r/partition_alter2_1_2_innodb.result2
-rw-r--r--mysql-test/suite/parts/r/partition_alter2_1_maria.result2
-rw-r--r--mysql-test/suite/parts/r/partition_alter2_1_myisam.result2
-rw-r--r--mysql-test/suite/parts/r/partition_alter2_2_1_innodb.result2
-rw-r--r--mysql-test/suite/parts/r/partition_alter2_2_2_innodb.result2
-rw-r--r--mysql-test/suite/parts/r/partition_alter2_2_maria.result2
-rw-r--r--mysql-test/suite/parts/r/partition_alter2_2_myisam.result2
-rw-r--r--mysql-test/suite/parts/r/partition_alter3_innodb.result98
-rw-r--r--mysql-test/suite/parts/r/partition_alter3_myisam.result4
-rw-r--r--mysql-test/suite/parts/r/partition_alter4_innodb.result2
-rw-r--r--mysql-test/suite/parts/r/partition_alter4_myisam.result2
-rw-r--r--mysql-test/suite/parts/r/partition_basic_innodb.result434
-rw-r--r--mysql-test/suite/parts/r/partition_basic_myisam.result2
-rw-r--r--mysql-test/suite/parts/r/partition_basic_symlink_innodb.result123
-rw-r--r--mysql-test/suite/parts/r/partition_basic_symlink_myisam.result2
-rw-r--r--mysql-test/suite/parts/r/partition_char_innodb.resultbin50278 -> 50278 bytes
-rw-r--r--mysql-test/suite/parts/r/partition_char_myisam.resultbin50278 -> 50278 bytes
-rw-r--r--mysql-test/suite/parts/r/partition_debug.result1948
-rw-r--r--mysql-test/suite/parts/r/partition_debug_innodb.result1918
-rw-r--r--mysql-test/suite/parts/r/partition_debug_myisam.result17
-rw-r--r--mysql-test/suite/parts/r/partition_engine_innodb.result2
-rw-r--r--mysql-test/suite/parts/r/partition_engine_myisam.result2
-rwxr-xr-xmysql-test/suite/parts/r/partition_exch_innodb.result355
-rwxr-xr-xmysql-test/suite/parts/r/partition_exch_myisam.result355
-rwxr-xr-xmysql-test/suite/parts/r/partition_exch_myisam_innodb.result14
-rwxr-xr-xmysql-test/suite/parts/r/partition_exch_qa.result355
-rwxr-xr-xmysql-test/suite/parts/r/partition_exch_qa_10.result70
-rwxr-xr-xmysql-test/suite/parts/r/partition_exch_qa_11.result56
-rw-r--r--mysql-test/suite/parts/r/partition_exch_qa_12.result123
-rw-r--r--mysql-test/suite/parts/r/partition_exch_qa_13.result203
-rwxr-xr-xmysql-test/suite/parts/r/partition_exch_qa_14.result45
-rw-r--r--mysql-test/suite/parts/r/partition_exch_qa_15.result19
-rw-r--r--mysql-test/suite/parts/r/partition_exch_qa_1_innodb.result171
-rw-r--r--mysql-test/suite/parts/r/partition_exch_qa_1_myisam.result171
-rw-r--r--mysql-test/suite/parts/r/partition_exch_qa_2.result138
-rwxr-xr-xmysql-test/suite/parts/r/partition_exch_qa_3.result17
-rwxr-xr-xmysql-test/suite/parts/r/partition_exch_qa_4_innodb.result76
-rwxr-xr-xmysql-test/suite/parts/r/partition_exch_qa_4_myisam.result76
-rwxr-xr-xmysql-test/suite/parts/r/partition_exch_qa_5_innodb.result114
-rwxr-xr-xmysql-test/suite/parts/r/partition_exch_qa_5_myisam.result114
-rwxr-xr-xmysql-test/suite/parts/r/partition_exch_qa_6.result105
-rwxr-xr-xmysql-test/suite/parts/r/partition_exch_qa_7_innodb.result82
-rwxr-xr-xmysql-test/suite/parts/r/partition_exch_qa_7_myisam.result82
-rwxr-xr-xmysql-test/suite/parts/r/partition_exch_qa_8_innodb.result83
-rwxr-xr-xmysql-test/suite/parts/r/partition_exch_qa_8_myisam.result83
-rw-r--r--mysql-test/suite/parts/r/partition_exchange_archive.result322
-rw-r--r--mysql-test/suite/parts/r/partition_exchange_blackhole.result10
-rw-r--r--mysql-test/suite/parts/r/partition_exchange_innodb.result374
-rw-r--r--mysql-test/suite/parts/r/partition_exchange_memory.result374
-rw-r--r--mysql-test/suite/parts/r/partition_exchange_myisam.result374
-rw-r--r--mysql-test/suite/parts/r/partition_mdev6067.result22
-rw-r--r--mysql-test/suite/parts/r/partition_mgm_lc0_archive.result82
-rw-r--r--mysql-test/suite/parts/r/partition_mgm_lc0_innodb.result82
-rw-r--r--mysql-test/suite/parts/r/partition_mgm_lc0_memory.result82
-rw-r--r--mysql-test/suite/parts/r/partition_mgm_lc0_myisam.result82
-rw-r--r--mysql-test/suite/parts/r/partition_mgm_lc1_archive.result82
-rw-r--r--mysql-test/suite/parts/r/partition_mgm_lc1_innodb.result82
-rw-r--r--mysql-test/suite/parts/r/partition_mgm_lc1_memory.result82
-rw-r--r--mysql-test/suite/parts/r/partition_mgm_lc1_myisam.result82
-rw-r--r--mysql-test/suite/parts/r/partition_mgm_lc2_archive.result82
-rw-r--r--mysql-test/suite/parts/r/partition_mgm_lc2_innodb.result90
-rw-r--r--mysql-test/suite/parts/r/partition_mgm_lc2_memory.result90
-rw-r--r--mysql-test/suite/parts/r/partition_mgm_lc2_myisam.result90
-rw-r--r--mysql-test/suite/parts/r/partition_repair_myisam.result85
-rw-r--r--mysql-test/suite/parts/r/partition_syntax_innodb.result2
-rw-r--r--mysql-test/suite/parts/r/partition_syntax_myisam.result2
-rw-r--r--mysql-test/suite/parts/t/partition_alter1_1_innodb.test2
-rw-r--r--mysql-test/suite/parts/t/partition_basic_innodb.test12
-rw-r--r--mysql-test/suite/parts/t/partition_basic_symlink_innodb.test220
-rw-r--r--mysql-test/suite/parts/t/partition_debug.test51
-rw-r--r--mysql-test/suite/parts/t/partition_debug_innodb-master.opt2
-rw-r--r--mysql-test/suite/parts/t/partition_debug_innodb.test31
-rw-r--r--mysql-test/suite/parts/t/partition_exch_innodb.test12
-rw-r--r--mysql-test/suite/parts/t/partition_exch_myisam.test11
-rw-r--r--mysql-test/suite/parts/t/partition_exch_myisam_innodb.test21
-rw-r--r--mysql-test/suite/parts/t/partition_exch_qa.test11
-rw-r--r--mysql-test/suite/parts/t/partition_exch_qa_10.test69
-rw-r--r--mysql-test/suite/parts/t/partition_exch_qa_11.test37
-rw-r--r--mysql-test/suite/parts/t/partition_exch_qa_12.test178
-rw-r--r--mysql-test/suite/parts/t/partition_exch_qa_13.test11
-rw-r--r--mysql-test/suite/parts/t/partition_exch_qa_14.test94
-rw-r--r--mysql-test/suite/parts/t/partition_exch_qa_15.test31
-rw-r--r--mysql-test/suite/parts/t/partition_exch_qa_1_innodb.test12
-rw-r--r--mysql-test/suite/parts/t/partition_exch_qa_1_myisam.test11
-rw-r--r--mysql-test/suite/parts/t/partition_exch_qa_2.test80
-rw-r--r--mysql-test/suite/parts/t/partition_exch_qa_3.test47
-rw-r--r--mysql-test/suite/parts/t/partition_exch_qa_4_innodb.test12
-rw-r--r--mysql-test/suite/parts/t/partition_exch_qa_4_myisam.test11
-rw-r--r--mysql-test/suite/parts/t/partition_exch_qa_5_innodb.test12
-rw-r--r--mysql-test/suite/parts/t/partition_exch_qa_5_myisam.test11
-rw-r--r--mysql-test/suite/parts/t/partition_exch_qa_6.test102
-rw-r--r--mysql-test/suite/parts/t/partition_exch_qa_7_innodb.test12
-rw-r--r--mysql-test/suite/parts/t/partition_exch_qa_7_myisam.test11
-rw-r--r--mysql-test/suite/parts/t/partition_exch_qa_8_innodb.test12
-rw-r--r--mysql-test/suite/parts/t/partition_exch_qa_8_myisam.test11
-rw-r--r--mysql-test/suite/parts/t/partition_exchange_archive.test11
-rw-r--r--mysql-test/suite/parts/t/partition_exchange_blackhole.test18
-rw-r--r--mysql-test/suite/parts/t/partition_exchange_innodb.test6
-rw-r--r--mysql-test/suite/parts/t/partition_exchange_memory.test5
-rw-r--r--mysql-test/suite/parts/t/partition_exchange_myisam.test5
-rw-r--r--mysql-test/suite/parts/t/partition_repair_myisam.test63
132 files changed, 12300 insertions, 362 deletions
diff --git a/mysql-test/suite/parts/disabled.def b/mysql-test/suite/parts/disabled.def
index 96592e78911..abbdbf7f044 100644
--- a/mysql-test/suite/parts/disabled.def
+++ b/mysql-test/suite/parts/disabled.def
@@ -11,3 +11,7 @@
##############################################################################
partition_value_myisam : CAST() in partitioning function is currently not supported
partition_value_innodb : CAST() in partitioning function is currently not supported
+parts.partition_mgm_lc1_archive : MDEV-5077 2013-09-27 svoj Cannot exchange partition with archive table
+parts.partition_exchange_archive: MDEV-5077 2013-09-27 svoj Cannot exchange partition with archive table
+parts.partition_mgm_lc0_archive : MDEV-5077 2013-09-27 svoj Cannot exchange partition with archive table
+parts.partition_mgm_lc2_archive : MDEV-5077 2013-09-27 svoj Cannot exchange partition with archive table
diff --git a/mysql-test/suite/parts/inc/part_exch_drop_tabs.inc b/mysql-test/suite/parts/inc/part_exch_drop_tabs.inc
new file mode 100644
index 00000000000..5ffc5438a3e
--- /dev/null
+++ b/mysql-test/suite/parts/inc/part_exch_drop_tabs.inc
@@ -0,0 +1,15 @@
+--disable_warnings
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
+--enable_warnings
+
diff --git a/mysql-test/suite/parts/inc/part_exch_qa.inc b/mysql-test/suite/parts/inc/part_exch_qa.inc
new file mode 100644
index 00000000000..1f5329a53ab
--- /dev/null
+++ b/mysql-test/suite/parts/inc/part_exch_qa.inc
@@ -0,0 +1,148 @@
+use test;
+
+--disable_result_log
+--disable_query_log
+--source suite/parts/inc/part_exch_tabs.inc
+--enable_result_log
+--enable_query_log
+
+--sorted_result
+SELECT * FROM t_10;
+--sorted_result
+SELECT * FROM t_100;
+--sorted_result
+SELECT * FROM t_1000;
+--sorted_result
+SELECT * FROM tp;
+--sorted_result
+SELECT * FROM tsp;
+--sorted_result
+SELECT * FROM tsp_00;
+--sorted_result
+SELECT * FROM tsp_01;
+--sorted_result
+SELECT * FROM tsp_02;
+--sorted_result
+SELECT * FROM tsp_03;
+--sorted_result
+SELECT * FROM tsp_04;
+
+# 1) Valid exchange with partitions.
+# exchange of values < 10 of tp to t and complete contents of t to p0 and back.
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+--sorted_result
+SELECT * FROM t_10;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+# Back to the former contents.
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+--sorted_result
+SELECT * FROM t_10;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+
+# Exchange with empty table.
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_empty;
+--sorted_result
+SELECT * FROM t_empty;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+# Back to the former contents.
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_empty;
+--sorted_result
+SELECT * FROM t_empty;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+
+# Exchange with null table.
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_null;
+--sorted_result
+SELECT * FROM t_null;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+# Back to the former contents.
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_null;
+--sorted_result
+SELECT * FROM t_null;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+
+# exchange of values < 100 of tp to t and complete contents of t to p1 and back.
+ALTER TABLE tp EXCHANGE PARTITION p1 WITH TABLE t_100;
+--sorted_result
+SELECT * FROM t_100;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 10 AND 100;
+# Back to the former contents.
+ALTER TABLE tp EXCHANGE PARTITION p1 WITH TABLE t_100;
+--sorted_result
+SELECT * FROM t_100;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 10 AND 100;
+
+# exchange of values < 1000 of tp to t and complete contents of t to p2 and back.
+ALTER TABLE tp EXCHANGE PARTITION p2 WITH TABLE t_1000;
+--sorted_result
+SELECT * FROM t_1000;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 100 AND 1000;
+# Back to the former contents.
+ALTER TABLE tp EXCHANGE PARTITION p2 WITH TABLE t_1000;
+--sorted_result
+SELECT * FROM t_1000;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 100 AND 1000;
+
+# 2) Valid exchange of subpartitions.
+# exchange of values < 10 of tsp to t and complete contents of t to p0 and back.
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+ALTER TABLE tsp EXCHANGE PARTITION sp01 WITH TABLE tsp_01;
+ALTER TABLE tsp EXCHANGE PARTITION sp02 WITH TABLE tsp_02;
+ALTER TABLE tsp EXCHANGE PARTITION sp03 WITH TABLE tsp_03;
+ALTER TABLE tsp EXCHANGE PARTITION sp04 WITH TABLE tsp_04;
+--sorted_result
+SELECT * FROM tsp_00;
+--sorted_result
+SELECT * FROM tsp_01;
+--sorted_result
+SELECT * FROM tsp_02;
+--sorted_result
+SELECT * FROM tsp_03;
+--sorted_result
+SELECT * FROM tsp_04;
+--sorted_result
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+# Back to the former contents.
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+ALTER TABLE tsp EXCHANGE PARTITION sp01 WITH TABLE tsp_01;
+ALTER TABLE tsp EXCHANGE PARTITION sp02 WITH TABLE tsp_02;
+ALTER TABLE tsp EXCHANGE PARTITION sp03 WITH TABLE tsp_03;
+ALTER TABLE tsp EXCHANGE PARTITION sp04 WITH TABLE tsp_04;
+--sorted_result
+SELECT * FROM tsp_00;
+--sorted_result
+SELECT * FROM tsp_01;
+--sorted_result
+SELECT * FROM tsp_02;
+--sorted_result
+SELECT * FROM tsp_03;
+--sorted_result
+SELECT * FROM tsp_04;
+--sorted_result
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+
+# Exchange with null table.
+ALTER TABLE tsp EXCHANGE PARTITION sp01 WITH TABLE t_null;
+--sorted_result
+SELECT * FROM t_null;
+--sorted_result
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+# Back to the former contents.
+ALTER TABLE tsp EXCHANGE PARTITION sp01 WITH TABLE t_null;
+--sorted_result
+SELECT * FROM t_null;
+--sorted_result
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+
+--source suite/parts/inc/part_exch_drop_tabs.inc
+
diff --git a/mysql-test/suite/parts/inc/part_exch_qa_1.inc b/mysql-test/suite/parts/inc/part_exch_qa_1.inc
new file mode 100644
index 00000000000..d790f29af6c
--- /dev/null
+++ b/mysql-test/suite/parts/inc/part_exch_qa_1.inc
@@ -0,0 +1,62 @@
+use test;
+
+--disable_result_log
+--disable_query_log
+--source suite/parts/inc/part_exch_tabs.inc
+--enable_result_log
+--enable_query_log
+
+--sorted_result
+SELECT * FROM t_10;
+--sorted_result
+SELECT * FROM t_100;
+--sorted_result
+SELECT * FROM t_1000;
+--sorted_result
+SELECT * FROM tp;
+--sorted_result
+SELECT * FROM tsp;
+--sorted_result
+SELECT * FROM tsp_00;
+--sorted_result
+SELECT * FROM tsp_01;
+--sorted_result
+SELECT * FROM tsp_02;
+--sorted_result
+SELECT * FROM tsp_03;
+--sorted_result
+SELECT * FROM tsp_04;
+
+# 13) Exchanges with indexes.
+# IGNORE was removed in bug#57708.
+CREATE INDEX id_t_10_b USING BTREE ON t_10 (b);
+--error ER_TABLES_DIFFERENT_METADATA
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+#--error ER_TABLES_DIFFERENT_METADATA
+#ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10 IGNORE;
+CREATE INDEX id_tp_b USING BTREE ON tp (b);
+--error ER_TABLES_DIFFERENT_METADATA
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+#--error ER_TABLES_DIFFERENT_METADATA
+#ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10 IGNORE;
+DROP INDEX id_t_10_b ON t_10;
+DROP INDEX id_tp_b ON tp;
+ALTER TABLE t_10 ADD UNIQUE INDEX USING BTREE (a);
+--error ER_TABLES_DIFFERENT_METADATA
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+#--error ER_TABLES_DIFFERENT_METADATA
+#ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10 IGNORE;
+ALTER TABLE tp ADD UNIQUE INDEX USING BTREE (a);
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+show create table t_10;
+show create table tp ;
+ALTER TABLE tp DROP INDEX a;
+ALTER TABLE t_10 DROP INDEX a;
+ALTER TABLE tp ADD UNIQUE INDEX USING BTREE (a,b);
+ALTER TABLE t_10 ADD UNIQUE INDEX USING BTREE (a,b);
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+show create table t_10;
+show create table tp ;
+
+--source suite/parts/inc/part_exch_drop_tabs.inc
+
diff --git a/mysql-test/suite/parts/inc/part_exch_qa_13.inc b/mysql-test/suite/parts/inc/part_exch_qa_13.inc
new file mode 100644
index 00000000000..aba75d22b26
--- /dev/null
+++ b/mysql-test/suite/parts/inc/part_exch_qa_13.inc
@@ -0,0 +1,202 @@
+# Author: Horst Hunger
+# Created: 2010-07-13
+
+use test;
+
+--disable_result_log
+--disable_query_log
+--disable_warnings
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
+--enable_warnings
+
+eval CREATE TABLE t_10 (a INT, b VARCHAR(55), PRIMARY KEY (a))
+CHECKSUM= 1,
+ENGINE = $engine_table;
+
+eval CREATE TABLE t_100 (a INT, b VARCHAR(55), PRIMARY KEY (a))
+COMMENT= 'comment',
+ENGINE = $engine_table;
+
+eval CREATE TABLE t_1000 (a INT, b VARCHAR(55), PRIMARY KEY (a))
+MIN_ROWS= 1,
+MAX_ROWS= 2000,
+ENGINE = $engine_table;
+
+eval CREATE TABLE t_empty (a INT, b VARCHAR(55), PRIMARY KEY (a))
+ENGINE = $engine_table;
+
+eval CREATE TABLE t_null (a INT, b VARCHAR(55), PRIMARY KEY (a))
+ENGINE = $engine_table;
+
+eval CREATE TABLE tp (a INT, b VARCHAR(55), PRIMARY KEY (a))
+CHECKSUM= 1,
+ENGINE = $engine_part
+PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10),
+ PARTITION p1 VALUES LESS THAN (100),
+ PARTITION p2 VALUES LESS THAN (1000));
+
+eval CREATE TABLE tp1 (a INT, b VARCHAR(55), PRIMARY KEY (a))
+ENGINE = $engine_part
+PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10) MAX_ROWS=2000 MIN_ROWS=1,
+ PARTITION p1 VALUES LESS THAN (100) MAX_ROWS=2000 MIN_ROWS=1,
+ PARTITION p2 VALUES LESS THAN (1000) MAX_ROWS=2000 MIN_ROWS=1
+);
+
+eval CREATE TABLE tsp (a INT,
+ b VARCHAR(55),
+ PRIMARY KEY (a))
+COMMENT= 'comment',
+ENGINE = $engine_subpart
+PARTITION BY RANGE (a)
+SUBPARTITION BY HASH(a)
+(PARTITION p0 VALUES LESS THAN (10)
+ (SUBPARTITION sp00 MAX_ROWS=2000 MIN_ROWS=1,
+ SUBPARTITION sp01 MAX_ROWS=2000 MIN_ROWS=1,
+ SUBPARTITION sp02 MAX_ROWS=2000 MIN_ROWS=1,
+ SUBPARTITION sp03 MAX_ROWS=2000 MIN_ROWS=1,
+ SUBPARTITION sp04 MAX_ROWS=2000 MIN_ROWS=1),
+ PARTITION p1 VALUES LESS THAN (100)
+ (SUBPARTITION sp10,
+ SUBPARTITION sp11,
+ SUBPARTITION sp12,
+ SUBPARTITION sp13,
+ SUBPARTITION sp14),
+ PARTITION p2 VALUES LESS THAN (1000)
+ (SUBPARTITION sp20,
+ SUBPARTITION sp21,
+ SUBPARTITION sp22,
+ SUBPARTITION sp23,
+ SUBPARTITION sp24));
+
+# Values t_10 (not partitioned)
+INSERT INTO t_10 VALUES (1, "One"), (3, "Three"), (5, "Five"), (9, "Nine");
+
+# Values t_100 (not partitioned)
+INSERT INTO t_100 VALUES (11, "Eleven"), (13, "Thirdteen"), (15, "Fifeteen"), (19, "Nineteen");
+INSERT INTO t_100 VALUES (91, "Ninety-one"), (93, "Ninety-three"), (95, "Ninety-five"), (99, "Ninety-nine");
+
+# Values t_1000 (not partitioned)
+INSERT INTO t_1000 VALUES (111, "Hundred elven"), (113, "Hundred thirdteen"), (115, "Hundred fiveteen"), (119, "Hundred nineteen");
+INSERT INTO t_1000 VALUES (131, "Hundred thirty-one"), (133, "Hundred thirty-three"), (135, "Hundred thirty-five"), (139, "Hundred thirty-nine");
+INSERT INTO t_1000 VALUES (151, "Hundred fifty-one"), (153, "Hundred fifty-three"), (155, "Hundred fity-five"), (159, "Hundred fifty-nine");
+INSERT INTO t_1000 VALUES (191, "Hundred ninety-one"), (193, "Hundred ninety-three"), (195, "Hundred ninety-five"), (199, "Hundred ninety-nine");
+
+# Values t_null (not partitioned)
+INSERT INTO t_null VALUES (1, "NULL");
+
+# Values tp (partitions)
+INSERT INTO tp VALUES (2, "Two"), (4, "Four"), (6, "Six"), (8, "Eight");
+INSERT INTO tp VALUES (12, "twelve"), (14, "Fourteen"), (16, "Sixteen"), (18, "Eightteen");
+INSERT INTO tp VALUES (112, "Hundred twelve"), (114, "Hundred fourteen"), (116, "Hundred sixteen"), (118, "Hundred eightteen");
+INSERT INTO tp VALUES (122, "Hundred twenty-two"), (124, "Hundred twenty-four"), (126, "Hundred twenty-six"), (128, "Hundred twenty-eight");
+INSERT INTO tp VALUES (162, "Hundred sixty-two"), (164, "Hundred sixty-four"), (166, "Hundred sixty-six"), (168, "Hundred sixty-eight");
+INSERT INTO tp VALUES (182, "Hundred eighty-two"), (184, "Hundred eighty-four"), (186, "Hundred eighty-six"), (188, "Hundred eighty-eight");
+
+# Values tp1 (partitions)
+INSERT INTO tp1 VALUES (2, "Two"), (4, "Four"), (6, "Six"), (8, "Eight");
+INSERT INTO tp1 VALUES (12, "twelve"), (14, "Fourteen"), (16, "Sixteen"), (18, "Eightteen");
+INSERT INTO tp1 VALUES (112, "Hundred twelve"), (114, "Hundred fourteen"), (116, "Hundred sixteen"), (118, "Hundred eightteen");
+INSERT INTO tp1 VALUES (122, "Hundred twenty-two"), (124, "Hundred twenty-four"), (126, "Hundred twenty-six"), (128, "Hundred twenty-eight");
+INSERT INTO tp1 VALUES (162, "Hundred sixty-two"), (164, "Hundred sixty-four"), (166, "Hundred sixty-six"), (168, "Hundred sixty-eight");
+INSERT INTO tp1 VALUES (182, "Hundred eighty-two"), (184, "Hundred eighty-four"), (186, "Hundred eighty-six"), (188, "Hundred eighty-eight");
+
+# Values tps (subpartitions)
+INSERT INTO tsp VALUES (2, "Two"), (4, "Four"), (6, "Six"), (8, "Eight");
+INSERT INTO tsp VALUES (12, "twelve"), (14, "Fourteen"), (16, "Sixteen"), (18, "Eightteen");
+INSERT INTO tsp VALUES (112, "Hundred twelve"), (114, "Hundred fourteen"), (116, "Hundred sixteen"), (118, "Hundred eightteen");
+INSERT INTO tsp VALUES (122, "Hundred twenty-two"), (124, "Hundred twenty-four"), (126, "Hundred twenty-six"), (128, "Hundred twenty-eight");
+INSERT INTO tsp VALUES (162, "Hundred sixty-two"), (164, "Hundred sixty-four"), (166, "Hundred sixty-six"), (168, "Hundred sixty-eight");
+INSERT INTO tsp VALUES (182, "Hundred eight-two"), (184, "Hundred eighty-four"), (186, "Hundred eighty-six"), (188, "Hundred eighty-eight");
+
+eval CREATE TABLE tsp_01(a INT,b VARCHAR(55),PRIMARY KEY (a)) ENGINE = $engine_table
+ AS SELECT a, b FROM t_10 WHERE MOD(a,5)= 1;
+eval CREATE TABLE tsp_02(a INT,b VARCHAR(55),PRIMARY KEY (a)) ENGINE = $engine_table
+ AS SELECT a, b FROM t_10 WHERE MOD(a,5)= 2;
+eval CREATE TABLE tsp_03(a INT,b VARCHAR(55),PRIMARY KEY (a)) ENGINE = $engine_table,
+ MAX_ROWS=2000, MIN_ROWS=1
+ AS SELECT a, b FROM t_10 WHERE MOD(a,5)= 3;
+eval CREATE TABLE tsp_04(a INT,b VARCHAR(55),PRIMARY KEY (a)) ENGINE = $engine_table
+ AS SELECT a, b FROM t_10 WHERE MOD(a,5)= 4;
+eval CREATE TABLE tsp_00(a INT,b VARCHAR(55),PRIMARY KEY (a)) ENGINE = $engine_table
+ AS SELECT a, b FROM t_10 WHERE MOD(a,5)= 0;
+
+SHOW CREATE TABLE t_100;
+SHOW CREATE TABLE t_1000;
+SHOW CREATE TABLE tp;
+SHOW CREATE TABLE tsp;
+
+--enable_result_log
+--enable_query_log
+
+--sorted_result
+SELECT * FROM t_10;
+--sorted_result
+SELECT * FROM t_100;
+--sorted_result
+SELECT * FROM t_1000;
+--sorted_result
+SELECT * FROM tp;
+--sorted_result
+SELECT * FROM tsp;
+--sorted_result
+SELECT * FROM tsp_00;
+--sorted_result
+SELECT * FROM tsp_01;
+--sorted_result
+SELECT * FROM tsp_02;
+--sorted_result
+SELECT * FROM tsp_03;
+--sorted_result
+SELECT * FROM tsp_04;
+
+# 13) Exchanges with different table options.
+# See bug#55944 to change the IGNORE
+# IGNORE was removed in bug#57708.
+INSERT INTO t_10 VALUES (10, "TEN");
+--error ER_ROW_DOES_NOT_MATCH_PARTITION
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+--sorted_result
+SELECT * FROM tp WHERE a < 11;
+--sorted_result
+SELECT * FROM t_10 WHERE a < 11;
+#ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10 IGNORE;
+#--sorted_result
+#SELECT * FROM tp WHERE a < 11;
+#--sorted_result
+#SELECT * FROM t_10 WHERE a < 11;
+INSERT INTO t_1000 VALUES (99, "Ninetynine");
+--error ER_ROW_DOES_NOT_MATCH_PARTITION
+ALTER TABLE tp1 EXCHANGE PARTITION p2 WITH TABLE t_1000;
+--sorted_result
+SELECT * FROM tp1 WHERE a < 1000 AND a > 98;
+--sorted_result
+SELECT * FROM t_1000 WHERE a < 1000 AND a > 98;
+#ALTER TABLE tp1 EXCHANGE PARTITION p2 WITH TABLE t_1000 IGNORE;
+#--sorted_result
+#SELECT * FROM tp1 WHERE a < 1000 AND a > 98;
+#--sorted_result
+#SELECT * FROM t_1000 WHERE a < 1000 AND a > 98;
+INSERT INTO tsp_03 VALUES (20, "Twenty");
+--error ER_ROW_DOES_NOT_MATCH_PARTITION
+ALTER TABLE tsp EXCHANGE PARTITION sp03 WITH TABLE tsp_03;
+--sorted_result
+SELECT * FROM tsp;
+--sorted_result
+SELECT * FROM tsp_03;
+#ALTER TABLE tsp EXCHANGE PARTITION sp03 WITH TABLE tsp_03 IGNORE;
+#--sorted_result
+#SELECT * FROM tsp;
+#--sorted_result
+#SELECT * FROM tsp_03;
+
+DROP TABLE tp1;
+--source suite/parts/inc/part_exch_drop_tabs.inc
+
diff --git a/mysql-test/suite/parts/inc/part_exch_qa_4.inc b/mysql-test/suite/parts/inc/part_exch_qa_4.inc
new file mode 100644
index 00000000000..d1de0298516
--- /dev/null
+++ b/mysql-test/suite/parts/inc/part_exch_qa_4.inc
@@ -0,0 +1,45 @@
+CREATE DATABASE test_2;
+
+USE test;
+--disable_result_log
+--disable_query_log
+--source suite/parts/inc/part_exch_tabs.inc
+
+USE test_2;
+--source suite/parts/inc/part_exch_tabs.inc
+
+--enable_result_log
+--enable_query_log
+
+USE test;
+# 10) Exchanges with different databases.
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE test_2.t_10;
+--sorted_result
+SELECT * FROM test_2.t_10;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+# Back to former values.
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE test_2.t_10;
+--sorted_result
+SELECT * FROM test_2.t_10;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE test_2.tsp_00;
+--sorted_result
+SELECT * FROM test_2.tsp_00;
+--sorted_result
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+# Back to former values.
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE test_2.tsp_00;
+--sorted_result
+SELECT * FROM test_2.tsp_00;
+--sorted_result
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+
+--source suite/parts/inc/part_exch_drop_tabs.inc
+USE test_2;
+--source suite/parts/inc/part_exch_drop_tabs.inc
+USE test;
+
+DROP DATABASE test_2;
+
diff --git a/mysql-test/suite/parts/inc/part_exch_qa_5.inc b/mysql-test/suite/parts/inc/part_exch_qa_5.inc
new file mode 100644
index 00000000000..1ad28df5f8c
--- /dev/null
+++ b/mysql-test/suite/parts/inc/part_exch_qa_5.inc
@@ -0,0 +1,89 @@
+--source include/not_embedded.inc
+
+CREATE USER test1@localhost;
+CREATE USER test2@localhost;
+GRANT USAGE ON *.* TO test1@localhost;
+GRANT USAGE ON *.* TO test2@localhost;
+GRANT CREATE, DROP, INSERT, SELECT ON test.* TO test1@localhost;
+GRANT CREATE, DROP, ALTER, UPDATE, INSERT, SELECT ON test.* TO test2@localhost;
+
+--echo connect (test1,localhost,test1,,test,MASTER_MYPORT,MASTER_MYSOCK);
+connect (test1,localhost,test1,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
+SELECT current_user();
+SHOW GRANTS FOR CURRENT_USER;
+--disable_result_log
+--disable_query_log
+--source suite/parts/inc/part_exch_tabs.inc
+--enable_result_log
+--enable_query_log
+--error ER_TABLEACCESS_DENIED_ERROR
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+--echo disconnect test1;
+disconnect test1;
+
+
+--echo connect (test2,localhost,test2,,test,MASTER_MYPORT,MASTER_MYSOCK);
+connect (test2,localhost,test2,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
+USE test;
+SELECT current_user();
+SHOW GRANTS FOR CURRENT_USER;
+
+# 9) Exchanges with different owner.
+# Privilege for ALTER and SELECT
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+--sorted_result
+SELECT * FROM t_10;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+# Back to former values.
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+--sorted_result
+SELECT * FROM t_10;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+--sorted_result
+SELECT * FROM tsp_00;
+--sorted_result
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+# Back to former values.
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+--sorted_result
+SELECT * FROM tsp_00;
+--sorted_result
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+--echo disconnect test2;
+disconnect test2;
+
+--echo connection default;
+connection default;
+REVOKE ALTER ON test.* FROM test2@localhost;
+
+--echo connect (test2,localhost,test2,,test,MASTER_MYPORT,MASTER_MYSOCK);
+connect (test2,localhost,test2,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
+USE test;
+SELECT current_user();
+SHOW GRANTS FOR CURRENT_USER;
+# Privilege for ALTER and SELECT
+--error ER_TABLEACCESS_DENIED_ERROR
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+# Back to former values.
+--error ER_TABLEACCESS_DENIED_ERROR
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+--error ER_TABLEACCESS_DENIED_ERROR
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+# Back to former values.
+--error ER_TABLEACCESS_DENIED_ERROR
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+
+--echo connection default;
+connection default;
+--echo disconnect test2;
+disconnect test2;
+
+--source suite/parts/inc/part_exch_drop_tabs.inc
+
+DROP USER test1@localhost;
+DROP USER test2@localhost;
+
diff --git a/mysql-test/suite/parts/inc/part_exch_qa_7.inc b/mysql-test/suite/parts/inc/part_exch_qa_7.inc
new file mode 100644
index 00000000000..d8809902d51
--- /dev/null
+++ b/mysql-test/suite/parts/inc/part_exch_qa_7.inc
@@ -0,0 +1,63 @@
+CREATE USER test_2@localhost;
+
+--source include/not_embedded.inc
+--disable_result_log
+--disable_query_log
+--source suite/parts/inc/part_exch_tabs.inc
+--enable_result_log
+--enable_query_log
+
+# 8) Exchanges partition and table and back in 2 sessions with an insert.
+# Parallel INSERT and SELECT
+# LOCK behaviour when exchanging different partitons.
+--echo send
+--send
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+
+--echo connect (test_2,localhost,test_2,,test,MASTER_MYPORT,MASTER_MYSOCK);
+connect (test_2,localhost,test_2,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
+# Wait until exchange has been done.
+let $wait_condition= SELECT count(a)>0 FROM tp WHERE a=1;
+--source include/wait_condition.inc
+# Expect 1,3,5,9 in tp and 2,4,6,8 in t_10
+--sorted_result
+SELECT * FROM t_10;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+# Exchange back.
+INSERT INTO tp VALUES (7,"Seven");
+# Expect 2,4,6,8 in tp
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+
+--echo connection default;
+connection default;
+--echo reap;
+reap;
+--sorted_result
+SELECT * FROM t_10;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+
+--echo connection test_2;
+connection test_2;
+let $wait_condition= SELECT count(a)>0 FROM tp WHERE a=2;
+--source include/wait_condition.inc
+--sorted_result
+SELECT * FROM t_10;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+--echo disconnect test_2;
+disconnect test_2;
+
+--echo connection default;
+connection default;
+--sorted_result
+SELECT * FROM t_10;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+--source suite/parts/inc/part_exch_drop_tabs.inc
+
+DROP USER test_2@localhost;
+
diff --git a/mysql-test/suite/parts/inc/part_exch_qa_8.inc b/mysql-test/suite/parts/inc/part_exch_qa_8.inc
new file mode 100644
index 00000000000..af0b5a9c6cd
--- /dev/null
+++ b/mysql-test/suite/parts/inc/part_exch_qa_8.inc
@@ -0,0 +1,71 @@
+CREATE USER test2@localhost;
+
+--source include/not_embedded.inc
+--disable_result_log
+--disable_query_log
+--source suite/parts/inc/part_exch_tabs.inc
+--enable_result_log
+--enable_query_log
+
+CREATE DATABASE testdb;
+USE testdb;
+--disable_result_log
+--disable_query_log
+--source suite/parts/inc/part_exch_tabs.inc
+--enable_result_log
+--enable_query_log
+
+USE test;
+GRANT CREATE, ALTER, DROP, INSERT, SELECT on test.* TO test2@localhost;
+GRANT CREATE, ALTER, DROP, INSERT, SELECT on testdb.* TO test2@localhost;
+
+# 8) Exchanges partition and table and back in 2 sessions with 2 databases.
+--echo connect (test2,localhost,test2,,test,MASTER_MYPORT,MASTER_MYSOCK);
+connect (test2,localhost,test2,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
+# Privileges on both DB's
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE testdb.t_10;
+--sorted_result
+SELECT * FROM testdb.t_10;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+# Exchange back.
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE testdb.t_10;
+--sorted_result
+SELECT * FROM testdb.t_10;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+
+ALTER TABLE testdb.tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+--sorted_result
+SELECT * FROM t_10;
+--sorted_result
+SELECT * FROM testdb.tp WHERE a BETWEEN 0 AND 10;
+# Exchange back.
+ALTER TABLE testdb.tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+--sorted_result
+SELECT * FROM t_10;
+--sorted_result
+SELECT * FROM testdb.tp WHERE a BETWEEN 0 AND 10;
+--echo disconnect test2;
+disconnect test2;
+
+--echo connection default;
+connection default;
+REVOKE INSERT ON testdb.* FROM test2@localhost;
+
+--echo connect (test2,localhost,test2,,test,MASTER_MYPORT,MASTER_MYSOCK);
+connect (test2,localhost,test2,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
+--error ER_TABLEACCESS_DENIED_ERROR
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE testdb.t_10;
+--error ER_TABLEACCESS_DENIED_ERROR
+ALTER TABLE testdb.tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+--echo disconnect test2;
+disconnect test2;
+
+--echo connection default;
+connection default;
+--source suite/parts/inc/part_exch_drop_tabs.inc
+
+DROP USER test2@localhost;
+DROP DATABASE testdb;
+
diff --git a/mysql-test/suite/parts/inc/part_exch_tabs.inc b/mysql-test/suite/parts/inc/part_exch_tabs.inc
new file mode 100644
index 00000000000..378e0c2278d
--- /dev/null
+++ b/mysql-test/suite/parts/inc/part_exch_tabs.inc
@@ -0,0 +1,139 @@
+--disable_warnings
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
+--enable_warnings
+
+eval CREATE TABLE t_10 (a INT,
+ b VARCHAR(55),
+ PRIMARY KEY (a)) $data_directory $index_directory
+ENGINE = $engine_table;
+
+eval CREATE TABLE t_100 (a INT,
+ b VARCHAR(55),
+ PRIMARY KEY (a)) $data_directory $index_directory
+ENGINE = $engine_table;
+
+eval CREATE TABLE t_1000 (a INT,
+ b VARCHAR(55),
+ PRIMARY KEY (a)) $data_directory $index_directory
+ENGINE = $engine_table;
+
+eval CREATE TABLE t_empty (a INT,
+ b VARCHAR(55),
+ PRIMARY KEY (a)) $data_directory $index_directory
+ENGINE = $engine_table;
+
+eval CREATE TABLE t_null (a INT,
+ b VARCHAR(55),
+ PRIMARY KEY (a)) $data_directory $index_directory
+ENGINE = $engine_table;
+
+eval CREATE TABLE tp (a INT,
+ b VARCHAR(55),
+ PRIMARY KEY (a)) $data_directory $index_directory
+ENGINE = $engine_part
+PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10) $p_data_directory $p_index_directory,
+ PARTITION p1 VALUES LESS THAN (100) $p_data_directory $p_index_directory,
+ PARTITION p2 VALUES LESS THAN (1000) $p_data_directory $p_index_directory);
+
+eval CREATE TABLE tsp (a INT,
+ b VARCHAR(55),
+ PRIMARY KEY (a)) $data_directory $index_directory
+ENGINE = $engine_subpart
+PARTITION BY RANGE (a)
+SUBPARTITION BY HASH(a)
+(PARTITION p0 VALUES LESS THAN (10) $p_data_directory $p_index_directory
+ (SUBPARTITION sp00,
+ SUBPARTITION sp01,
+ SUBPARTITION sp02,
+ SUBPARTITION sp03,
+ SUBPARTITION sp04),
+ PARTITION p1 VALUES LESS THAN (100)
+ (SUBPARTITION sp10 $p_data_directory $p_index_directory,
+ SUBPARTITION sp11 $p_data_directory $p_index_directory,
+ SUBPARTITION sp12 $p_data_directory $p_index_directory,
+ SUBPARTITION sp13 $p_data_directory $p_index_directory,
+ SUBPARTITION sp14 $p_data_directory $p_index_directory),
+ PARTITION p2 VALUES LESS THAN (1000) $p_data_directory $p_index_directory
+ (SUBPARTITION sp20,
+ SUBPARTITION sp21,
+ SUBPARTITION sp22,
+ SUBPARTITION sp23,
+ SUBPARTITION sp24));
+
+# Values t_10 (not partitioned)
+INSERT INTO t_10 VALUES (1, "One"), (3, "Three"), (5, "Five"), (9, "Nine");
+
+# Values t_100 (not partitioned)
+INSERT INTO t_100 VALUES (11, "Eleven"), (13, "Thirdteen"), (15, "Fifeteen"), (19, "Nineteen");
+INSERT INTO t_100 VALUES (91, "Ninety-one"), (93, "Ninety-three"), (95, "Ninety-five"), (99, "Ninety-nine");
+
+# Values t_1000 (not partitioned)
+INSERT INTO t_1000 VALUES (111, "Hundred elven"), (113, "Hundred thirdteen"), (115, "Hundred fiveteen"), (119, "Hundred nineteen");
+INSERT INTO t_1000 VALUES (131, "Hundred thirty-one"), (133, "Hundred thirty-three"), (135, "Hundred thirty-five"), (139, "Hundred thirty-nine");
+INSERT INTO t_1000 VALUES (151, "Hundred fifty-one"), (153, "Hundred fifty-three"), (155, "Hundred fity-five"), (159, "Hundred fifty-nine");
+INSERT INTO t_1000 VALUES (191, "Hundred ninety-one"), (193, "Hundred ninety-three"), (195, "Hundred ninety-five"), (199, "Hundred ninety-nine");
+
+# Values t_null (not partitioned)
+INSERT INTO t_null VALUES (1, "NULL");
+
+# Values tp (partitions)
+INSERT INTO tp VALUES (2, "Two"), (4, "Four"), (6, "Six"), (8, "Eight");
+INSERT INTO tp VALUES (12, "twelve"), (14, "Fourteen"), (16, "Sixteen"), (18, "Eightteen");
+INSERT INTO tp VALUES (112, "Hundred twelve"), (114, "Hundred fourteen"), (116, "Hundred sixteen"), (118, "Hundred eightteen");
+INSERT INTO tp VALUES (122, "Hundred twenty-two"), (124, "Hundred twenty-four"), (126, "Hundred twenty-six"), (128, "Hundred twenty-eight");
+INSERT INTO tp VALUES (162, "Hundred sixty-two"), (164, "Hundred sixty-four"), (166, "Hundred sixty-six"), (168, "Hundred sixty-eight");
+INSERT INTO tp VALUES (182, "Hundred eighty-two"), (184, "Hundred eighty-four"), (186, "Hundred eighty-six"), (188, "Hundred eighty-eight");
+
+# Values tps (subpartitions)
+INSERT INTO tsp VALUES (2, "Two"), (4, "Four"), (6, "Six"), (8, "Eight");
+INSERT INTO tsp VALUES (12, "twelve"), (14, "Fourteen"), (16, "Sixteen"), (18, "Eightteen");
+INSERT INTO tsp VALUES (112, "Hundred twelve"), (114, "Hundred fourteen"), (116, "Hundred sixteen"), (118, "Hundred eightteen");
+INSERT INTO tsp VALUES (122, "Hundred twenty-two"), (124, "Hundred twenty-four"), (126, "Hundred twenty-six"), (128, "Hundred twenty-eight");
+INSERT INTO tsp VALUES (162, "Hundred sixty-two"), (164, "Hundred sixty-four"), (166, "Hundred sixty-six"), (168, "Hundred sixty-eight");
+INSERT INTO tsp VALUES (182, "Hundred eight-two"), (184, "Hundred eighty-four"), (186, "Hundred eighty-six"), (188, "Hundred eighty-eight");
+
+eval CREATE TABLE tsp_01(a INT,b VARCHAR(55),PRIMARY KEY (a))
+ ENGINE = $engine_table $data_directory $index_directory
+ AS SELECT a, b FROM t_10 WHERE MOD(a,5)= 1;
+eval CREATE TABLE tsp_02(a INT,b VARCHAR(55),PRIMARY KEY (a))
+ ENGINE = $engine_table $data_directory $index_directory
+ AS SELECT a, b FROM t_10 WHERE MOD(a,5)= 2;
+eval CREATE TABLE tsp_03(a INT,b VARCHAR(55),PRIMARY KEY (a))
+ ENGINE = $engine_table $data_directory $index_directory
+ AS SELECT a, b FROM t_10 WHERE MOD(a,5)= 3;
+eval CREATE TABLE tsp_04(a INT,b VARCHAR(55),PRIMARY KEY (a))
+ ENGINE = $engine_table $data_directory $index_directory
+ AS SELECT a, b FROM t_10 WHERE MOD(a,5)= 4;
+eval CREATE TABLE tsp_00(a INT,b VARCHAR(55),PRIMARY KEY (a))
+ ENGINE = $engine_table $data_directory $index_directory
+ AS SELECT a, b FROM t_10 WHERE MOD(a,5)= 0;
+
+SHOW CREATE TABLE t_10;
+SHOW CREATE TABLE t_100;
+SHOW CREATE TABLE t_1000;
+SHOW CREATE TABLE tp;
+SHOW CREATE TABLE tsp;
+
+--sorted_result
+SELECT * FROM t_10;
+--sorted_result
+SELECT * FROM t_100;
+--sorted_result
+SELECT * FROM t_1000;
+--sorted_result
+SELECT * FROM tp;
+--sorted_result
+SELECT * FROM tp WHERE a< 10;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 11 AND 100;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 101 AND 200;
+--sorted_result
+SELECT * FROM tsp;
diff --git a/mysql-test/suite/parts/inc/partition.pre b/mysql-test/suite/parts/inc/partition.pre
index f9b361c787c..f82916ae631 100644
--- a/mysql-test/suite/parts/inc/partition.pre
+++ b/mysql-test/suite/parts/inc/partition.pre
@@ -23,13 +23,13 @@
################################################################################
# Set the session storage engine
-eval SET @@session.storage_engine = $engine;
+eval SET @@session.default_storage_engine = $engine;
##### Disabled/affected testcases, because of open bugs #####
# --echo
# --echo #------------------------------------------------------------------------
# --echo # There are several testcases disabled because of the open bugs
-# if (`SELECT @@session.storage_engine IN('ndbcluster')`)
+# if (`SELECT @@session.default_storage_engine IN('ndbcluster')`)
# {
# --echo # #18730
# }
@@ -135,7 +135,7 @@ f_charbig VARCHAR(1000);
# in partition_methods[1|2].inc and partition_alter_1[1|3].inc
# when $sub_part_no is set to >= 3.
let $sub_part_no= 3;
-if (`SELECT @@session.storage_engine = 'ndbcluster'`)
+if (`SELECT @@session.default_storage_engine = 'ndbcluster'`)
{
let $sub_part_no= 2;
}
@@ -318,7 +318,7 @@ if (0)
# --source inc/have_partition.inc
# b) Engine specific settings and requirements
# $do_pk_tests, $MAX_VALUE, $engine
-# SET SESSION storage_engine
+# SET SESSION default_storage_engine
# $engine_other
# c) Generate the prerequisites ($variables, @variables, tables) needed
# via
diff --git a/mysql-test/suite/parts/inc/partition_alter3.inc b/mysql-test/suite/parts/inc/partition_alter3.inc
index 1fad361b371..395f93f44f6 100644
--- a/mysql-test/suite/parts/inc/partition_alter3.inc
+++ b/mysql-test/suite/parts/inc/partition_alter3.inc
@@ -115,6 +115,7 @@ ALTER TABLE t1 REMOVE PARTITIONING;
--source suite/parts/inc/partition_check_read1.inc
#
--echo # 1.2.7 Remove partitioning from not partitioned table --> ????
+--error ER_PARTITION_MGMT_ON_NONPARTITIONED
ALTER TABLE t1 REMOVE PARTITIONING;
DROP TABLE t1;
--source suite/parts/inc/partition_check_drop.inc
@@ -193,6 +194,7 @@ ALTER TABLE t1 REMOVE PARTITIONING;
--source suite/parts/inc/partition_check_read2.inc
#
--echo # 2.2.7 Remove partitioning from not partitioned table --> ????
+--error ER_PARTITION_MGMT_ON_NONPARTITIONED
ALTER TABLE t1 REMOVE PARTITIONING;
DROP TABLE t1;
--source suite/parts/inc/partition_check_drop.inc
diff --git a/mysql-test/suite/parts/inc/partition_binary.inc b/mysql-test/suite/parts/inc/partition_binary.inc
index 08db71b6483..21e9635c036 100644
--- a/mysql-test/suite/parts/inc/partition_binary.inc
+++ b/mysql-test/suite/parts/inc/partition_binary.inc
@@ -8,11 +8,13 @@ partition pa3 max_rows=30 min_rows=4,
partition pa4 max_rows=40 min_rows=2);
show create table t1;
insert into t1 values (repeat('a',255)), ('b'), (repeat('a',128)), (repeat('b',64));
+--sorted_result
select hex(a) from t1;
select a from t1 where substr(a,1,2)='b\0';
update t1 set a='cc' where substr(a,1,2)= 'b\0';
select a from t1 where substr(a,1,1)='c';
delete from t1 where substr(a,1,2)='cc';
+--sorted_result
select hex(a) from t1;
drop table t1;
@@ -33,6 +35,7 @@ inc $letter;
commit;
--enable_query_log
select count(*) from t2;
+--sorted_result
select hex(a) from t2;
drop table t2;
diff --git a/mysql-test/suite/parts/inc/partition_char.inc b/mysql-test/suite/parts/inc/partition_char.inc
index 0fa28370c83..d28ed3158c5 100644
--- a/mysql-test/suite/parts/inc/partition_char.inc
+++ b/mysql-test/suite/parts/inc/partition_char.inc
@@ -8,10 +8,12 @@ partition pa3 max_rows=30 min_rows=4,
partition pa4 max_rows=40 min_rows=2);
show create table t1;
insert into t1 values (repeat('a',255)), ('b'), (repeat('a',128)), (repeat('b',64));
+--sorted_result
select * from t1;
select * from t1 where a='b';
update t1 set a='bb' where a='b';
delete from t1 where a='bb';
+--sorted_result
select * from t1;
drop table t1;
@@ -32,6 +34,7 @@ inc $letter;
commit;
--enable_query_log
select count(*) from t2;
+--sorted_result
select * from t2;
drop table t2;
diff --git a/mysql-test/suite/parts/inc/partition_crash_exchange.inc b/mysql-test/suite/parts/inc/partition_crash_exchange.inc
new file mode 100644
index 00000000000..399cff8f376
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_crash_exchange.inc
@@ -0,0 +1,29 @@
+# To be used with WL#4445: EXCHANGE PARTITION WITH TABLE.
+SET SESSION debug_dbug="+d,exchange_partition_abort_1";
+--source suite/parts/inc/partition_crash_t2.inc
+SET SESSION debug_dbug="-d,exchange_partition_abort_1";
+SET SESSION debug_dbug="+d,exchange_partition_abort_2";
+--source suite/parts/inc/partition_crash_t2.inc
+SET SESSION debug_dbug="-d,exchange_partition_abort_2";
+SET SESSION debug_dbug="+d,exchange_partition_abort_3";
+--source suite/parts/inc/partition_crash_t2.inc
+SET SESSION debug_dbug="-d,exchange_partition_abort_3";
+SET SESSION debug_dbug="+d,exchange_partition_abort_4";
+--source suite/parts/inc/partition_crash_t2.inc
+SET SESSION debug_dbug="-d,exchange_partition_abort_4";
+SET SESSION debug_dbug="+d,exchange_partition_abort_5";
+--source suite/parts/inc/partition_crash_t2.inc
+SET SESSION debug_dbug="-d,exchange_partition_abort_5";
+SET SESSION debug_dbug="+d,exchange_partition_abort_6";
+--source suite/parts/inc/partition_crash_t2.inc
+SET SESSION debug_dbug="-d,exchange_partition_abort_6";
+SET SESSION debug_dbug="+d,exchange_partition_abort_7";
+--source suite/parts/inc/partition_crash_t2.inc
+SET SESSION debug_dbug="-d,exchange_partition_abort_7";
+SET SESSION debug_dbug="+d,exchange_partition_abort_8";
+--source suite/parts/inc/partition_crash_t2.inc
+SET SESSION debug_dbug="-d,exchange_partition_abort_8";
+SET SESSION debug_dbug="+d,exchange_partition_abort_9";
+--source suite/parts/inc/partition_crash_t2.inc
+SET SESSION debug_dbug="-d,exchange_partition_abort_9";
+
diff --git a/mysql-test/suite/parts/inc/partition_crash_t2.inc b/mysql-test/suite/parts/inc/partition_crash_t2.inc
new file mode 100644
index 00000000000..fd88cc60a8d
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_crash_t2.inc
@@ -0,0 +1,12 @@
+# Include file to extend partition_crash with a second table.
+# To be used with WL#4445: EXCHANGE PARTITION WITH TABLE.
+--eval $create_statement2
+--eval $insert_statement2
+SHOW CREATE TABLE t2;
+--sorted_result
+SELECT * FROM t2;
+--source suite/parts/inc/partition_crash.inc
+SHOW CREATE TABLE t2;
+--sorted_result
+SELECT * FROM t2;
+DROP TABLE t2;
diff --git a/mysql-test/suite/parts/inc/partition_enum.inc b/mysql-test/suite/parts/inc/partition_enum.inc
index a545d7fd8c7..87e88983055 100644
--- a/mysql-test/suite/parts/inc/partition_enum.inc
+++ b/mysql-test/suite/parts/inc/partition_enum.inc
@@ -8,11 +8,13 @@ partition pa3 max_rows=30 min_rows=4,
partition pa4 max_rows=40 min_rows=2);
show create table t1;
insert into t1 values ('A'),('D'),('L'),('G');
+--sorted_result
select * from t1;
select * from t1 where a='A';
update t1 set a='E' where a='L';
select * from t1;
delete from t1 where a='E';
+--sorted_result
select * from t1;
drop table t1;
@@ -37,6 +39,7 @@ commit;
--enable_query_log
insert into t2 values ('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9'),('0');
select count(*) from t2;
+--sorted_result
select * from t2;
drop table t2;
diff --git a/mysql-test/suite/parts/inc/partition_exchange.inc b/mysql-test/suite/parts/inc/partition_exchange.inc
new file mode 100644
index 00000000000..f5ecddd13a4
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_exchange.inc
@@ -0,0 +1,361 @@
+# Include file to test PARTITION EXCHANGE usable with different engines
+# Written by Mattias.Jonsson@Sun.Com
+
+--echo # Test with AUTO_INCREMENT
+eval CREATE TABLE tp
+(a INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ b varchar(24))
+ENGINE = $engine
+PARTITION BY HASH (a) PARTITIONS 4;
+CREATE TABLE t LIKE tp;
+ALTER TABLE t REMOVE PARTITIONING;
+SHOW CREATE TABLE tp;
+SHOW CREATE TABLE t;
+INSERT INTO tp (b) VALUES ("One"), ("Two"), ("Three"), ("Four"), ("Five"),
+("Six"), ("Seven"), ("Eight"), ("Nine"), ("Ten"), ("Eleven"), ("Twelwe");
+if ($no_update)
+{
+# Archive handles auto inc by only allowing increasing values,
+# so this must be inserted before a higher value is inserted.
+INSERT INTO tp VALUES (41, "One hundred one");
+}
+INSERT INTO tp VALUES (97, "Ninety seven");
+if (!$no_delete)
+{
+INSERT INTO tp VALUES (111, "One hundred eleven");
+}
+if (!$no_update)
+{
+INSERT INTO tp VALUES (101, "One hundred one");
+}
+SET INSERT_ID = 13;
+INSERT INTO t (b) VALUES ("Thirteen");
+if ($no_update)
+{
+SET INSERT_ID = 17;
+INSERT INTO t (b) VALUES ("Twenty five");
+}
+SET INSERT_ID = 21;
+INSERT INTO t (b) VALUES ("Twenty one");
+if (!$no_update)
+{
+SET INSERT_ID = 25;
+INSERT INTO t (b) VALUES ("Twenty five");
+}
+if (!$no_delete)
+{
+SET INSERT_ID = 55;
+INSERT INTO t (b) VALUES ("Fifty five");
+DELETE FROM tp WHERE a = 111;
+DELETE FROM t WHERE a = 55;
+}
+if (!$no_update)
+{
+UPDATE tp SET a = 41 WHERE a = 101;
+UPDATE t SET a = 17 WHERE a = 25;
+}
+-- disable_query_log
+-- disable_result_log
+ANALYZE TABLE tp;
+-- enable_result_log
+-- enable_query_log
+SELECT PARTITION_NAME, IF(TABLE_ROWS, 'YES', 'NO') AS HAVE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA ='test' AND TABLE_NAME = 'tp';
+SELECT IF(TABLE_ROWS, 'YES', 'NO') AS HAVE_ROWS FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA ='test' AND TABLE_NAME = 't';
+ALTER TABLE tp EXCHANGE PARTITION p1 WITH TABLE t;
+-- disable_query_log
+-- disable_result_log
+ANALYZE TABLE tp;
+-- enable_result_log
+-- enable_query_log
+SELECT PARTITION_NAME, IF(TABLE_ROWS, 'YES', 'NO') AS HAVE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA ='test' AND TABLE_NAME = 'tp';
+SELECT IF(TABLE_ROWS, 'YES', 'NO') AS HAVE_ROWS FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA ='test' AND TABLE_NAME = 't';
+SELECT * FROM tp ORDER BY a;
+SELECT * FROM t ORDER BY a;
+SHOW CREATE TABLE tp;
+SHOW CREATE TABLE t;
+DROP TABLE tp, t;
+
+# set a DEBUG_SYNC after open table and before verifying is done
+# Test that one can read from the table but not write, test that one can both
+# read and write to the partition
+# Verify that one must close the other instances of the table before the rename
+# takes place (i.e. no need for LOCK_open)
+# Test that it is not possible to drop, create, truncate either the tables or
+# partition
+# Test that it waits for ongoing transactions
+
+if ($no_keys)
+{
+eval CREATE TABLE t
+(a INT,
+ b VARCHAR(55))
+ENGINE = $engine;
+eval CREATE TABLE tp
+(a INT,
+ b VARCHAR(55))
+ENGINE = $engine
+PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (100),
+ PARTITION p1 VALUES LESS THAN MAXVALUE);
+eval CREATE TABLE tsp
+(a INT,
+ b VARCHAR(55))
+ENGINE = $engine
+PARTITION BY RANGE (a)
+SUBPARTITION BY HASH(a)
+(PARTITION p0 VALUES LESS THAN (100)
+ (SUBPARTITION sp0,
+ SUBPARTITION sp1),
+ PARTITION p1 VALUES LESS THAN MAXVALUE
+ (SUBPARTITION sp2,
+ SUBPARTITION sp3));
+}
+if (!$no_keys)
+{
+eval CREATE TABLE t
+(a INT,
+ b VARCHAR(55),
+ PRIMARY KEY (a))
+ENGINE = $engine;
+eval CREATE TABLE tp
+(a INT,
+ b VARCHAR(55),
+ PRIMARY KEY (a))
+ENGINE = $engine
+PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (100),
+ PARTITION p1 VALUES LESS THAN MAXVALUE);
+eval CREATE TABLE tsp
+(a INT,
+ b VARCHAR(55),
+ PRIMARY KEY (a))
+ENGINE = $engine
+PARTITION BY RANGE (a)
+SUBPARTITION BY HASH(a)
+(PARTITION p0 VALUES LESS THAN (100)
+ (SUBPARTITION sp0,
+ SUBPARTITION sp1),
+ PARTITION p1 VALUES LESS THAN MAXVALUE
+ (SUBPARTITION sp2,
+ SUBPARTITION sp3));
+}
+
+INSERT INTO t VALUES (1, "First value"), (3, "Three"), (5, "Five"), (99, "End of values");
+INSERT INTO tp VALUES (2, "First value"), (10, "Ten"), (50, "Fifty"), (200, "Two hundred, end of values"), (61, "Sixty one"), (62, "Sixty two"), (63, "Sixty three"), (64, "Sixty four"), (161, "161"), (162, "162"), (163, "163"), (164, "164");
+INSERT INTO tsp VALUES (2, "First value"), (10, "Ten"), (50, "Fifty"), (200, "Two hundred, end of values"), (61, "Sixty one"), (62, "Sixty two"), (63, "Sixty three"), (64, "Sixty four"), (161, "161"), (162, "162"), (163, "163"), (164, "164");
+--sorted_result
+SELECT * FROM t;
+--sorted_result
+SELECT * FROM tp;
+
+--echo # Start by testing read/write locking
+SET AUTOCOMMIT = 1;
+
+connect(con1, localhost, root,,);
+--echo # con1
+SET DEBUG_SYNC= 'swap_partition_after_compare_tables SIGNAL swap_in_progress WAIT_FOR goto_verification';
+SET DEBUG_SYNC= 'swap_partition_first_row_read SIGNAL swap_in_progress WAIT_FOR goto_wait';
+SET DEBUG_SYNC= 'swap_partition_after_wait SIGNAL swap_in_progress WAIT_FOR goto_rename';
+SET DEBUG_SYNC= 'swap_partition_before_rename SIGNAL swap_in_progress WAIT_FOR test_done';
+send ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t;
+
+connection default;
+--echo # con default
+SET DEBUG_SYNC= 'now WAIT_FOR swap_in_progress';
+--echo # select from t and select/update/delete/insert from tp should work
+SELECT * FROM t WHERE a = 99;
+SELECT * FROM tp WHERE a = 61;
+--echo # any write (update/delete/insert) into t or tp should fail
+SET SESSION lock_wait_timeout=1;
+if (!$no_update)
+{
+--error ER_LOCK_WAIT_TIMEOUT
+UPDATE tp SET a = 53, b = concat("Fifty three, was ", b) WHERE a = 63;
+}
+--error ER_LOCK_WAIT_TIMEOUT
+INSERT INTO tp VALUES (63, "Sixty three, new"), (59, "To be deleted");
+if (!$no_delete)
+{
+--error ER_LOCK_WAIT_TIMEOUT
+DELETE FROM tp WHERE a = 59;
+}
+if (!$no_update)
+{
+--error ER_LOCK_WAIT_TIMEOUT
+UPDATE t SET a = 53, b = "Fifty three, was three" WHERE a = 3;
+}
+--error ER_LOCK_WAIT_TIMEOUT
+INSERT INTO t VALUES (63, "Sixty three, new"), (59, "To be deleted");
+if (!$no_delete)
+{
+--error ER_LOCK_WAIT_TIMEOUT
+DELETE FROM t WHERE a = 3;
+}
+--error ER_LOCK_WAIT_TIMEOUT
+eval ALTER TABLE t ENGINE = $engine;
+--error ER_LOCK_WAIT_TIMEOUT
+eval ALTER TABLE tp ENGINE = $engine;
+SHOW CREATE TABLE t;
+SHOW CREATE TABLE tp;
+SET DEBUG_SYNC= 'now SIGNAL goto_verification';
+SET DEBUG_SYNC= 'now WAIT_FOR swap_in_progress';
+--echo # select from t and select/update/delete/insert from tp should work
+SELECT * FROM t WHERE a = 99;
+SELECT * FROM tp WHERE a = 61;
+if (!$no_update)
+{
+--error ER_LOCK_WAIT_TIMEOUT
+UPDATE tp SET a = 43, b = concat("Fifty three, was ", b) WHERE a = 63;
+}
+--error ER_LOCK_WAIT_TIMEOUT
+INSERT INTO tp VALUES (63, "Sixty three, new 2"), (59, "To be deleted");
+if (!$no_delete)
+{
+--error ER_LOCK_WAIT_TIMEOUT
+DELETE FROM tp WHERE a = 59;
+}
+--echo # any write (update/delete/insert) into t should fail
+if (!$no_update)
+{
+--error ER_LOCK_WAIT_TIMEOUT
+UPDATE t SET a = 53, b = "Fifty three, was three" WHERE a = 3;
+}
+--error ER_LOCK_WAIT_TIMEOUT
+INSERT INTO t VALUES (63, "Sixty three, new"), (59, "To be deleted");
+if (!$no_delete)
+{
+--error ER_LOCK_WAIT_TIMEOUT
+DELETE FROM t WHERE a = 3;
+}
+--error ER_LOCK_WAIT_TIMEOUT
+eval ALTER TABLE t ENGINE = $engine;
+--error ER_LOCK_WAIT_TIMEOUT
+eval ALTER TABLE tp ENGINE = $engine;
+SHOW CREATE TABLE t;
+SHOW CREATE TABLE tp;
+SET DEBUG_SYNC= 'now SIGNAL goto_wait';
+SET DEBUG_SYNC= 'now WAIT_FOR swap_in_progress';
+--echo # Both tables should now be under exclusive lock, even SHOW should fail
+--error ER_LOCK_WAIT_TIMEOUT
+SELECT * FROM t WHERE a = 99;
+--error ER_LOCK_WAIT_TIMEOUT
+SELECT * FROM tp WHERE a = 61;
+if (!$no_update)
+{
+--error ER_LOCK_WAIT_TIMEOUT
+UPDATE tp SET a = 53, b = concat("Fifty three, was ", b) WHERE a = 63;
+}
+--error ER_LOCK_WAIT_TIMEOUT
+INSERT INTO tp VALUES (63, "Sixty three, new 2"), (59, "To be deleted");
+if (!$no_delete)
+{
+--error ER_LOCK_WAIT_TIMEOUT
+DELETE FROM tp WHERE a = 59;
+}
+if (!$no_update)
+{
+--error ER_LOCK_WAIT_TIMEOUT
+UPDATE t SET a = 53, b = "Fifty three, was three" WHERE a = 3;
+}
+--error ER_LOCK_WAIT_TIMEOUT
+INSERT INTO t VALUES (63, "Sixty three, new"), (59, "To be deleted");
+if (!$no_delete)
+{
+--error ER_LOCK_WAIT_TIMEOUT
+DELETE FROM t WHERE a = 3;
+}
+--error ER_LOCK_WAIT_TIMEOUT
+SHOW CREATE TABLE t;
+--error ER_LOCK_WAIT_TIMEOUT
+SHOW CREATE TABLE tp;
+--error ER_LOCK_WAIT_TIMEOUT
+eval ALTER TABLE t ENGINE = $engine;
+--error ER_LOCK_WAIT_TIMEOUT
+eval ALTER TABLE tp ENGINE = $engine;
+SET DEBUG_SYNC= 'now SIGNAL goto_rename';
+SET DEBUG_SYNC= 'now WAIT_FOR swap_in_progress';
+--echo # Both tables should now be under exclusive lock
+--error ER_LOCK_WAIT_TIMEOUT
+SELECT * FROM t WHERE a = 99;
+--error ER_LOCK_WAIT_TIMEOUT
+SELECT * FROM tp WHERE a = 61;
+if (!$no_update)
+{
+--error ER_LOCK_WAIT_TIMEOUT
+UPDATE tp SET a = 53, b = concat("Fifty three, was ", b) WHERE a = 63;
+}
+--error ER_LOCK_WAIT_TIMEOUT
+INSERT INTO tp VALUES (63, "Sixty three, new 2"), (59, "To be deleted");
+if (!$no_delete)
+{
+--error ER_LOCK_WAIT_TIMEOUT
+DELETE FROM tp WHERE a = 59;
+}
+if (!$no_update)
+{
+--error ER_LOCK_WAIT_TIMEOUT
+UPDATE t SET a = 53, b = "Fifty three, was three" WHERE a = 3;
+}
+--error ER_LOCK_WAIT_TIMEOUT
+INSERT INTO t VALUES (63, "Sixty three, new"), (59, "To be deleted");
+if (!$no_delete)
+{
+--error ER_LOCK_WAIT_TIMEOUT
+DELETE FROM t WHERE a = 3;
+}
+--error ER_LOCK_WAIT_TIMEOUT
+eval ALTER TABLE t ENGINE = $engine;
+--error ER_LOCK_WAIT_TIMEOUT
+eval ALTER TABLE tp ENGINE = $engine;
+--error ER_LOCK_WAIT_TIMEOUT
+SHOW CREATE TABLE t;
+--error ER_LOCK_WAIT_TIMEOUT
+SHOW CREATE TABLE tp;
+
+SET DEBUG_SYNC= 'now SIGNAL test_done';
+
+connection con1;
+--echo # con1
+--reap
+connection default;
+--echo # con default
+--echo # Tables should now be as normal
+SHOW CREATE TABLE t;
+SHOW CREATE TABLE tp;
+SELECT * FROM tp WHERE a = 99;
+SELECT * FROM t WHERE a = 61;
+if (!$no_update)
+{
+UPDATE t SET a = 53, b = "Fifty three, was sixty three" WHERE a = 63;
+}
+INSERT INTO t VALUES (63, "Sixty three, new"), (59, "To be deleted");
+if (!$no_delete)
+{
+DELETE FROM t WHERE a = 59;
+}
+if (!$no_update)
+{
+UPDATE tp SET a = 53, b = "Fifty three, was three" WHERE a = 3;
+}
+INSERT INTO tp VALUES (63, "Sixty three, new"), (59, "To be deleted");
+if (!$no_delete)
+{
+DELETE FROM tp WHERE a = 3;
+}
+eval ALTER TABLE t ENGINE = $engine;
+eval ALTER TABLE tp ENGINE = $engine;
+
+disconnect con1;
+connection default;
+--echo # con default
+SET DEBUG_SYNC= 'RESET';
+SHOW CREATE TABLE t;
+SHOW CREATE TABLE tp;
+--sorted_result
+SELECT * FROM t;
+--sorted_result
+SELECT * FROM tp;
+
+DROP TABLE t, tp, tsp;
+
+
diff --git a/mysql-test/suite/parts/inc/partition_fail_exchange.inc b/mysql-test/suite/parts/inc/partition_fail_exchange.inc
new file mode 100644
index 00000000000..cc8d76bedfe
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_fail_exchange.inc
@@ -0,0 +1,27 @@
+SET SESSION debug_dbug="+d,exchange_partition_fail_1";
+--source suite/parts/inc/partition_fail_t2.inc
+SET SESSION debug_dbug="-d,exchange_partition_fail_1";
+SET SESSION debug_dbug="+d,exchange_partition_fail_2";
+--source suite/parts/inc/partition_fail_t2.inc
+SET SESSION debug_dbug="-d,exchange_partition_fail_2";
+SET SESSION debug_dbug="+d,exchange_partition_fail_3";
+--source suite/parts/inc/partition_fail_t2.inc
+SET SESSION debug_dbug="-d,exchange_partition_fail_3";
+SET SESSION debug_dbug="+d,exchange_partition_fail_4";
+--source suite/parts/inc/partition_fail_t2.inc
+SET SESSION debug_dbug="-d,exchange_partition_fail_4";
+SET SESSION debug_dbug="+d,exchange_partition_fail_5";
+--source suite/parts/inc/partition_fail_t2.inc
+SET SESSION debug_dbug="-d,exchange_partition_fail_5";
+SET SESSION debug_dbug="+d,exchange_partition_fail_6";
+--source suite/parts/inc/partition_fail_t2.inc
+SET SESSION debug_dbug="-d,exchange_partition_fail_6";
+SET SESSION debug_dbug="+d,exchange_partition_fail_7";
+--source suite/parts/inc/partition_fail_t2.inc
+SET SESSION debug_dbug="-d,exchange_partition_fail_7";
+SET SESSION debug_dbug="+d,exchange_partition_fail_8";
+--source suite/parts/inc/partition_fail_t2.inc
+SET SESSION debug_dbug="-d,exchange_partition_fail_8";
+SET SESSION debug_dbug="+d,exchange_partition_fail_9";
+--source suite/parts/inc/partition_fail_t2.inc
+SET SESSION debug_dbug="-d,exchange_partition_fail_9";
diff --git a/mysql-test/suite/parts/inc/partition_fail_t2.inc b/mysql-test/suite/parts/inc/partition_fail_t2.inc
new file mode 100644
index 00000000000..3904ec8662c
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_fail_t2.inc
@@ -0,0 +1,31 @@
+# Include file to to test failure with error injection.
+# To be used with WL#4445: EXCHANGE PARTITION WITH TABLE.
+--eval $create_statement2
+--eval $insert_statement2
+SHOW CREATE TABLE t2;
+--sorted_result
+SELECT * FROM t2;
+--eval $create_statement
+--eval $insert_statement
+--echo # State before failure
+--replace_result #p# #P#
+--list_files $DATADIR/test
+SHOW CREATE TABLE t1;
+--sorted_result
+SELECT * FROM t1;
+# accept all errors
+--disable_abort_on_error
+--replace_regex /#sqlx-[0-9a-f_]*/#sqlx-nnnn_nnnn/i
+--eval $fail_statement
+--enable_abort_on_error
+--echo # State after failure
+--replace_result #p# #P#
+--list_files $DATADIR/test
+SHOW CREATE TABLE t1;
+--sorted_result
+SELECT * FROM t1;
+DROP TABLE t1;
+SHOW CREATE TABLE t2;
+--sorted_result
+SELECT * FROM t2;
+DROP TABLE t2;
diff --git a/mysql-test/suite/parts/inc/partition_mgm.inc b/mysql-test/suite/parts/inc/partition_mgm.inc
index 67d1feb8046..75834228d7a 100644
--- a/mysql-test/suite/parts/inc/partition_mgm.inc
+++ b/mysql-test/suite/parts/inc/partition_mgm.inc
@@ -57,6 +57,36 @@ ALTER TABLE TableA COALESCE PARTITION 4;
SELECT * FROM TableA;
SHOW CREATE TABLE TableA;
+-- disable_query_log
+-- disable_result_log
+ANALYZE TABLE TableA;
+-- enable_result_log
+-- enable_query_log
+
+--echo # Test of EXCHANGE PARTITION WITH TABLE
+if (!$native_partitioning)
+{
+SELECT PARTITION_NAME, TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA ='MySQL_Test_DB' AND TABLE_NAME = 'TableA';
+CREATE TABLE TableB LIKE TableA;
+ALTER TABLE TableB REMOVE PARTITIONING;
+ALTER TABLE TableA EXCHANGE PARTITION parta WITH TABLE TableB;
+--sorted_result
+SELECT * FROM TableA;
+SHOW CREATE TABLE TableA;
+--sorted_result
+SELECT * FROM TableB;
+SHOW CREATE TABLE TableB;
+SELECT PARTITION_NAME, IF(TABLE_ROWS, 'YES', 'NO') AS HAVE_TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA ='MySQL_Test_DB' AND TABLE_NAME = 'TableA';
+ALTER TABLE TableA EXCHANGE PARTITION parta WITH TABLE TableB;
+INSERT INTO TableB VALUES (11);
+--error ER_ROW_DOES_NOT_MATCH_PARTITION
+ALTER TABLE TableA EXCHANGE PARTITION Partc WITH TABLE TableB;
+DROP TABLE TableB;
+--sorted_result
+SELECT * FROM TableA;
+SHOW CREATE TABLE TableA;
+}
+
--echo # Test of REORGANIZE PARTITIONS
--echo # Should not work on HASH/KEY
--error ER_REORG_HASH_ONLY_ON_SAME_NO
diff --git a/mysql-test/suite/parts/inc/partition_varbinary.inc b/mysql-test/suite/parts/inc/partition_varbinary.inc
index 04ba66d87ea..292407cd525 100644
--- a/mysql-test/suite/parts/inc/partition_varbinary.inc
+++ b/mysql-test/suite/parts/inc/partition_varbinary.inc
@@ -8,10 +8,12 @@ partition pa3 max_rows=30 min_rows=4,
partition pa4 max_rows=40 min_rows=2);
show create table t1;
insert into t1 values (repeat('a',767)), ('b'), (repeat('a',500)), (repeat('b',64));
+--sorted_result
select * from t1;
select * from t1 where a='b';
update t1 set a='bb' where a='b';
delete from t1 where a='bb';
+--sorted_result
select * from t1;
drop table t1;
@@ -32,6 +34,7 @@ inc $letter;
commit;
--enable_query_log
select count(*) from t2;
+--sorted_result
select * from t2;
drop table t2;
diff --git a/mysql-test/suite/parts/inc/partition_varchar.inc b/mysql-test/suite/parts/inc/partition_varchar.inc
index 33c61034a52..257c122ddf2 100644
--- a/mysql-test/suite/parts/inc/partition_varchar.inc
+++ b/mysql-test/suite/parts/inc/partition_varchar.inc
@@ -8,10 +8,12 @@ partition pa3 max_rows=30 min_rows=4,
partition pa4 max_rows=40 min_rows=2);
show create table t1;
insert into t1 values (repeat('a',767)), ('b'), (repeat('a',500)), (repeat('b',64));
+--sorted_result
select * from t1;
select * from t1 where a='b';
update t1 set a='bb' where a='b';
delete from t1 where a='bb';
+--sorted_result
select * from t1;
drop table t1;
@@ -32,6 +34,7 @@ inc $letter;
commit;
--enable_query_log
select count(*) from t2;
+--sorted_result
select * from t2;
drop table t2;
diff --git a/mysql-test/suite/parts/r/part_ctype_utf32.result b/mysql-test/suite/parts/r/part_ctype_utf32.result
index 5d52a8eace4..4667fe1035f 100644
--- a/mysql-test/suite/parts/r/part_ctype_utf32.result
+++ b/mysql-test/suite/parts/r/part_ctype_utf32.result
@@ -3,7 +3,7 @@
#
DROP TABLE IF EXISTS t1;
Warnings:
-Note 1051 Unknown table 't1'
+Note 1051 Unknown table 'test.t1'
CREATE TABLE t1 (
a enum('a') CHARACTER SET utf32 COLLATE utf32_spanish2_ci
) ENGINE=MYISAM PARTITION BY KEY(a) PARTITIONS 2;
diff --git a/mysql-test/suite/parts/r/partition_alter1_1_2_innodb.result b/mysql-test/suite/parts/r/partition_alter1_1_2_innodb.result
index 3ef62f2b050..00ef7527059 100644
--- a/mysql-test/suite/parts/r/partition_alter1_1_2_innodb.result
+++ b/mysql-test/suite/parts/r/partition_alter1_1_2_innodb.result
@@ -1,5 +1,5 @@
SET @max_row = 20;
-SET @@session.storage_engine = 'InnoDB';
+SET @@session.default_storage_engine = 'InnoDB';
#------------------------------------------------------------------------
# 0. Setting of auxiliary variables + Creation of an auxiliary tables
diff --git a/mysql-test/suite/parts/r/partition_alter1_1_2_myisam.result b/mysql-test/suite/parts/r/partition_alter1_1_2_myisam.result
index 887ac403cdb..bc737289895 100644
--- a/mysql-test/suite/parts/r/partition_alter1_1_2_myisam.result
+++ b/mysql-test/suite/parts/r/partition_alter1_1_2_myisam.result
@@ -1,5 +1,5 @@
SET @max_row = 20;
-SET @@session.storage_engine = 'MyISAM';
+SET @@session.default_storage_engine = 'MyISAM';
#------------------------------------------------------------------------
# 0. Setting of auxiliary variables + Creation of an auxiliary tables
diff --git a/mysql-test/suite/parts/r/partition_alter1_1_innodb.result b/mysql-test/suite/parts/r/partition_alter1_1_innodb.result
index 66d84768b5e..0a7b284a15c 100644
--- a/mysql-test/suite/parts/r/partition_alter1_1_innodb.result
+++ b/mysql-test/suite/parts/r/partition_alter1_1_innodb.result
@@ -1,5 +1,5 @@
SET @max_row = 20;
-SET @@session.storage_engine = 'InnoDB';
+SET @@session.default_storage_engine = 'InnoDB';
#------------------------------------------------------------------------
# 0. Setting of auxiliary variables + Creation of an auxiliary tables
diff --git a/mysql-test/suite/parts/r/partition_alter1_1_myisam.result b/mysql-test/suite/parts/r/partition_alter1_1_myisam.result
index 9f616d04df3..26450b28620 100644
--- a/mysql-test/suite/parts/r/partition_alter1_1_myisam.result
+++ b/mysql-test/suite/parts/r/partition_alter1_1_myisam.result
@@ -1,5 +1,5 @@
SET @max_row = 20;
-SET @@session.storage_engine = 'MyISAM';
+SET @@session.default_storage_engine = 'MyISAM';
#------------------------------------------------------------------------
# 0. Setting of auxiliary variables + Creation of an auxiliary tables
diff --git a/mysql-test/suite/parts/r/partition_alter1_2_innodb.result b/mysql-test/suite/parts/r/partition_alter1_2_innodb.result
index f1a1aeecb66..22d24bd50fe 100644
--- a/mysql-test/suite/parts/r/partition_alter1_2_innodb.result
+++ b/mysql-test/suite/parts/r/partition_alter1_2_innodb.result
@@ -1,5 +1,5 @@
SET @max_row = 20;
-SET @@session.storage_engine = 'InnoDB';
+SET @@session.default_storage_engine = 'InnoDB';
#------------------------------------------------------------------------
# 0. Setting of auxiliary variables + Creation of an auxiliary tables
diff --git a/mysql-test/suite/parts/r/partition_alter1_2_myisam.result b/mysql-test/suite/parts/r/partition_alter1_2_myisam.result
index 087262f5f89..72545e89bae 100644
--- a/mysql-test/suite/parts/r/partition_alter1_2_myisam.result
+++ b/mysql-test/suite/parts/r/partition_alter1_2_myisam.result
@@ -1,5 +1,5 @@
SET @max_row = 20;
-SET @@session.storage_engine = 'MyISAM';
+SET @@session.default_storage_engine = 'MyISAM';
#------------------------------------------------------------------------
# 0. Setting of auxiliary variables + Creation of an auxiliary tables
diff --git a/mysql-test/suite/parts/r/partition_alter2_1_1_innodb.result b/mysql-test/suite/parts/r/partition_alter2_1_1_innodb.result
index 314044044bb..f3d5314643b 100644
--- a/mysql-test/suite/parts/r/partition_alter2_1_1_innodb.result
+++ b/mysql-test/suite/parts/r/partition_alter2_1_1_innodb.result
@@ -1,5 +1,5 @@
SET @max_row = 20;
-SET @@session.storage_engine = 'InnoDB';
+SET @@session.default_storage_engine = 'InnoDB';
#------------------------------------------------------------------------
# 0. Setting of auxiliary variables + Creation of an auxiliary tables
diff --git a/mysql-test/suite/parts/r/partition_alter2_1_2_innodb.result b/mysql-test/suite/parts/r/partition_alter2_1_2_innodb.result
index e824cf45ce9..eb662109cea 100644
--- a/mysql-test/suite/parts/r/partition_alter2_1_2_innodb.result
+++ b/mysql-test/suite/parts/r/partition_alter2_1_2_innodb.result
@@ -1,5 +1,5 @@
SET @max_row = 20;
-SET @@session.storage_engine = 'InnoDB';
+SET @@session.default_storage_engine = 'InnoDB';
#------------------------------------------------------------------------
# 0. Setting of auxiliary variables + Creation of an auxiliary tables
diff --git a/mysql-test/suite/parts/r/partition_alter2_1_maria.result b/mysql-test/suite/parts/r/partition_alter2_1_maria.result
index 3dc6bae975a..0e7c1818fbc 100644
--- a/mysql-test/suite/parts/r/partition_alter2_1_maria.result
+++ b/mysql-test/suite/parts/r/partition_alter2_1_maria.result
@@ -1,5 +1,5 @@
SET @max_row = 20;
-SET @@session.storage_engine = 'Aria';
+SET @@session.default_storage_engine = 'Aria';
#------------------------------------------------------------------------
# 0. Setting of auxiliary variables + Creation of an auxiliary tables
diff --git a/mysql-test/suite/parts/r/partition_alter2_1_myisam.result b/mysql-test/suite/parts/r/partition_alter2_1_myisam.result
index f2a13497159..c3e1b18841c 100644
--- a/mysql-test/suite/parts/r/partition_alter2_1_myisam.result
+++ b/mysql-test/suite/parts/r/partition_alter2_1_myisam.result
@@ -1,5 +1,5 @@
SET @max_row = 20;
-SET @@session.storage_engine = 'MyISAM';
+SET @@session.default_storage_engine = 'MyISAM';
#------------------------------------------------------------------------
# 0. Setting of auxiliary variables + Creation of an auxiliary tables
diff --git a/mysql-test/suite/parts/r/partition_alter2_2_1_innodb.result b/mysql-test/suite/parts/r/partition_alter2_2_1_innodb.result
index faba21b41f7..1f4642f63ec 100644
--- a/mysql-test/suite/parts/r/partition_alter2_2_1_innodb.result
+++ b/mysql-test/suite/parts/r/partition_alter2_2_1_innodb.result
@@ -1,5 +1,5 @@
SET @max_row = 20;
-SET @@session.storage_engine = 'InnoDB';
+SET @@session.default_storage_engine = 'InnoDB';
#------------------------------------------------------------------------
# 0. Setting of auxiliary variables + Creation of an auxiliary tables
diff --git a/mysql-test/suite/parts/r/partition_alter2_2_2_innodb.result b/mysql-test/suite/parts/r/partition_alter2_2_2_innodb.result
index 2557cd5a219..0db5bf79c4d 100644
--- a/mysql-test/suite/parts/r/partition_alter2_2_2_innodb.result
+++ b/mysql-test/suite/parts/r/partition_alter2_2_2_innodb.result
@@ -1,5 +1,5 @@
SET @max_row = 20;
-SET @@session.storage_engine = 'InnoDB';
+SET @@session.default_storage_engine = 'InnoDB';
#------------------------------------------------------------------------
# 0. Setting of auxiliary variables + Creation of an auxiliary tables
diff --git a/mysql-test/suite/parts/r/partition_alter2_2_maria.result b/mysql-test/suite/parts/r/partition_alter2_2_maria.result
index b5d45539036..2bb3683ad73 100644
--- a/mysql-test/suite/parts/r/partition_alter2_2_maria.result
+++ b/mysql-test/suite/parts/r/partition_alter2_2_maria.result
@@ -1,5 +1,5 @@
SET @max_row = 20;
-SET @@session.storage_engine = 'Aria';
+SET @@session.default_storage_engine = 'Aria';
#------------------------------------------------------------------------
# 0. Setting of auxiliary variables + Creation of an auxiliary tables
diff --git a/mysql-test/suite/parts/r/partition_alter2_2_myisam.result b/mysql-test/suite/parts/r/partition_alter2_2_myisam.result
index 70e869f48fb..8d8e77ebbd3 100644
--- a/mysql-test/suite/parts/r/partition_alter2_2_myisam.result
+++ b/mysql-test/suite/parts/r/partition_alter2_2_myisam.result
@@ -1,5 +1,5 @@
SET @max_row = 20;
-SET @@session.storage_engine = 'MyISAM';
+SET @@session.default_storage_engine = 'MyISAM';
#------------------------------------------------------------------------
# 0. Setting of auxiliary variables + Creation of an auxiliary tables
diff --git a/mysql-test/suite/parts/r/partition_alter3_innodb.result b/mysql-test/suite/parts/r/partition_alter3_innodb.result
index ed41ede378d..fd67547f55b 100644
--- a/mysql-test/suite/parts/r/partition_alter3_innodb.result
+++ b/mysql-test/suite/parts/r/partition_alter3_innodb.result
@@ -1,5 +1,5 @@
SET @max_row = 20;
-SET @@session.storage_engine = 'InnoDB';
+SET @@session.default_storage_engine = 'InnoDB';
#------------------------------------------------------------------------
# 0. Setting of auxiliary variables + Creation of an auxiliary tables
@@ -57,6 +57,7 @@ t1 CREATE TABLE `t1` (
`f_varchar` varchar(30) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
t1.frm
+t1.ibd
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 Using where
@@ -78,6 +79,7 @@ t1 CREATE TABLE `t1` (
`f_varchar` varchar(30) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
/*!50100 PARTITION BY HASH (YEAR(f_date)) */
+t1#P#p0.ibd
t1.frm
t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
@@ -96,6 +98,7 @@ t1 CREATE TABLE `t1` (
`f_varchar` varchar(30) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
/*!50100 PARTITION BY HASH (DAYOFYEAR(f_date)) */
+t1#P#p0.ibd
t1.frm
t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
@@ -112,6 +115,7 @@ t1 CREATE TABLE `t1` (
`f_varchar` varchar(30) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
/*!50100 PARTITION BY HASH (YEAR(f_date)) */
+t1#P#p0.ibd
t1.frm
t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
@@ -137,6 +141,9 @@ t1 CREATE TABLE `t1` (
(PARTITION p0 ENGINE = InnoDB,
PARTITION part1 ENGINE = InnoDB,
PARTITION part7 ENGINE = InnoDB) */
+t1#P#p0.ibd
+t1#P#part1.ibd
+t1#P#part7.ibd
t1.frm
t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
@@ -161,6 +168,10 @@ t1 CREATE TABLE `t1` (
PARTITION part1 ENGINE = InnoDB,
PARTITION part7 ENGINE = InnoDB,
PARTITION part2 ENGINE = InnoDB) */
+t1#P#p0.ibd
+t1#P#part1.ibd
+t1#P#part2.ibd
+t1#P#part7.ibd
t1.frm
t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
@@ -186,6 +197,14 @@ t1 CREATE TABLE `t1` (
PARTITION p5 ENGINE = InnoDB,
PARTITION p6 ENGINE = InnoDB,
PARTITION p7 ENGINE = InnoDB) */
+t1#P#p0.ibd
+t1#P#p4.ibd
+t1#P#p5.ibd
+t1#P#p6.ibd
+t1#P#p7.ibd
+t1#P#part1.ibd
+t1#P#part2.ibd
+t1#P#part7.ibd
t1.frm
t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
@@ -222,6 +241,13 @@ t1 CREATE TABLE `t1` (
PARTITION p4 ENGINE = InnoDB,
PARTITION p5 ENGINE = InnoDB,
PARTITION p6 ENGINE = InnoDB) */
+t1#P#p0.ibd
+t1#P#p4.ibd
+t1#P#p5.ibd
+t1#P#p6.ibd
+t1#P#part1.ibd
+t1#P#part2.ibd
+t1#P#part7.ibd
t1.frm
t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
@@ -244,6 +270,12 @@ t1 CREATE TABLE `t1` (
PARTITION part2 ENGINE = InnoDB,
PARTITION p4 ENGINE = InnoDB,
PARTITION p5 ENGINE = InnoDB) */
+t1#P#p0.ibd
+t1#P#p4.ibd
+t1#P#p5.ibd
+t1#P#part1.ibd
+t1#P#part2.ibd
+t1#P#part7.ibd
t1.frm
t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
@@ -265,6 +297,11 @@ t1 CREATE TABLE `t1` (
PARTITION part7 ENGINE = InnoDB,
PARTITION part2 ENGINE = InnoDB,
PARTITION p4 ENGINE = InnoDB) */
+t1#P#p0.ibd
+t1#P#p4.ibd
+t1#P#part1.ibd
+t1#P#part2.ibd
+t1#P#part7.ibd
t1.frm
t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
@@ -285,6 +322,10 @@ t1 CREATE TABLE `t1` (
PARTITION part1 ENGINE = InnoDB,
PARTITION part7 ENGINE = InnoDB,
PARTITION part2 ENGINE = InnoDB) */
+t1#P#p0.ibd
+t1#P#part1.ibd
+t1#P#part2.ibd
+t1#P#part7.ibd
t1.frm
t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
@@ -304,6 +345,9 @@ t1 CREATE TABLE `t1` (
(PARTITION p0 ENGINE = InnoDB,
PARTITION part1 ENGINE = InnoDB,
PARTITION part7 ENGINE = InnoDB) */
+t1#P#p0.ibd
+t1#P#part1.ibd
+t1#P#part7.ibd
t1.frm
t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
@@ -322,6 +366,8 @@ t1 CREATE TABLE `t1` (
/*!50100 PARTITION BY HASH (YEAR(f_date))
(PARTITION p0 ENGINE = InnoDB,
PARTITION part1 ENGINE = InnoDB) */
+t1#P#p0.ibd
+t1#P#part1.ibd
t1.frm
t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
@@ -339,6 +385,7 @@ t1 CREATE TABLE `t1` (
) ENGINE=InnoDB DEFAULT CHARSET=latin1
/*!50100 PARTITION BY HASH (YEAR(f_date))
(PARTITION p0 ENGINE = InnoDB) */
+t1#P#p0.ibd
t1.frm
t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
@@ -359,6 +406,7 @@ t1 CREATE TABLE `t1` (
`f_varchar` varchar(30) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
t1.frm
+t1.ibd
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 Using where
@@ -367,6 +415,7 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
# check read row by row success: 1
# 1.2.7 Remove partitioning from not partitioned table --> ????
ALTER TABLE t1 REMOVE PARTITIONING;
+ERROR HY000: Partition management on a not partitioned table is not possible
DROP TABLE t1;
# Attention: There are unused files.
# Either the DROP TABLE or a preceding ALTER TABLE
@@ -398,6 +447,7 @@ t1 CREATE TABLE `t1` (
`f_charbig` varchar(1000) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
t1.frm
+t1.ibd
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 Using where
@@ -420,6 +470,7 @@ t1 CREATE TABLE `t1` (
`f_charbig` varchar(1000) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
/*!50100 PARTITION BY KEY (f_int1) */
+t1#P#p0.ibd
t1.frm
t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
@@ -448,6 +499,9 @@ t1 CREATE TABLE `t1` (
(PARTITION p0 ENGINE = InnoDB,
PARTITION part1 ENGINE = InnoDB,
PARTITION part7 ENGINE = InnoDB) */
+t1#P#p0.ibd
+t1#P#part1.ibd
+t1#P#part7.ibd
t1.frm
t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
@@ -472,6 +526,10 @@ t1 CREATE TABLE `t1` (
PARTITION part1 ENGINE = InnoDB,
PARTITION part7 ENGINE = InnoDB,
PARTITION part2 ENGINE = InnoDB) */
+t1#P#p0.ibd
+t1#P#part1.ibd
+t1#P#part2.ibd
+t1#P#part7.ibd
t1.frm
t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
@@ -500,6 +558,14 @@ t1 CREATE TABLE `t1` (
PARTITION p5 ENGINE = InnoDB,
PARTITION p6 ENGINE = InnoDB,
PARTITION p7 ENGINE = InnoDB) */
+t1#P#p0.ibd
+t1#P#p4.ibd
+t1#P#p5.ibd
+t1#P#p6.ibd
+t1#P#p7.ibd
+t1#P#part1.ibd
+t1#P#part2.ibd
+t1#P#part7.ibd
t1.frm
t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
@@ -534,6 +600,13 @@ t1 CREATE TABLE `t1` (
PARTITION p4 ENGINE = InnoDB,
PARTITION p5 ENGINE = InnoDB,
PARTITION p6 ENGINE = InnoDB) */
+t1#P#p0.ibd
+t1#P#p4.ibd
+t1#P#p5.ibd
+t1#P#p6.ibd
+t1#P#part1.ibd
+t1#P#part2.ibd
+t1#P#part7.ibd
t1.frm
t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
@@ -559,6 +632,12 @@ t1 CREATE TABLE `t1` (
PARTITION part2 ENGINE = InnoDB,
PARTITION p4 ENGINE = InnoDB,
PARTITION p5 ENGINE = InnoDB) */
+t1#P#p0.ibd
+t1#P#p4.ibd
+t1#P#p5.ibd
+t1#P#part1.ibd
+t1#P#part2.ibd
+t1#P#part7.ibd
t1.frm
t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
@@ -583,6 +662,11 @@ t1 CREATE TABLE `t1` (
PARTITION part7 ENGINE = InnoDB,
PARTITION part2 ENGINE = InnoDB,
PARTITION p4 ENGINE = InnoDB) */
+t1#P#p0.ibd
+t1#P#p4.ibd
+t1#P#part1.ibd
+t1#P#part2.ibd
+t1#P#part7.ibd
t1.frm
t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
@@ -606,6 +690,10 @@ t1 CREATE TABLE `t1` (
PARTITION part1 ENGINE = InnoDB,
PARTITION part7 ENGINE = InnoDB,
PARTITION part2 ENGINE = InnoDB) */
+t1#P#p0.ibd
+t1#P#part1.ibd
+t1#P#part2.ibd
+t1#P#part7.ibd
t1.frm
t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
@@ -628,6 +716,9 @@ t1 CREATE TABLE `t1` (
(PARTITION p0 ENGINE = InnoDB,
PARTITION part1 ENGINE = InnoDB,
PARTITION part7 ENGINE = InnoDB) */
+t1#P#p0.ibd
+t1#P#part1.ibd
+t1#P#part7.ibd
t1.frm
t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
@@ -649,6 +740,8 @@ t1 CREATE TABLE `t1` (
/*!50100 PARTITION BY KEY (f_int1)
(PARTITION p0 ENGINE = InnoDB,
PARTITION part1 ENGINE = InnoDB) */
+t1#P#p0.ibd
+t1#P#part1.ibd
t1.frm
t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
@@ -669,6 +762,7 @@ t1 CREATE TABLE `t1` (
) ENGINE=InnoDB DEFAULT CHARSET=latin1
/*!50100 PARTITION BY KEY (f_int1)
(PARTITION p0 ENGINE = InnoDB) */
+t1#P#p0.ibd
t1.frm
t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
@@ -692,6 +786,7 @@ t1 CREATE TABLE `t1` (
`f_charbig` varchar(1000) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
t1.frm
+t1.ibd
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 Using where
@@ -700,6 +795,7 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
# check read row by row success: 1
# 2.2.7 Remove partitioning from not partitioned table --> ????
ALTER TABLE t1 REMOVE PARTITIONING;
+ERROR HY000: Partition management on a not partitioned table is not possible
DROP TABLE t1;
# Attention: There are unused files.
# Either the DROP TABLE or a preceding ALTER TABLE
diff --git a/mysql-test/suite/parts/r/partition_alter3_myisam.result b/mysql-test/suite/parts/r/partition_alter3_myisam.result
index 297f2bf9210..dfb21ee17ba 100644
--- a/mysql-test/suite/parts/r/partition_alter3_myisam.result
+++ b/mysql-test/suite/parts/r/partition_alter3_myisam.result
@@ -1,5 +1,5 @@
SET @max_row = 20;
-SET @@session.storage_engine = 'MyISAM';
+SET @@session.default_storage_engine = 'MyISAM';
#------------------------------------------------------------------------
# 0. Setting of auxiliary variables + Creation of an auxiliary tables
@@ -463,6 +463,7 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
# check read row by row success: 1
# 1.2.7 Remove partitioning from not partitioned table --> ????
ALTER TABLE t1 REMOVE PARTITIONING;
+ERROR HY000: Partition management on a not partitioned table is not possible
DROP TABLE t1;
#========================================================================
@@ -882,6 +883,7 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
# check read row by row success: 1
# 2.2.7 Remove partitioning from not partitioned table --> ????
ALTER TABLE t1 REMOVE PARTITIONING;
+ERROR HY000: Partition management on a not partitioned table is not possible
DROP TABLE t1;
DROP VIEW IF EXISTS v1;
DROP TABLE IF EXISTS t1;
diff --git a/mysql-test/suite/parts/r/partition_alter4_innodb.result b/mysql-test/suite/parts/r/partition_alter4_innodb.result
index 46f3ed3c974..e4dacbc663c 100644
--- a/mysql-test/suite/parts/r/partition_alter4_innodb.result
+++ b/mysql-test/suite/parts/r/partition_alter4_innodb.result
@@ -1,5 +1,5 @@
SET @max_row = 20;
-SET @@session.storage_engine = 'InnoDB';
+SET @@session.default_storage_engine = 'InnoDB';
#------------------------------------------------------------------------
# 0. Setting of auxiliary variables + Creation of an auxiliary tables
diff --git a/mysql-test/suite/parts/r/partition_alter4_myisam.result b/mysql-test/suite/parts/r/partition_alter4_myisam.result
index c74a105306c..8aba07874aa 100644
--- a/mysql-test/suite/parts/r/partition_alter4_myisam.result
+++ b/mysql-test/suite/parts/r/partition_alter4_myisam.result
@@ -1,5 +1,5 @@
SET @max_row = 20;
-SET @@session.storage_engine = 'MyISAM';
+SET @@session.default_storage_engine = 'MyISAM';
#------------------------------------------------------------------------
# 0. Setting of auxiliary variables + Creation of an auxiliary tables
diff --git a/mysql-test/suite/parts/r/partition_basic_innodb.result b/mysql-test/suite/parts/r/partition_basic_innodb.result
index ea5a53fc5f4..0bf2b8e8eaa 100644
--- a/mysql-test/suite/parts/r/partition_basic_innodb.result
+++ b/mysql-test/suite/parts/r/partition_basic_innodb.result
@@ -1,5 +1,5 @@
SET @max_row = 20;
-SET @@session.storage_engine = 'InnoDB';
+SET @@session.default_storage_engine = 'InnoDB';
#------------------------------------------------------------------------
# 0. Setting of auxiliary variables + Creation of an auxiliary tables
@@ -77,6 +77,8 @@ t1 CREATE TABLE `t1` (
PARTITIONS 2 */
unified filelist
+t1#P#p0.ibd
+t1#P#p1.ibd
t1.frm
t1.par
@@ -532,6 +534,11 @@ t1 CREATE TABLE `t1` (
PARTITIONS 5 */
unified filelist
+t1#P#p0.ibd
+t1#P#p1.ibd
+t1#P#p2.ibd
+t1#P#p3.ibd
+t1#P#p4.ibd
t1.frm
t1.par
@@ -1002,6 +1009,14 @@ t1 CREATE TABLE `t1` (
PARTITION part3 VALUES IN (3) ENGINE = InnoDB) */
unified filelist
+t1#P#part0.ibd
+t1#P#part1.ibd
+t1#P#part2.ibd
+t1#P#part3.ibd
+t1#P#part_1.ibd
+t1#P#part_2.ibd
+t1#P#part_3.ibd
+t1#P#part_N.ibd
t1.frm
t1.par
@@ -1468,6 +1483,12 @@ t1 CREATE TABLE `t1` (
PARTITION partf VALUES LESS THAN (2147483646) ENGINE = InnoDB) */
unified filelist
+t1#P#parta.ibd
+t1#P#partb.ibd
+t1#P#partc.ibd
+t1#P#partd.ibd
+t1#P#parte.ibd
+t1#P#partf.ibd
t1.frm
t1.par
@@ -1930,6 +1951,14 @@ SUBPARTITIONS 2
PARTITION partd VALUES LESS THAN (2147483646) ENGINE = InnoDB) */
unified filelist
+t1#P#parta#SP#partasp0.ibd
+t1#P#parta#SP#partasp1.ibd
+t1#P#partb#SP#partbsp0.ibd
+t1#P#partb#SP#partbsp1.ibd
+t1#P#partc#SP#partcsp0.ibd
+t1#P#partc#SP#partcsp1.ibd
+t1#P#partd#SP#partdsp0.ibd
+t1#P#partd#SP#partdsp1.ibd
t1.frm
t1.par
@@ -2405,6 +2434,14 @@ SUBPARTITION BY KEY (f_int1)
SUBPARTITION subpart42 ENGINE = InnoDB)) */
unified filelist
+t1#P#part1#SP#subpart11.ibd
+t1#P#part1#SP#subpart12.ibd
+t1#P#part2#SP#subpart21.ibd
+t1#P#part2#SP#subpart22.ibd
+t1#P#part3#SP#subpart31.ibd
+t1#P#part3#SP#subpart32.ibd
+t1#P#part4#SP#subpart41.ibd
+t1#P#part4#SP#subpart42.ibd
t1.frm
t1.par
@@ -2882,6 +2919,14 @@ SUBPARTITION BY HASH (f_int1 + 1)
SUBPARTITION sp42 ENGINE = InnoDB)) */
unified filelist
+t1#P#part1#SP#sp11.ibd
+t1#P#part1#SP#sp12.ibd
+t1#P#part2#SP#sp21.ibd
+t1#P#part2#SP#sp22.ibd
+t1#P#part3#SP#sp31.ibd
+t1#P#part3#SP#sp32.ibd
+t1#P#part4#SP#sp41.ibd
+t1#P#part4#SP#sp42.ibd
t1.frm
t1.par
@@ -3345,6 +3390,15 @@ SUBPARTITIONS 3
PARTITION part3 VALUES IN (NULL) ENGINE = InnoDB) */
unified filelist
+t1#P#part1#SP#part1sp0.ibd
+t1#P#part1#SP#part1sp1.ibd
+t1#P#part1#SP#part1sp2.ibd
+t1#P#part2#SP#part2sp0.ibd
+t1#P#part2#SP#part2sp1.ibd
+t1#P#part2#SP#part2sp2.ibd
+t1#P#part3#SP#part3sp0.ibd
+t1#P#part3#SP#part3sp1.ibd
+t1#P#part3#SP#part3sp2.ibd
t1.frm
t1.par
@@ -3802,6 +3856,8 @@ t1 CREATE TABLE `t1` (
PARTITIONS 2 */
unified filelist
+t1#P#p0.ibd
+t1#P#p1.ibd
t1.frm
t1.par
@@ -4257,6 +4313,11 @@ t1 CREATE TABLE `t1` (
PARTITIONS 5 */
unified filelist
+t1#P#p0.ibd
+t1#P#p1.ibd
+t1#P#p2.ibd
+t1#P#p3.ibd
+t1#P#p4.ibd
t1.frm
t1.par
@@ -4727,6 +4788,14 @@ t1 CREATE TABLE `t1` (
PARTITION part3 VALUES IN (3) ENGINE = InnoDB) */
unified filelist
+t1#P#part0.ibd
+t1#P#part1.ibd
+t1#P#part2.ibd
+t1#P#part3.ibd
+t1#P#part_1.ibd
+t1#P#part_2.ibd
+t1#P#part_3.ibd
+t1#P#part_N.ibd
t1.frm
t1.par
@@ -5193,6 +5262,12 @@ t1 CREATE TABLE `t1` (
PARTITION partf VALUES LESS THAN (2147483646) ENGINE = InnoDB) */
unified filelist
+t1#P#parta.ibd
+t1#P#partb.ibd
+t1#P#partc.ibd
+t1#P#partd.ibd
+t1#P#parte.ibd
+t1#P#partf.ibd
t1.frm
t1.par
@@ -5655,6 +5730,14 @@ SUBPARTITIONS 2
PARTITION partd VALUES LESS THAN (2147483646) ENGINE = InnoDB) */
unified filelist
+t1#P#parta#SP#partasp0.ibd
+t1#P#parta#SP#partasp1.ibd
+t1#P#partb#SP#partbsp0.ibd
+t1#P#partb#SP#partbsp1.ibd
+t1#P#partc#SP#partcsp0.ibd
+t1#P#partc#SP#partcsp1.ibd
+t1#P#partd#SP#partdsp0.ibd
+t1#P#partd#SP#partdsp1.ibd
t1.frm
t1.par
@@ -6128,6 +6211,14 @@ SUBPARTITION BY KEY (f_int2)
SUBPARTITION subpart42 ENGINE = InnoDB)) */
unified filelist
+t1#P#part1#SP#subpart11.ibd
+t1#P#part1#SP#subpart12.ibd
+t1#P#part2#SP#subpart21.ibd
+t1#P#part2#SP#subpart22.ibd
+t1#P#part3#SP#subpart31.ibd
+t1#P#part3#SP#subpart32.ibd
+t1#P#part4#SP#subpart41.ibd
+t1#P#part4#SP#subpart42.ibd
t1.frm
t1.par
@@ -6601,6 +6692,14 @@ SUBPARTITION BY HASH (f_int2 + 1)
SUBPARTITION sp42 ENGINE = InnoDB)) */
unified filelist
+t1#P#part1#SP#sp11.ibd
+t1#P#part1#SP#sp12.ibd
+t1#P#part2#SP#sp21.ibd
+t1#P#part2#SP#sp22.ibd
+t1#P#part3#SP#sp31.ibd
+t1#P#part3#SP#sp32.ibd
+t1#P#part4#SP#sp41.ibd
+t1#P#part4#SP#sp42.ibd
t1.frm
t1.par
@@ -7064,6 +7163,15 @@ SUBPARTITIONS 3
PARTITION part3 VALUES IN (NULL) ENGINE = InnoDB) */
unified filelist
+t1#P#part1#SP#part1sp0.ibd
+t1#P#part1#SP#part1sp1.ibd
+t1#P#part1#SP#part1sp2.ibd
+t1#P#part2#SP#part2sp0.ibd
+t1#P#part2#SP#part2sp1.ibd
+t1#P#part2#SP#part2sp2.ibd
+t1#P#part3#SP#part3sp0.ibd
+t1#P#part3#SP#part3sp1.ibd
+t1#P#part3#SP#part3sp2.ibd
t1.frm
t1.par
@@ -7527,6 +7635,8 @@ t1 CREATE TABLE `t1` (
PARTITIONS 2 */
unified filelist
+t1#P#p0.ibd
+t1#P#p1.ibd
t1.frm
t1.par
@@ -8019,6 +8129,11 @@ t1 CREATE TABLE `t1` (
PARTITIONS 5 */
unified filelist
+t1#P#p0.ibd
+t1#P#p1.ibd
+t1#P#p2.ibd
+t1#P#p3.ibd
+t1#P#p4.ibd
t1.frm
t1.par
@@ -8526,6 +8641,14 @@ t1 CREATE TABLE `t1` (
PARTITION part3 VALUES IN (3) ENGINE = InnoDB) */
unified filelist
+t1#P#part0.ibd
+t1#P#part1.ibd
+t1#P#part2.ibd
+t1#P#part3.ibd
+t1#P#part_1.ibd
+t1#P#part_2.ibd
+t1#P#part_3.ibd
+t1#P#part_N.ibd
t1.frm
t1.par
@@ -9029,6 +9152,12 @@ t1 CREATE TABLE `t1` (
PARTITION partf VALUES LESS THAN (2147483646) ENGINE = InnoDB) */
unified filelist
+t1#P#parta.ibd
+t1#P#partb.ibd
+t1#P#partc.ibd
+t1#P#partd.ibd
+t1#P#parte.ibd
+t1#P#partf.ibd
t1.frm
t1.par
@@ -9528,6 +9657,14 @@ SUBPARTITIONS 2
PARTITION partd VALUES LESS THAN (2147483646) ENGINE = InnoDB) */
unified filelist
+t1#P#parta#SP#partasp0.ibd
+t1#P#parta#SP#partasp1.ibd
+t1#P#partb#SP#partbsp0.ibd
+t1#P#partb#SP#partbsp1.ibd
+t1#P#partc#SP#partcsp0.ibd
+t1#P#partc#SP#partcsp1.ibd
+t1#P#partd#SP#partdsp0.ibd
+t1#P#partd#SP#partdsp1.ibd
t1.frm
t1.par
@@ -10040,6 +10177,14 @@ SUBPARTITION BY KEY (f_int1)
SUBPARTITION subpart42 ENGINE = InnoDB)) */
unified filelist
+t1#P#part1#SP#subpart11.ibd
+t1#P#part1#SP#subpart12.ibd
+t1#P#part2#SP#subpart21.ibd
+t1#P#part2#SP#subpart22.ibd
+t1#P#part3#SP#subpart31.ibd
+t1#P#part3#SP#subpart32.ibd
+t1#P#part4#SP#subpart41.ibd
+t1#P#part4#SP#subpart42.ibd
t1.frm
t1.par
@@ -10554,6 +10699,14 @@ SUBPARTITION BY HASH (f_int1 + 1)
SUBPARTITION sp42 ENGINE = InnoDB)) */
unified filelist
+t1#P#part1#SP#sp11.ibd
+t1#P#part1#SP#sp12.ibd
+t1#P#part2#SP#sp21.ibd
+t1#P#part2#SP#sp22.ibd
+t1#P#part3#SP#sp31.ibd
+t1#P#part3#SP#sp32.ibd
+t1#P#part4#SP#sp41.ibd
+t1#P#part4#SP#sp42.ibd
t1.frm
t1.par
@@ -11054,6 +11207,15 @@ SUBPARTITIONS 3
PARTITION part3 VALUES IN (NULL) ENGINE = InnoDB) */
unified filelist
+t1#P#part1#SP#part1sp0.ibd
+t1#P#part1#SP#part1sp1.ibd
+t1#P#part1#SP#part1sp2.ibd
+t1#P#part2#SP#part2sp0.ibd
+t1#P#part2#SP#part2sp1.ibd
+t1#P#part2#SP#part2sp2.ibd
+t1#P#part3#SP#part3sp0.ibd
+t1#P#part3#SP#part3sp1.ibd
+t1#P#part3#SP#part3sp2.ibd
t1.frm
t1.par
@@ -11547,6 +11709,8 @@ t1 CREATE TABLE `t1` (
PARTITIONS 2 */
unified filelist
+t1#P#p0.ibd
+t1#P#p1.ibd
t1.frm
t1.par
@@ -12039,6 +12203,11 @@ t1 CREATE TABLE `t1` (
PARTITIONS 5 */
unified filelist
+t1#P#p0.ibd
+t1#P#p1.ibd
+t1#P#p2.ibd
+t1#P#p3.ibd
+t1#P#p4.ibd
t1.frm
t1.par
@@ -12546,6 +12715,14 @@ t1 CREATE TABLE `t1` (
PARTITION part3 VALUES IN (3) ENGINE = InnoDB) */
unified filelist
+t1#P#part0.ibd
+t1#P#part1.ibd
+t1#P#part2.ibd
+t1#P#part3.ibd
+t1#P#part_1.ibd
+t1#P#part_2.ibd
+t1#P#part_3.ibd
+t1#P#part_N.ibd
t1.frm
t1.par
@@ -13049,6 +13226,12 @@ t1 CREATE TABLE `t1` (
PARTITION partf VALUES LESS THAN (2147483646) ENGINE = InnoDB) */
unified filelist
+t1#P#parta.ibd
+t1#P#partb.ibd
+t1#P#partc.ibd
+t1#P#partd.ibd
+t1#P#parte.ibd
+t1#P#partf.ibd
t1.frm
t1.par
@@ -13548,6 +13731,14 @@ SUBPARTITIONS 2
PARTITION partd VALUES LESS THAN (2147483646) ENGINE = InnoDB) */
unified filelist
+t1#P#parta#SP#partasp0.ibd
+t1#P#parta#SP#partasp1.ibd
+t1#P#partb#SP#partbsp0.ibd
+t1#P#partb#SP#partbsp1.ibd
+t1#P#partc#SP#partcsp0.ibd
+t1#P#partc#SP#partcsp1.ibd
+t1#P#partd#SP#partdsp0.ibd
+t1#P#partd#SP#partdsp1.ibd
t1.frm
t1.par
@@ -14060,6 +14251,14 @@ SUBPARTITION BY KEY (f_int1)
SUBPARTITION subpart42 ENGINE = InnoDB)) */
unified filelist
+t1#P#part1#SP#subpart11.ibd
+t1#P#part1#SP#subpart12.ibd
+t1#P#part2#SP#subpart21.ibd
+t1#P#part2#SP#subpart22.ibd
+t1#P#part3#SP#subpart31.ibd
+t1#P#part3#SP#subpart32.ibd
+t1#P#part4#SP#subpart41.ibd
+t1#P#part4#SP#subpart42.ibd
t1.frm
t1.par
@@ -14574,6 +14773,14 @@ SUBPARTITION BY HASH (f_int1 + 1)
SUBPARTITION sp42 ENGINE = InnoDB)) */
unified filelist
+t1#P#part1#SP#sp11.ibd
+t1#P#part1#SP#sp12.ibd
+t1#P#part2#SP#sp21.ibd
+t1#P#part2#SP#sp22.ibd
+t1#P#part3#SP#sp31.ibd
+t1#P#part3#SP#sp32.ibd
+t1#P#part4#SP#sp41.ibd
+t1#P#part4#SP#sp42.ibd
t1.frm
t1.par
@@ -15074,6 +15281,15 @@ SUBPARTITIONS 3
PARTITION part3 VALUES IN (NULL) ENGINE = InnoDB) */
unified filelist
+t1#P#part1#SP#part1sp0.ibd
+t1#P#part1#SP#part1sp1.ibd
+t1#P#part1#SP#part1sp2.ibd
+t1#P#part2#SP#part2sp0.ibd
+t1#P#part2#SP#part2sp1.ibd
+t1#P#part2#SP#part2sp2.ibd
+t1#P#part3#SP#part3sp0.ibd
+t1#P#part3#SP#part3sp1.ibd
+t1#P#part3#SP#part3sp2.ibd
t1.frm
t1.par
@@ -15567,6 +15783,8 @@ t1 CREATE TABLE `t1` (
PARTITIONS 2 */
unified filelist
+t1#P#p0.ibd
+t1#P#p1.ibd
t1.frm
t1.par
@@ -16075,6 +16293,11 @@ t1 CREATE TABLE `t1` (
PARTITIONS 5 */
unified filelist
+t1#P#p0.ibd
+t1#P#p1.ibd
+t1#P#p2.ibd
+t1#P#p3.ibd
+t1#P#p4.ibd
t1.frm
t1.par
@@ -16598,6 +16821,14 @@ t1 CREATE TABLE `t1` (
PARTITION part3 VALUES IN (3) ENGINE = InnoDB) */
unified filelist
+t1#P#part0.ibd
+t1#P#part1.ibd
+t1#P#part2.ibd
+t1#P#part3.ibd
+t1#P#part_1.ibd
+t1#P#part_2.ibd
+t1#P#part_3.ibd
+t1#P#part_N.ibd
t1.frm
t1.par
@@ -17117,6 +17348,12 @@ t1 CREATE TABLE `t1` (
PARTITION partf VALUES LESS THAN (2147483646) ENGINE = InnoDB) */
unified filelist
+t1#P#parta.ibd
+t1#P#partb.ibd
+t1#P#partc.ibd
+t1#P#partd.ibd
+t1#P#parte.ibd
+t1#P#partf.ibd
t1.frm
t1.par
@@ -17632,6 +17869,14 @@ SUBPARTITIONS 2
PARTITION partd VALUES LESS THAN (2147483646) ENGINE = InnoDB) */
unified filelist
+t1#P#parta#SP#partasp0.ibd
+t1#P#parta#SP#partasp1.ibd
+t1#P#partb#SP#partbsp0.ibd
+t1#P#partb#SP#partbsp1.ibd
+t1#P#partc#SP#partcsp0.ibd
+t1#P#partc#SP#partcsp1.ibd
+t1#P#partd#SP#partdsp0.ibd
+t1#P#partd#SP#partdsp1.ibd
t1.frm
t1.par
@@ -18160,6 +18405,14 @@ SUBPARTITION BY KEY (f_int1)
SUBPARTITION subpart42 ENGINE = InnoDB)) */
unified filelist
+t1#P#part1#SP#subpart11.ibd
+t1#P#part1#SP#subpart12.ibd
+t1#P#part2#SP#subpart21.ibd
+t1#P#part2#SP#subpart22.ibd
+t1#P#part3#SP#subpart31.ibd
+t1#P#part3#SP#subpart32.ibd
+t1#P#part4#SP#subpart41.ibd
+t1#P#part4#SP#subpart42.ibd
t1.frm
t1.par
@@ -18690,6 +18943,14 @@ SUBPARTITION BY HASH (f_int1 + 1)
SUBPARTITION sp42 ENGINE = InnoDB)) */
unified filelist
+t1#P#part1#SP#sp11.ibd
+t1#P#part1#SP#sp12.ibd
+t1#P#part2#SP#sp21.ibd
+t1#P#part2#SP#sp22.ibd
+t1#P#part3#SP#sp31.ibd
+t1#P#part3#SP#sp32.ibd
+t1#P#part4#SP#sp41.ibd
+t1#P#part4#SP#sp42.ibd
t1.frm
t1.par
@@ -19206,6 +19467,15 @@ SUBPARTITIONS 3
PARTITION part3 VALUES IN (NULL) ENGINE = InnoDB) */
unified filelist
+t1#P#part1#SP#part1sp0.ibd
+t1#P#part1#SP#part1sp1.ibd
+t1#P#part1#SP#part1sp2.ibd
+t1#P#part2#SP#part2sp0.ibd
+t1#P#part2#SP#part2sp1.ibd
+t1#P#part2#SP#part2sp2.ibd
+t1#P#part3#SP#part3sp0.ibd
+t1#P#part3#SP#part3sp1.ibd
+t1#P#part3#SP#part3sp2.ibd
t1.frm
t1.par
@@ -19720,6 +19990,8 @@ t1 CREATE TABLE `t1` (
PARTITIONS 2 */
unified filelist
+t1#P#p0.ibd
+t1#P#p1.ibd
t1.frm
t1.par
@@ -20212,6 +20484,11 @@ t1 CREATE TABLE `t1` (
PARTITIONS 5 */
unified filelist
+t1#P#p0.ibd
+t1#P#p1.ibd
+t1#P#p2.ibd
+t1#P#p3.ibd
+t1#P#p4.ibd
t1.frm
t1.par
@@ -20719,6 +20996,14 @@ t1 CREATE TABLE `t1` (
PARTITION part3 VALUES IN (3) ENGINE = InnoDB) */
unified filelist
+t1#P#part0.ibd
+t1#P#part1.ibd
+t1#P#part2.ibd
+t1#P#part3.ibd
+t1#P#part_1.ibd
+t1#P#part_2.ibd
+t1#P#part_3.ibd
+t1#P#part_N.ibd
t1.frm
t1.par
@@ -21222,6 +21507,12 @@ t1 CREATE TABLE `t1` (
PARTITION partf VALUES LESS THAN (2147483646) ENGINE = InnoDB) */
unified filelist
+t1#P#parta.ibd
+t1#P#partb.ibd
+t1#P#partc.ibd
+t1#P#partd.ibd
+t1#P#parte.ibd
+t1#P#partf.ibd
t1.frm
t1.par
@@ -21721,6 +22012,14 @@ SUBPARTITIONS 2
PARTITION partd VALUES LESS THAN (2147483646) ENGINE = InnoDB) */
unified filelist
+t1#P#parta#SP#partasp0.ibd
+t1#P#parta#SP#partasp1.ibd
+t1#P#partb#SP#partbsp0.ibd
+t1#P#partb#SP#partbsp1.ibd
+t1#P#partc#SP#partcsp0.ibd
+t1#P#partc#SP#partcsp1.ibd
+t1#P#partd#SP#partdsp0.ibd
+t1#P#partd#SP#partdsp1.ibd
t1.frm
t1.par
@@ -22231,6 +22530,14 @@ SUBPARTITION BY KEY (f_int2)
SUBPARTITION subpart42 ENGINE = InnoDB)) */
unified filelist
+t1#P#part1#SP#subpart11.ibd
+t1#P#part1#SP#subpart12.ibd
+t1#P#part2#SP#subpart21.ibd
+t1#P#part2#SP#subpart22.ibd
+t1#P#part3#SP#subpart31.ibd
+t1#P#part3#SP#subpart32.ibd
+t1#P#part4#SP#subpart41.ibd
+t1#P#part4#SP#subpart42.ibd
t1.frm
t1.par
@@ -22741,6 +23048,14 @@ SUBPARTITION BY HASH (f_int2 + 1)
SUBPARTITION sp42 ENGINE = InnoDB)) */
unified filelist
+t1#P#part1#SP#sp11.ibd
+t1#P#part1#SP#sp12.ibd
+t1#P#part2#SP#sp21.ibd
+t1#P#part2#SP#sp22.ibd
+t1#P#part3#SP#sp31.ibd
+t1#P#part3#SP#sp32.ibd
+t1#P#part4#SP#sp41.ibd
+t1#P#part4#SP#sp42.ibd
t1.frm
t1.par
@@ -23241,6 +23556,15 @@ SUBPARTITIONS 3
PARTITION part3 VALUES IN (NULL) ENGINE = InnoDB) */
unified filelist
+t1#P#part1#SP#part1sp0.ibd
+t1#P#part1#SP#part1sp1.ibd
+t1#P#part1#SP#part1sp2.ibd
+t1#P#part2#SP#part2sp0.ibd
+t1#P#part2#SP#part2sp1.ibd
+t1#P#part2#SP#part2sp2.ibd
+t1#P#part3#SP#part3sp0.ibd
+t1#P#part3#SP#part3sp1.ibd
+t1#P#part3#SP#part3sp2.ibd
t1.frm
t1.par
@@ -23734,6 +24058,8 @@ t1 CREATE TABLE `t1` (
PARTITIONS 2 */
unified filelist
+t1#P#p0.ibd
+t1#P#p1.ibd
t1.frm
t1.par
@@ -24226,6 +24552,11 @@ t1 CREATE TABLE `t1` (
PARTITIONS 5 */
unified filelist
+t1#P#p0.ibd
+t1#P#p1.ibd
+t1#P#p2.ibd
+t1#P#p3.ibd
+t1#P#p4.ibd
t1.frm
t1.par
@@ -24733,6 +25064,14 @@ t1 CREATE TABLE `t1` (
PARTITION part3 VALUES IN (3) ENGINE = InnoDB) */
unified filelist
+t1#P#part0.ibd
+t1#P#part1.ibd
+t1#P#part2.ibd
+t1#P#part3.ibd
+t1#P#part_1.ibd
+t1#P#part_2.ibd
+t1#P#part_3.ibd
+t1#P#part_N.ibd
t1.frm
t1.par
@@ -25236,6 +25575,12 @@ t1 CREATE TABLE `t1` (
PARTITION partf VALUES LESS THAN (2147483646) ENGINE = InnoDB) */
unified filelist
+t1#P#parta.ibd
+t1#P#partb.ibd
+t1#P#partc.ibd
+t1#P#partd.ibd
+t1#P#parte.ibd
+t1#P#partf.ibd
t1.frm
t1.par
@@ -25735,6 +26080,14 @@ SUBPARTITIONS 2
PARTITION partd VALUES LESS THAN (2147483646) ENGINE = InnoDB) */
unified filelist
+t1#P#parta#SP#partasp0.ibd
+t1#P#parta#SP#partasp1.ibd
+t1#P#partb#SP#partbsp0.ibd
+t1#P#partb#SP#partbsp1.ibd
+t1#P#partc#SP#partcsp0.ibd
+t1#P#partc#SP#partcsp1.ibd
+t1#P#partd#SP#partdsp0.ibd
+t1#P#partd#SP#partdsp1.ibd
t1.frm
t1.par
@@ -26245,6 +26598,14 @@ SUBPARTITION BY KEY (f_int2)
SUBPARTITION subpart42 ENGINE = InnoDB)) */
unified filelist
+t1#P#part1#SP#subpart11.ibd
+t1#P#part1#SP#subpart12.ibd
+t1#P#part2#SP#subpart21.ibd
+t1#P#part2#SP#subpart22.ibd
+t1#P#part3#SP#subpart31.ibd
+t1#P#part3#SP#subpart32.ibd
+t1#P#part4#SP#subpart41.ibd
+t1#P#part4#SP#subpart42.ibd
t1.frm
t1.par
@@ -26755,6 +27116,14 @@ SUBPARTITION BY HASH (f_int2 + 1)
SUBPARTITION sp42 ENGINE = InnoDB)) */
unified filelist
+t1#P#part1#SP#sp11.ibd
+t1#P#part1#SP#sp12.ibd
+t1#P#part2#SP#sp21.ibd
+t1#P#part2#SP#sp22.ibd
+t1#P#part3#SP#sp31.ibd
+t1#P#part3#SP#sp32.ibd
+t1#P#part4#SP#sp41.ibd
+t1#P#part4#SP#sp42.ibd
t1.frm
t1.par
@@ -27255,6 +27624,15 @@ SUBPARTITIONS 3
PARTITION part3 VALUES IN (NULL) ENGINE = InnoDB) */
unified filelist
+t1#P#part1#SP#part1sp0.ibd
+t1#P#part1#SP#part1sp1.ibd
+t1#P#part1#SP#part1sp2.ibd
+t1#P#part2#SP#part2sp0.ibd
+t1#P#part2#SP#part2sp1.ibd
+t1#P#part2#SP#part2sp2.ibd
+t1#P#part3#SP#part3sp0.ibd
+t1#P#part3#SP#part3sp1.ibd
+t1#P#part3#SP#part3sp2.ibd
t1.frm
t1.par
@@ -27748,6 +28126,8 @@ t1 CREATE TABLE `t1` (
PARTITIONS 2 */
unified filelist
+t1#P#p0.ibd
+t1#P#p1.ibd
t1.frm
t1.par
@@ -28256,6 +28636,11 @@ t1 CREATE TABLE `t1` (
PARTITIONS 5 */
unified filelist
+t1#P#p0.ibd
+t1#P#p1.ibd
+t1#P#p2.ibd
+t1#P#p3.ibd
+t1#P#p4.ibd
t1.frm
t1.par
@@ -28779,6 +29164,14 @@ t1 CREATE TABLE `t1` (
PARTITION part3 VALUES IN (3) ENGINE = InnoDB) */
unified filelist
+t1#P#part0.ibd
+t1#P#part1.ibd
+t1#P#part2.ibd
+t1#P#part3.ibd
+t1#P#part_1.ibd
+t1#P#part_2.ibd
+t1#P#part_3.ibd
+t1#P#part_N.ibd
t1.frm
t1.par
@@ -29298,6 +29691,12 @@ t1 CREATE TABLE `t1` (
PARTITION partf VALUES LESS THAN (2147483646) ENGINE = InnoDB) */
unified filelist
+t1#P#parta.ibd
+t1#P#partb.ibd
+t1#P#partc.ibd
+t1#P#partd.ibd
+t1#P#parte.ibd
+t1#P#partf.ibd
t1.frm
t1.par
@@ -29813,6 +30212,14 @@ SUBPARTITIONS 2
PARTITION partd VALUES LESS THAN (2147483646) ENGINE = InnoDB) */
unified filelist
+t1#P#parta#SP#partasp0.ibd
+t1#P#parta#SP#partasp1.ibd
+t1#P#partb#SP#partbsp0.ibd
+t1#P#partb#SP#partbsp1.ibd
+t1#P#partc#SP#partcsp0.ibd
+t1#P#partc#SP#partcsp1.ibd
+t1#P#partd#SP#partdsp0.ibd
+t1#P#partd#SP#partdsp1.ibd
t1.frm
t1.par
@@ -30339,6 +30746,14 @@ SUBPARTITION BY KEY (f_int2)
SUBPARTITION subpart42 ENGINE = InnoDB)) */
unified filelist
+t1#P#part1#SP#subpart11.ibd
+t1#P#part1#SP#subpart12.ibd
+t1#P#part2#SP#subpart21.ibd
+t1#P#part2#SP#subpart22.ibd
+t1#P#part3#SP#subpart31.ibd
+t1#P#part3#SP#subpart32.ibd
+t1#P#part4#SP#subpart41.ibd
+t1#P#part4#SP#subpart42.ibd
t1.frm
t1.par
@@ -30865,6 +31280,14 @@ SUBPARTITION BY HASH (f_int2 + 1)
SUBPARTITION sp42 ENGINE = InnoDB)) */
unified filelist
+t1#P#part1#SP#sp11.ibd
+t1#P#part1#SP#sp12.ibd
+t1#P#part2#SP#sp21.ibd
+t1#P#part2#SP#sp22.ibd
+t1#P#part3#SP#sp31.ibd
+t1#P#part3#SP#sp32.ibd
+t1#P#part4#SP#sp41.ibd
+t1#P#part4#SP#sp42.ibd
t1.frm
t1.par
@@ -31381,6 +31804,15 @@ SUBPARTITIONS 3
PARTITION part3 VALUES IN (NULL) ENGINE = InnoDB) */
unified filelist
+t1#P#part1#SP#part1sp0.ibd
+t1#P#part1#SP#part1sp1.ibd
+t1#P#part1#SP#part1sp2.ibd
+t1#P#part2#SP#part2sp0.ibd
+t1#P#part2#SP#part2sp1.ibd
+t1#P#part2#SP#part2sp2.ibd
+t1#P#part3#SP#part3sp0.ibd
+t1#P#part3#SP#part3sp1.ibd
+t1#P#part3#SP#part3sp2.ibd
t1.frm
t1.par
diff --git a/mysql-test/suite/parts/r/partition_basic_myisam.result b/mysql-test/suite/parts/r/partition_basic_myisam.result
index f70dae13bb6..8cddb7baca6 100644
--- a/mysql-test/suite/parts/r/partition_basic_myisam.result
+++ b/mysql-test/suite/parts/r/partition_basic_myisam.result
@@ -1,5 +1,5 @@
SET @max_row = 20;
-SET @@session.storage_engine = 'MyISAM';
+SET @@session.default_storage_engine = 'MyISAM';
#------------------------------------------------------------------------
# 0. Setting of auxiliary variables + Creation of an auxiliary tables
diff --git a/mysql-test/suite/parts/r/partition_basic_symlink_innodb.result b/mysql-test/suite/parts/r/partition_basic_symlink_innodb.result
index 731cb186b34..d7a77e5e54a 100644
--- a/mysql-test/suite/parts/r/partition_basic_symlink_innodb.result
+++ b/mysql-test/suite/parts/r/partition_basic_symlink_innodb.result
@@ -1,10 +1,41 @@
-# Will not run partition_basic_symlink on InnoDB, since it is the same
-# as partition_basic, since InnoDB does not support DATA/INDEX DIR
-# Will only verify that the DATA/INDEX DIR is stored and used if
-# ALTER to MyISAM.
+#
+# Verify that the DATA/INDEX DIR is stored and used if ALTER to MyISAM.
+#
DROP TABLE IF EXISTS t1;
-CREATE TABLE t1 (c1 INT)
-ENGINE = InnoDB
+SET SESSION innodb_strict_mode = ON;
+#
+# InnoDB only supports DATA DIRECTORY with innodb_file_per_table=ON
+#
+SET GLOBAL innodb_file_per_table = OFF;
+CREATE TABLE t1 (c1 INT) ENGINE = InnoDB
+PARTITION BY HASH (c1) (
+PARTITION p0
+DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir'
+ INDEX DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-idx-dir',
+PARTITION p1
+DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir'
+ INDEX DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-idx-dir'
+);
+ERROR HY000: Can't create table `test`.`t1` (errno: 140 "Wrong create options")
+SHOW WARNINGS;
+Level Code Message
+Warning 1478 InnoDB: DATA DIRECTORY requires innodb_file_per_table.
+Warning 1478 InnoDB: INDEX DIRECTORY is not supported
+Error 1005 Can't create table `test`.`t1` (errno: 140 "Wrong create options")
+Warning 1030 Got error 140 "Wrong create options" from storage engine InnoDB
+Error 6 Error on delete of 'MYSQLD_DATADIR/test/t1.par' (Errcode: 2 "No such file or directory")
+#
+# InnoDB is different from MyISAM in that it uses a text file
+# with an '.isl' extension instead of a symbolic link so that
+# the tablespace can be re-located on any OS. Also, instead of
+# putting the file directly into the DATA DIRECTORY,
+# it adds a folder under it with the name of the database.
+# Since strict mode is off, InnoDB ignores the INDEX DIRECTORY
+# and it is no longer part of the definition.
+#
+SET SESSION innodb_strict_mode = OFF;
+SET GLOBAL innodb_file_per_table = ON;
+CREATE TABLE t1 (c1 INT) ENGINE = InnoDB
PARTITION BY HASH (c1)
(PARTITION p0
DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir'
@@ -13,8 +44,26 @@ PARTITION p1
DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir'
INDEX DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-idx-dir'
);
-# Verifying .frm and .par files
-# Verifying that there are no MyISAM files
+Warnings:
+Warning 1618 <INDEX DIRECTORY> option ignored
+Warning 1618 <INDEX DIRECTORY> option ignored
+SHOW WARNINGS;
+Level Code Message
+Warning 1618 <INDEX DIRECTORY> option ignored
+Warning 1618 <INDEX DIRECTORY> option ignored
+# Verifying .frm, .par, .isl & .ibd files
+---- MYSQLD_DATADIR/test
+t1#P#p0.isl
+t1#P#p1.isl
+t1.frm
+t1.par
+---- MYSQLTEST_VARDIR/mysql-test-data-dir/test
+t1#P#p0.ibd
+t1#P#p1.ibd
+# The ibd tablespaces should not be directly under the DATA DIRECTORY
+---- MYSQLTEST_VARDIR/mysql-test-data-dir
+test
+---- MYSQLTEST_VARDIR/mysql-test-idx-dir
FLUSH TABLES;
SHOW CREATE TABLE t1;
Table Create Table
@@ -22,17 +71,61 @@ t1 CREATE TABLE `t1` (
`c1` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
/*!50100 PARTITION BY HASH (c1)
-(PARTITION p0 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' INDEX DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-idx-dir' ENGINE = InnoDB,
- PARTITION p1 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' INDEX DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-idx-dir' ENGINE = InnoDB) */
-ALTER TABLE t1 ENGINE = MyISAM;
-# Verifying .frm, .par and MyISAM files (.MYD, MYI)
-FLUSH TABLES;
+(PARTITION p0 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = InnoDB,
+ PARTITION p1 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = InnoDB) */
+#
+# Verify that the DATA/INDEX DIRECTORY is stored and used if we
+# ALTER TABLE to MyISAM.
+#
+ALTER TABLE t1 engine=MyISAM;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY HASH (c1)
-(PARTITION p0 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' INDEX DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-idx-dir' ENGINE = MyISAM,
- PARTITION p1 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' INDEX DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-idx-dir' ENGINE = MyISAM) */
+(PARTITION p0 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = MyISAM,
+ PARTITION p1 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = MyISAM) */
+# Verifying .frm, .par and MyISAM files (.MYD, MYI)
+---- MYSQLD_DATADIR/test
+t1#P#p0.MYD
+t1#P#p0.MYI
+t1#P#p1.MYD
+t1#P#p1.MYI
+t1.frm
+t1.par
+---- MYSQLTEST_VARDIR/mysql-test-data-dir
+t1#P#p0.MYD
+t1#P#p1.MYD
+test
+---- MYSQLTEST_VARDIR/mysql-test-idx-dir
+#
+# Now verify that the DATA DIRECTORY is used again if we
+# ALTER TABLE back to InnoDB.
+#
+SET SESSION innodb_strict_mode = ON;
+ALTER TABLE t1 engine=InnoDB;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` int(11) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY HASH (c1)
+(PARTITION p0 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = InnoDB,
+ PARTITION p1 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = InnoDB) */
+# Verifying .frm, .par, .isl and InnoDB .ibd files
+---- MYSQLD_DATADIR/test
+t1#P#p0.isl
+t1#P#p1.isl
+t1.frm
+t1.par
+---- MYSQLTEST_VARDIR/mysql-test-data-dir
+test
+---- MYSQLTEST_VARDIR/mysql-test-idx-dir
+---- MYSQLTEST_VARDIR/mysql-test-data-dir/test
+t1#P#p0.ibd
+t1#P#p1.ibd
DROP TABLE t1;
+#
+# Cleanup
+#
diff --git a/mysql-test/suite/parts/r/partition_basic_symlink_myisam.result b/mysql-test/suite/parts/r/partition_basic_symlink_myisam.result
index 146b3d361fb..5f44fd138d9 100644
--- a/mysql-test/suite/parts/r/partition_basic_symlink_myisam.result
+++ b/mysql-test/suite/parts/r/partition_basic_symlink_myisam.result
@@ -1,5 +1,5 @@
SET @max_row = 20;
-SET @@session.storage_engine = 'MyISAM';
+SET @@session.default_storage_engine = 'MyISAM';
#------------------------------------------------------------------------
# 0. Setting of auxiliary variables + Creation of an auxiliary tables
diff --git a/mysql-test/suite/parts/r/partition_char_innodb.result b/mysql-test/suite/parts/r/partition_char_innodb.result
index 6f4a107f840..bb99e89b022 100644
--- a/mysql-test/suite/parts/r/partition_char_innodb.result
+++ b/mysql-test/suite/parts/r/partition_char_innodb.result
Binary files differ
diff --git a/mysql-test/suite/parts/r/partition_char_myisam.result b/mysql-test/suite/parts/r/partition_char_myisam.result
index 913a874b646..9936f3ec0f4 100644
--- a/mysql-test/suite/parts/r/partition_char_myisam.result
+++ b/mysql-test/suite/parts/r/partition_char_myisam.result
Binary files differ
diff --git a/mysql-test/suite/parts/r/partition_debug.result b/mysql-test/suite/parts/r/partition_debug.result
new file mode 100644
index 00000000000..109072be49c
--- /dev/null
+++ b/mysql-test/suite/parts/r/partition_debug.result
@@ -0,0 +1,1948 @@
+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_dbug="+d,ha_partition_fail_index_init";
+SELECT * FROM t1 WHERE b = "Seven";
+ERROR HY000: Table has no partition for value 0
+SET SESSION debug_dbug="-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_dbug="+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_dbug="-d,exchange_partition_abort_1";
+SET SESSION debug_dbug="+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_dbug="-d,exchange_partition_abort_2";
+SET SESSION debug_dbug="+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_dbug="-d,exchange_partition_abort_3";
+SET SESSION debug_dbug="+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_dbug="-d,exchange_partition_abort_4";
+SET SESSION debug_dbug="+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_dbug="-d,exchange_partition_abort_5";
+SET SESSION debug_dbug="+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_dbug="-d,exchange_partition_abort_6";
+SET SESSION debug_dbug="+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_dbug="-d,exchange_partition_abort_7";
+SET SESSION debug_dbug="+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_dbug="-d,exchange_partition_abort_8";
+SET SESSION debug_dbug="+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_dbug="-d,exchange_partition_abort_9";
+SET SESSION debug_dbug="+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_dbug="-d,exchange_partition_fail_1";
+SET SESSION debug_dbug="+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_dbug="-d,exchange_partition_fail_2";
+SET SESSION debug_dbug="+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 "Internal error/check (Not system error)")
+# 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_dbug="-d,exchange_partition_fail_3";
+SET SESSION debug_dbug="+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_dbug="-d,exchange_partition_fail_4";
+SET SESSION debug_dbug="+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 "Internal error/check (Not system error)")
+# 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_dbug="-d,exchange_partition_fail_5";
+SET SESSION debug_dbug="+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_dbug="-d,exchange_partition_fail_6";
+SET SESSION debug_dbug="+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 "Internal error/check (Not system error)")
+# 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_dbug="-d,exchange_partition_fail_7";
+SET SESSION debug_dbug="+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_dbug="-d,exchange_partition_fail_8";
+SET SESSION debug_dbug="+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_dbug="-d,exchange_partition_fail_9";
diff --git a/mysql-test/suite/parts/r/partition_debug_innodb.result b/mysql-test/suite/parts/r/partition_debug_innodb.result
index 891091efd58..7ecd746077e 100644
--- a/mysql-test/suite/parts/r/partition_debug_innodb.result
+++ b/mysql-test/suite/parts/r/partition_debug_innodb.result
@@ -1,75 +1,4 @@
DROP TABLE IF EXISTS t1;
-#
-# Bug#12696518/Bug#11766879/60106:DIFF BETWEEN # OF INDEXES IN MYSQL
-# VS INNODB, PARTITONING, ON INDEX CREATE
-#
-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 SESSION debug_dbug = "+d,ha_partition_fail_final_add_index";
-ALTER TABLE t1 ADD INDEX (b);
-ERROR HY000: Table has no partition for value 0
-SHOW CREATE TABLE t1;
-Table Create Table
-t1 CREATE TABLE `t1` (
- `a` int(11) NOT NULL,
- `b` varchar(64) DEFAULT NULL,
- PRIMARY KEY (`a`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-/*!50100 PARTITION BY HASH (a)
-PARTITIONS 3 */
-SELECT * FROM t1;
-a b
-0 first row
-1 second row
-2 Third row
-3 row id 3
-4 4 row
-5 row5
-6 X 6 row
-7 Seventh row
-8 Last row
-FLUSH TABLES;
-CREATE INDEX new_index ON t1 (b);
-ERROR HY000: Table has no partition for value 0
-SHOW CREATE TABLE t1;
-Table Create Table
-t1 CREATE TABLE `t1` (
- `a` int(11) NOT NULL,
- `b` varchar(64) DEFAULT NULL,
- PRIMARY KEY (`a`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-/*!50100 PARTITION BY HASH (a)
-PARTITIONS 3 */
-SELECT * FROM t1;
-a b
-0 first row
-1 second row
-2 Third row
-3 row id 3
-4 4 row
-5 row5
-6 X 6 row
-7 Seventh row
-8 Last row
-SET SESSION debug_dbug = "-d,ha_partition_fail_final_add_index";
-SHOW CREATE TABLE t1;
-Table Create Table
-t1 CREATE TABLE `t1` (
- `a` int(11) NOT NULL,
- `b` varchar(64) DEFAULT NULL,
- PRIMARY KEY (`a`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-/*!50100 PARTITION BY HASH (a)
-PARTITIONS 3 */
-DROP TABLE t1;
call mtr.add_suppression("InnoDB: Warning: allocated tablespace .*, old maximum was");
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 ");
@@ -3922,7 +3851,6 @@ t1.par
# State after crash recovery
t1#P#p0.ibd
t1#P#p10.ibd
-t1#P#p20.ibd
t1.frm
t1.par
SHOW CREATE TABLE t1;
@@ -3933,8 +3861,7 @@ t1 CREATE TABLE `t1` (
) ENGINE=InnoDB DEFAULT CHARSET=latin1
/*!50100 PARTITION BY LIST (a)
(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB,
- PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19) ENGINE = InnoDB,
- PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29) ENGINE = InnoDB) */
+ PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */
SELECT * FROM t1;
a b
1 Original from partition p0
@@ -4055,6 +3982,8 @@ ALTER TABLE t1 REORGANIZE PARTITION p10 INTO
PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29));
ERROR HY000: Lost connection to MySQL server during query
# State after crash (before recovery)
+#sql-t1.frm
+#sql-t1.par
t1#P#p0.ibd
t1#P#p10#TMP#.ibd
t1#P#p10.ibd
@@ -5022,7 +4951,6 @@ ERROR HY000: Unknown error
# State after failure
t1#P#p0.ibd
t1#P#p10.ibd
-t1#P#p20.ibd
t1.frm
t1.par
SHOW CREATE TABLE t1;
@@ -5033,8 +4961,7 @@ t1 CREATE TABLE `t1` (
) ENGINE=InnoDB DEFAULT CHARSET=latin1
/*!50100 PARTITION BY LIST (a)
(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB,
- PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19) ENGINE = InnoDB,
- PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29) ENGINE = InnoDB) */
+ PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */
SELECT * FROM t1;
a b
1 Original from partition p0
@@ -5085,7 +5012,6 @@ ERROR HY000: Unknown error
# State after failure
t1#P#p0.ibd
t1#P#p10.ibd
-t1#P#p20.ibd
t1.frm
t1.par
SHOW CREATE TABLE t1;
@@ -5096,8 +5022,7 @@ t1 CREATE TABLE `t1` (
) ENGINE=InnoDB DEFAULT CHARSET=latin1
/*!50100 PARTITION BY LIST (a)
(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB,
- PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19) ENGINE = InnoDB,
- PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29) ENGINE = InnoDB) */
+ PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */
SELECT * FROM t1;
a b
1 Original from partition p0
@@ -5873,3 +5798,1836 @@ a b
UNLOCK TABLES;
DROP TABLE t1;
SET SESSION debug_dbug="-d,fail_change_partition_12";
+#
+# WL#4445: EXCHANGE PARTITION WITH TABLE
+# Verify ddl_log and InnoDB in case of crashing.
+call mtr.add_suppression("InnoDB: Warning: allocated tablespace .*, old maximum was ");
+call mtr.add_suppression("Attempting backtrace. You can use the following information to find out");
+call mtr.add_suppression("table .* does not exist in the InnoDB internal");
+SET SESSION debug_dbug="+d,exchange_partition_abort_1";
+CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = InnoDB;
+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=InnoDB 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))
+ENGINE = InnoDB
+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.ibd
+t1#P#p1.ibd
+t1.frm
+t1.par
+t2.frm
+t2.ibd
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` varchar(64) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10) ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
+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.ibd
+t1#P#p1.ibd
+t1.frm
+t1.par
+t2.frm
+t2.ibd
+# State after crash recovery
+t1#P#p0.ibd
+t1#P#p1.ibd
+t1.frm
+t1.par
+t2.frm
+t2.ibd
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` varchar(64) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10) ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
+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=InnoDB 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_dbug="-d,exchange_partition_abort_1";
+SET SESSION debug_dbug="+d,exchange_partition_abort_2";
+CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = InnoDB;
+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=InnoDB 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))
+ENGINE = InnoDB
+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.ibd
+t1#P#p1.ibd
+t1.frm
+t1.par
+t2.frm
+t2.ibd
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` varchar(64) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10) ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
+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.ibd
+t1#P#p1.ibd
+t1.frm
+t1.par
+t2.frm
+t2.ibd
+# State after crash recovery
+t1#P#p0.ibd
+t1#P#p1.ibd
+t1.frm
+t1.par
+t2.frm
+t2.ibd
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` varchar(64) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10) ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
+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=InnoDB 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_dbug="-d,exchange_partition_abort_2";
+SET SESSION debug_dbug="+d,exchange_partition_abort_3";
+CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = InnoDB;
+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=InnoDB 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))
+ENGINE = InnoDB
+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.ibd
+t1#P#p1.ibd
+t1.frm
+t1.par
+t2.frm
+t2.ibd
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` varchar(64) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10) ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
+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.ibd
+t1#P#p1.ibd
+t1.frm
+t1.par
+t2.frm
+t2.ibd
+# State after crash recovery
+t1#P#p0.ibd
+t1#P#p1.ibd
+t1.frm
+t1.par
+t2.frm
+t2.ibd
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` varchar(64) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10) ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
+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=InnoDB 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_dbug="-d,exchange_partition_abort_3";
+SET SESSION debug_dbug="+d,exchange_partition_abort_4";
+CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = InnoDB;
+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=InnoDB 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))
+ENGINE = InnoDB
+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.ibd
+t1#P#p1.ibd
+t1.frm
+t1.par
+t2.frm
+t2.ibd
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` varchar(64) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10) ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
+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.ibd
+t1#P#p0.ibd
+t1#P#p1.ibd
+t1.frm
+t1.par
+t2.frm
+# State after crash recovery
+t1#P#p0.ibd
+t1#P#p1.ibd
+t1.frm
+t1.par
+t2.frm
+t2.ibd
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` varchar(64) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10) ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
+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=InnoDB 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_dbug="-d,exchange_partition_abort_4";
+SET SESSION debug_dbug="+d,exchange_partition_abort_5";
+CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = InnoDB;
+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=InnoDB 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))
+ENGINE = InnoDB
+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.ibd
+t1#P#p1.ibd
+t1.frm
+t1.par
+t2.frm
+t2.ibd
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` varchar(64) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10) ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
+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.ibd
+t1#P#p0.ibd
+t1#P#p1.ibd
+t1.frm
+t1.par
+t2.frm
+# State after crash recovery
+t1#P#p0.ibd
+t1#P#p1.ibd
+t1.frm
+t1.par
+t2.frm
+t2.ibd
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` varchar(64) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10) ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
+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=InnoDB 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_dbug="-d,exchange_partition_abort_5";
+SET SESSION debug_dbug="+d,exchange_partition_abort_6";
+CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = InnoDB;
+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=InnoDB 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))
+ENGINE = InnoDB
+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.ibd
+t1#P#p1.ibd
+t1.frm
+t1.par
+t2.frm
+t2.ibd
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` varchar(64) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10) ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
+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.ibd
+t1#P#p1.ibd
+t1.frm
+t1.par
+t2.frm
+t2.ibd
+# State after crash recovery
+t1#P#p0.ibd
+t1#P#p1.ibd
+t1.frm
+t1.par
+t2.frm
+t2.ibd
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` varchar(64) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10) ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
+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=InnoDB 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_dbug="-d,exchange_partition_abort_6";
+SET SESSION debug_dbug="+d,exchange_partition_abort_7";
+CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = InnoDB;
+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=InnoDB 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))
+ENGINE = InnoDB
+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.ibd
+t1#P#p1.ibd
+t1.frm
+t1.par
+t2.frm
+t2.ibd
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` varchar(64) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10) ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
+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.ibd
+t1#P#p1.ibd
+t1.frm
+t1.par
+t2.frm
+t2.ibd
+# State after crash recovery
+t1#P#p0.ibd
+t1#P#p1.ibd
+t1.frm
+t1.par
+t2.frm
+t2.ibd
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` varchar(64) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10) ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
+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=InnoDB 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_dbug="-d,exchange_partition_abort_7";
+SET SESSION debug_dbug="+d,exchange_partition_abort_8";
+CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = InnoDB;
+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=InnoDB 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))
+ENGINE = InnoDB
+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.ibd
+t1#P#p1.ibd
+t1.frm
+t1.par
+t2.frm
+t2.ibd
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` varchar(64) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10) ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
+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.ibd
+t1#P#p1.ibd
+t1.frm
+t1.par
+t2.frm
+t2.ibd
+# State after crash recovery
+t1#P#p0.ibd
+t1#P#p1.ibd
+t1.frm
+t1.par
+t2.frm
+t2.ibd
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` varchar(64) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10) ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
+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=InnoDB 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_dbug="-d,exchange_partition_abort_8";
+SET SESSION debug_dbug="+d,exchange_partition_abort_9";
+CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = InnoDB;
+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=InnoDB 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))
+ENGINE = InnoDB
+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.ibd
+t1#P#p1.ibd
+t1.frm
+t1.par
+t2.frm
+t2.ibd
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` varchar(64) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10) ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
+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.ibd
+t1#P#p1.ibd
+t1.frm
+t1.par
+t2.frm
+t2.ibd
+# State after crash recovery
+t1#P#p0.ibd
+t1#P#p1.ibd
+t1.frm
+t1.par
+t2.frm
+t2.ibd
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` varchar(64) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10) ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
+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=InnoDB 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_dbug="-d,exchange_partition_abort_9";
+SET SESSION debug_dbug="+d,exchange_partition_fail_1";
+CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = InnoDB;
+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=InnoDB 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))
+ENGINE = InnoDB
+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.ibd
+t1#P#p1.ibd
+t1.frm
+t1.par
+t2.frm
+t2.ibd
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` varchar(64) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10) ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
+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.ibd
+t1#P#p1.ibd
+t1.frm
+t1.par
+t2.frm
+t2.ibd
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` varchar(64) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10) ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
+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=InnoDB 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_dbug="-d,exchange_partition_fail_1";
+SET SESSION debug_dbug="+d,exchange_partition_fail_2";
+CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = InnoDB;
+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=InnoDB 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))
+ENGINE = InnoDB
+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.ibd
+t1#P#p1.ibd
+t1.frm
+t1.par
+t2.frm
+t2.ibd
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` varchar(64) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10) ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
+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.ibd
+t1#P#p1.ibd
+t1.frm
+t1.par
+t2.frm
+t2.ibd
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` varchar(64) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10) ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
+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=InnoDB 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_dbug="-d,exchange_partition_fail_2";
+SET SESSION debug_dbug="+d,exchange_partition_fail_3";
+CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = InnoDB;
+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=InnoDB 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))
+ENGINE = InnoDB
+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.ibd
+t1#P#p1.ibd
+t1.frm
+t1.par
+t2.frm
+t2.ibd
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` varchar(64) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10) ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
+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 "Internal error/check (Not system error)")
+# State after failure
+t1#P#p0.ibd
+t1#P#p1.ibd
+t1.frm
+t1.par
+t2.frm
+t2.ibd
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` varchar(64) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10) ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
+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=InnoDB 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_dbug="-d,exchange_partition_fail_3";
+SET SESSION debug_dbug="+d,exchange_partition_fail_4";
+CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = InnoDB;
+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=InnoDB 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))
+ENGINE = InnoDB
+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.ibd
+t1#P#p1.ibd
+t1.frm
+t1.par
+t2.frm
+t2.ibd
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` varchar(64) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10) ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
+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.ibd
+t1#P#p1.ibd
+t1.frm
+t1.par
+t2.frm
+t2.ibd
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` varchar(64) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10) ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
+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=InnoDB 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_dbug="-d,exchange_partition_fail_4";
+SET SESSION debug_dbug="+d,exchange_partition_fail_5";
+CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = InnoDB;
+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=InnoDB 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))
+ENGINE = InnoDB
+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.ibd
+t1#P#p1.ibd
+t1.frm
+t1.par
+t2.frm
+t2.ibd
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` varchar(64) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10) ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
+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 "Internal error/check (Not system error)")
+# State after failure
+t1#P#p0.ibd
+t1#P#p1.ibd
+t1.frm
+t1.par
+t2.frm
+t2.ibd
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` varchar(64) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10) ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
+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=InnoDB 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_dbug="-d,exchange_partition_fail_5";
+SET SESSION debug_dbug="+d,exchange_partition_fail_6";
+CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = InnoDB;
+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=InnoDB 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))
+ENGINE = InnoDB
+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.ibd
+t1#P#p1.ibd
+t1.frm
+t1.par
+t2.frm
+t2.ibd
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` varchar(64) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10) ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
+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.ibd
+t1#P#p1.ibd
+t1.frm
+t1.par
+t2.frm
+t2.ibd
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` varchar(64) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10) ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
+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=InnoDB 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_dbug="-d,exchange_partition_fail_6";
+SET SESSION debug_dbug="+d,exchange_partition_fail_7";
+CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = InnoDB;
+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=InnoDB 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))
+ENGINE = InnoDB
+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.ibd
+t1#P#p1.ibd
+t1.frm
+t1.par
+t2.frm
+t2.ibd
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` varchar(64) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10) ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
+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 "Internal error/check (Not system error)")
+# State after failure
+t1#P#p0.ibd
+t1#P#p1.ibd
+t1.frm
+t1.par
+t2.frm
+t2.ibd
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` varchar(64) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10) ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
+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=InnoDB 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_dbug="-d,exchange_partition_fail_7";
+SET SESSION debug_dbug="+d,exchange_partition_fail_8";
+CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = InnoDB;
+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=InnoDB 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))
+ENGINE = InnoDB
+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.ibd
+t1#P#p1.ibd
+t1.frm
+t1.par
+t2.frm
+t2.ibd
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` varchar(64) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10) ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
+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.ibd
+t1#P#p1.ibd
+t1.frm
+t1.par
+t2.frm
+t2.ibd
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` varchar(64) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10) ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
+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=InnoDB 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_dbug="-d,exchange_partition_fail_8";
+SET SESSION debug_dbug="+d,exchange_partition_fail_9";
+CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = InnoDB;
+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=InnoDB 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))
+ENGINE = InnoDB
+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.ibd
+t1#P#p1.ibd
+t1.frm
+t1.par
+t2.frm
+t2.ibd
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` varchar(64) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10) ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
+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.ibd
+t1#P#p1.ibd
+t1.frm
+t1.par
+t2.frm
+t2.ibd
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` varchar(64) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10) ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
+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=InnoDB 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_dbug="-d,exchange_partition_fail_9";
diff --git a/mysql-test/suite/parts/r/partition_debug_myisam.result b/mysql-test/suite/parts/r/partition_debug_myisam.result
index 2411d58169e..8408f166e79 100644
--- a/mysql-test/suite/parts/r/partition_debug_myisam.result
+++ b/mysql-test/suite/parts/r/partition_debug_myisam.result
@@ -4151,8 +4151,6 @@ t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p10.MYD
t1#P#p10.MYI
-t1#P#p20.MYD
-t1#P#p20.MYI
t1.frm
t1.par
SHOW CREATE TABLE t1;
@@ -4163,8 +4161,7 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY LIST (a)
(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM,
- PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19) ENGINE = MyISAM,
- PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29) ENGINE = MyISAM) */
+ PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */
SELECT * FROM t1;
a b
1 Original from partition p0
@@ -4296,6 +4293,8 @@ ALTER TABLE t1 REORGANIZE PARTITION p10 INTO
PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29));
ERROR HY000: Lost connection to MySQL server during query
# State after crash (before recovery)
+#sql-t1.frm
+#sql-t1.par
t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p10#TMP#.MYD
@@ -5348,8 +5347,6 @@ t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p10.MYD
t1#P#p10.MYI
-t1#P#p20.MYD
-t1#P#p20.MYI
t1.frm
t1.par
SHOW CREATE TABLE t1;
@@ -5360,8 +5357,7 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY LIST (a)
(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM,
- PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19) ENGINE = MyISAM,
- PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29) ENGINE = MyISAM) */
+ PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */
SELECT * FROM t1;
a b
1 Original from partition p0
@@ -5416,8 +5412,6 @@ t1#P#p0.MYD
t1#P#p0.MYI
t1#P#p10.MYD
t1#P#p10.MYI
-t1#P#p20.MYD
-t1#P#p20.MYI
t1.frm
t1.par
SHOW CREATE TABLE t1;
@@ -5428,8 +5422,7 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY LIST (a)
(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM,
- PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19) ENGINE = MyISAM,
- PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29) ENGINE = MyISAM) */
+ PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */
SELECT * FROM t1;
a b
1 Original from partition p0
diff --git a/mysql-test/suite/parts/r/partition_engine_innodb.result b/mysql-test/suite/parts/r/partition_engine_innodb.result
index 5335983b560..8e5f7c43dd9 100644
--- a/mysql-test/suite/parts/r/partition_engine_innodb.result
+++ b/mysql-test/suite/parts/r/partition_engine_innodb.result
@@ -1,5 +1,5 @@
SET @max_row = 20;
-SET @@session.storage_engine = 'InnoDB';
+SET @@session.default_storage_engine = 'InnoDB';
#------------------------------------------------------------------------
# 0. Setting of auxiliary variables + Creation of an auxiliary tables
diff --git a/mysql-test/suite/parts/r/partition_engine_myisam.result b/mysql-test/suite/parts/r/partition_engine_myisam.result
index cfba8731b2f..e63f9ee2fff 100644
--- a/mysql-test/suite/parts/r/partition_engine_myisam.result
+++ b/mysql-test/suite/parts/r/partition_engine_myisam.result
@@ -1,5 +1,5 @@
SET @max_row = 20;
-SET @@session.storage_engine = 'MyISAM';
+SET @@session.default_storage_engine = 'MyISAM';
#------------------------------------------------------------------------
# 0. Setting of auxiliary variables + Creation of an auxiliary tables
diff --git a/mysql-test/suite/parts/r/partition_exch_innodb.result b/mysql-test/suite/parts/r/partition_exch_innodb.result
new file mode 100755
index 00000000000..d444e2e3558
--- /dev/null
+++ b/mysql-test/suite/parts/r/partition_exch_innodb.result
@@ -0,0 +1,355 @@
+use test;
+SELECT * FROM t_10;
+a b
+1 One
+3 Three
+5 Five
+9 Nine
+SELECT * FROM t_100;
+a b
+11 Eleven
+13 Thirdteen
+15 Fifeteen
+19 Nineteen
+91 Ninety-one
+93 Ninety-three
+95 Ninety-five
+99 Ninety-nine
+SELECT * FROM t_1000;
+a b
+111 Hundred elven
+113 Hundred thirdteen
+115 Hundred fiveteen
+119 Hundred nineteen
+131 Hundred thirty-one
+133 Hundred thirty-three
+135 Hundred thirty-five
+139 Hundred thirty-nine
+151 Hundred fifty-one
+153 Hundred fifty-three
+155 Hundred fity-five
+159 Hundred fifty-nine
+191 Hundred ninety-one
+193 Hundred ninety-three
+195 Hundred ninety-five
+199 Hundred ninety-nine
+SELECT * FROM tp;
+a b
+112 Hundred twelve
+114 Hundred fourteen
+116 Hundred sixteen
+118 Hundred eightteen
+12 twelve
+122 Hundred twenty-two
+124 Hundred twenty-four
+126 Hundred twenty-six
+128 Hundred twenty-eight
+14 Fourteen
+16 Sixteen
+162 Hundred sixty-two
+164 Hundred sixty-four
+166 Hundred sixty-six
+168 Hundred sixty-eight
+18 Eightteen
+182 Hundred eighty-two
+184 Hundred eighty-four
+186 Hundred eighty-six
+188 Hundred eighty-eight
+2 Two
+4 Four
+6 Six
+8 Eight
+SELECT * FROM tsp;
+a b
+112 Hundred twelve
+114 Hundred fourteen
+116 Hundred sixteen
+118 Hundred eightteen
+12 twelve
+122 Hundred twenty-two
+124 Hundred twenty-four
+126 Hundred twenty-six
+128 Hundred twenty-eight
+14 Fourteen
+16 Sixteen
+162 Hundred sixty-two
+164 Hundred sixty-four
+166 Hundred sixty-six
+168 Hundred sixty-eight
+18 Eightteen
+182 Hundred eight-two
+184 Hundred eighty-four
+186 Hundred eighty-six
+188 Hundred eighty-eight
+2 Two
+4 Four
+6 Six
+8 Eight
+SELECT * FROM tsp_00;
+a b
+5 Five
+SELECT * FROM tsp_01;
+a b
+1 One
+SELECT * FROM tsp_02;
+a b
+SELECT * FROM tsp_03;
+a b
+3 Three
+SELECT * FROM tsp_04;
+a b
+9 Nine
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+SELECT * FROM t_10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a b
+1 One
+3 Three
+5 Five
+9 Nine
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+SELECT * FROM t_10;
+a b
+1 One
+3 Three
+5 Five
+9 Nine
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_empty;
+SELECT * FROM t_empty;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a b
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_empty;
+SELECT * FROM t_empty;
+a b
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_null;
+SELECT * FROM t_null;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a b
+1 NULL
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_null;
+SELECT * FROM t_null;
+a b
+1 NULL
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+ALTER TABLE tp EXCHANGE PARTITION p1 WITH TABLE t_100;
+SELECT * FROM t_100;
+a b
+12 twelve
+14 Fourteen
+16 Sixteen
+18 Eightteen
+SELECT * FROM tp WHERE a BETWEEN 10 AND 100;
+a b
+11 Eleven
+13 Thirdteen
+15 Fifeteen
+19 Nineteen
+91 Ninety-one
+93 Ninety-three
+95 Ninety-five
+99 Ninety-nine
+ALTER TABLE tp EXCHANGE PARTITION p1 WITH TABLE t_100;
+SELECT * FROM t_100;
+a b
+11 Eleven
+13 Thirdteen
+15 Fifeteen
+19 Nineteen
+91 Ninety-one
+93 Ninety-three
+95 Ninety-five
+99 Ninety-nine
+SELECT * FROM tp WHERE a BETWEEN 10 AND 100;
+a b
+12 twelve
+14 Fourteen
+16 Sixteen
+18 Eightteen
+ALTER TABLE tp EXCHANGE PARTITION p2 WITH TABLE t_1000;
+SELECT * FROM t_1000;
+a b
+112 Hundred twelve
+114 Hundred fourteen
+116 Hundred sixteen
+118 Hundred eightteen
+122 Hundred twenty-two
+124 Hundred twenty-four
+126 Hundred twenty-six
+128 Hundred twenty-eight
+162 Hundred sixty-two
+164 Hundred sixty-four
+166 Hundred sixty-six
+168 Hundred sixty-eight
+182 Hundred eighty-two
+184 Hundred eighty-four
+186 Hundred eighty-six
+188 Hundred eighty-eight
+SELECT * FROM tp WHERE a BETWEEN 100 AND 1000;
+a b
+111 Hundred elven
+113 Hundred thirdteen
+115 Hundred fiveteen
+119 Hundred nineteen
+131 Hundred thirty-one
+133 Hundred thirty-three
+135 Hundred thirty-five
+139 Hundred thirty-nine
+151 Hundred fifty-one
+153 Hundred fifty-three
+155 Hundred fity-five
+159 Hundred fifty-nine
+191 Hundred ninety-one
+193 Hundred ninety-three
+195 Hundred ninety-five
+199 Hundred ninety-nine
+ALTER TABLE tp EXCHANGE PARTITION p2 WITH TABLE t_1000;
+SELECT * FROM t_1000;
+a b
+111 Hundred elven
+113 Hundred thirdteen
+115 Hundred fiveteen
+119 Hundred nineteen
+131 Hundred thirty-one
+133 Hundred thirty-three
+135 Hundred thirty-five
+139 Hundred thirty-nine
+151 Hundred fifty-one
+153 Hundred fifty-three
+155 Hundred fity-five
+159 Hundred fifty-nine
+191 Hundred ninety-one
+193 Hundred ninety-three
+195 Hundred ninety-five
+199 Hundred ninety-nine
+SELECT * FROM tp WHERE a BETWEEN 100 AND 1000;
+a b
+112 Hundred twelve
+114 Hundred fourteen
+116 Hundred sixteen
+118 Hundred eightteen
+122 Hundred twenty-two
+124 Hundred twenty-four
+126 Hundred twenty-six
+128 Hundred twenty-eight
+162 Hundred sixty-two
+164 Hundred sixty-four
+166 Hundred sixty-six
+168 Hundred sixty-eight
+182 Hundred eighty-two
+184 Hundred eighty-four
+186 Hundred eighty-six
+188 Hundred eighty-eight
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+ALTER TABLE tsp EXCHANGE PARTITION sp01 WITH TABLE tsp_01;
+ALTER TABLE tsp EXCHANGE PARTITION sp02 WITH TABLE tsp_02;
+ALTER TABLE tsp EXCHANGE PARTITION sp03 WITH TABLE tsp_03;
+ALTER TABLE tsp EXCHANGE PARTITION sp04 WITH TABLE tsp_04;
+SELECT * FROM tsp_00;
+a b
+SELECT * FROM tsp_01;
+a b
+6 Six
+SELECT * FROM tsp_02;
+a b
+2 Two
+SELECT * FROM tsp_03;
+a b
+8 Eight
+SELECT * FROM tsp_04;
+a b
+4 Four
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+a b
+1 One
+3 Three
+5 Five
+9 Nine
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+ALTER TABLE tsp EXCHANGE PARTITION sp01 WITH TABLE tsp_01;
+ALTER TABLE tsp EXCHANGE PARTITION sp02 WITH TABLE tsp_02;
+ALTER TABLE tsp EXCHANGE PARTITION sp03 WITH TABLE tsp_03;
+ALTER TABLE tsp EXCHANGE PARTITION sp04 WITH TABLE tsp_04;
+SELECT * FROM tsp_00;
+a b
+5 Five
+SELECT * FROM tsp_01;
+a b
+1 One
+SELECT * FROM tsp_02;
+a b
+SELECT * FROM tsp_03;
+a b
+3 Three
+SELECT * FROM tsp_04;
+a b
+9 Nine
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+ALTER TABLE tsp EXCHANGE PARTITION sp01 WITH TABLE t_null;
+SELECT * FROM t_null;
+a b
+6 Six
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+a b
+1 NULL
+2 Two
+4 Four
+8 Eight
+ALTER TABLE tsp EXCHANGE PARTITION sp01 WITH TABLE t_null;
+SELECT * FROM t_null;
+a b
+1 NULL
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
diff --git a/mysql-test/suite/parts/r/partition_exch_myisam.result b/mysql-test/suite/parts/r/partition_exch_myisam.result
new file mode 100755
index 00000000000..d444e2e3558
--- /dev/null
+++ b/mysql-test/suite/parts/r/partition_exch_myisam.result
@@ -0,0 +1,355 @@
+use test;
+SELECT * FROM t_10;
+a b
+1 One
+3 Three
+5 Five
+9 Nine
+SELECT * FROM t_100;
+a b
+11 Eleven
+13 Thirdteen
+15 Fifeteen
+19 Nineteen
+91 Ninety-one
+93 Ninety-three
+95 Ninety-five
+99 Ninety-nine
+SELECT * FROM t_1000;
+a b
+111 Hundred elven
+113 Hundred thirdteen
+115 Hundred fiveteen
+119 Hundred nineteen
+131 Hundred thirty-one
+133 Hundred thirty-three
+135 Hundred thirty-five
+139 Hundred thirty-nine
+151 Hundred fifty-one
+153 Hundred fifty-three
+155 Hundred fity-five
+159 Hundred fifty-nine
+191 Hundred ninety-one
+193 Hundred ninety-three
+195 Hundred ninety-five
+199 Hundred ninety-nine
+SELECT * FROM tp;
+a b
+112 Hundred twelve
+114 Hundred fourteen
+116 Hundred sixteen
+118 Hundred eightteen
+12 twelve
+122 Hundred twenty-two
+124 Hundred twenty-four
+126 Hundred twenty-six
+128 Hundred twenty-eight
+14 Fourteen
+16 Sixteen
+162 Hundred sixty-two
+164 Hundred sixty-four
+166 Hundred sixty-six
+168 Hundred sixty-eight
+18 Eightteen
+182 Hundred eighty-two
+184 Hundred eighty-four
+186 Hundred eighty-six
+188 Hundred eighty-eight
+2 Two
+4 Four
+6 Six
+8 Eight
+SELECT * FROM tsp;
+a b
+112 Hundred twelve
+114 Hundred fourteen
+116 Hundred sixteen
+118 Hundred eightteen
+12 twelve
+122 Hundred twenty-two
+124 Hundred twenty-four
+126 Hundred twenty-six
+128 Hundred twenty-eight
+14 Fourteen
+16 Sixteen
+162 Hundred sixty-two
+164 Hundred sixty-four
+166 Hundred sixty-six
+168 Hundred sixty-eight
+18 Eightteen
+182 Hundred eight-two
+184 Hundred eighty-four
+186 Hundred eighty-six
+188 Hundred eighty-eight
+2 Two
+4 Four
+6 Six
+8 Eight
+SELECT * FROM tsp_00;
+a b
+5 Five
+SELECT * FROM tsp_01;
+a b
+1 One
+SELECT * FROM tsp_02;
+a b
+SELECT * FROM tsp_03;
+a b
+3 Three
+SELECT * FROM tsp_04;
+a b
+9 Nine
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+SELECT * FROM t_10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a b
+1 One
+3 Three
+5 Five
+9 Nine
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+SELECT * FROM t_10;
+a b
+1 One
+3 Three
+5 Five
+9 Nine
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_empty;
+SELECT * FROM t_empty;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a b
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_empty;
+SELECT * FROM t_empty;
+a b
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_null;
+SELECT * FROM t_null;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a b
+1 NULL
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_null;
+SELECT * FROM t_null;
+a b
+1 NULL
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+ALTER TABLE tp EXCHANGE PARTITION p1 WITH TABLE t_100;
+SELECT * FROM t_100;
+a b
+12 twelve
+14 Fourteen
+16 Sixteen
+18 Eightteen
+SELECT * FROM tp WHERE a BETWEEN 10 AND 100;
+a b
+11 Eleven
+13 Thirdteen
+15 Fifeteen
+19 Nineteen
+91 Ninety-one
+93 Ninety-three
+95 Ninety-five
+99 Ninety-nine
+ALTER TABLE tp EXCHANGE PARTITION p1 WITH TABLE t_100;
+SELECT * FROM t_100;
+a b
+11 Eleven
+13 Thirdteen
+15 Fifeteen
+19 Nineteen
+91 Ninety-one
+93 Ninety-three
+95 Ninety-five
+99 Ninety-nine
+SELECT * FROM tp WHERE a BETWEEN 10 AND 100;
+a b
+12 twelve
+14 Fourteen
+16 Sixteen
+18 Eightteen
+ALTER TABLE tp EXCHANGE PARTITION p2 WITH TABLE t_1000;
+SELECT * FROM t_1000;
+a b
+112 Hundred twelve
+114 Hundred fourteen
+116 Hundred sixteen
+118 Hundred eightteen
+122 Hundred twenty-two
+124 Hundred twenty-four
+126 Hundred twenty-six
+128 Hundred twenty-eight
+162 Hundred sixty-two
+164 Hundred sixty-four
+166 Hundred sixty-six
+168 Hundred sixty-eight
+182 Hundred eighty-two
+184 Hundred eighty-four
+186 Hundred eighty-six
+188 Hundred eighty-eight
+SELECT * FROM tp WHERE a BETWEEN 100 AND 1000;
+a b
+111 Hundred elven
+113 Hundred thirdteen
+115 Hundred fiveteen
+119 Hundred nineteen
+131 Hundred thirty-one
+133 Hundred thirty-three
+135 Hundred thirty-five
+139 Hundred thirty-nine
+151 Hundred fifty-one
+153 Hundred fifty-three
+155 Hundred fity-five
+159 Hundred fifty-nine
+191 Hundred ninety-one
+193 Hundred ninety-three
+195 Hundred ninety-five
+199 Hundred ninety-nine
+ALTER TABLE tp EXCHANGE PARTITION p2 WITH TABLE t_1000;
+SELECT * FROM t_1000;
+a b
+111 Hundred elven
+113 Hundred thirdteen
+115 Hundred fiveteen
+119 Hundred nineteen
+131 Hundred thirty-one
+133 Hundred thirty-three
+135 Hundred thirty-five
+139 Hundred thirty-nine
+151 Hundred fifty-one
+153 Hundred fifty-three
+155 Hundred fity-five
+159 Hundred fifty-nine
+191 Hundred ninety-one
+193 Hundred ninety-three
+195 Hundred ninety-five
+199 Hundred ninety-nine
+SELECT * FROM tp WHERE a BETWEEN 100 AND 1000;
+a b
+112 Hundred twelve
+114 Hundred fourteen
+116 Hundred sixteen
+118 Hundred eightteen
+122 Hundred twenty-two
+124 Hundred twenty-four
+126 Hundred twenty-six
+128 Hundred twenty-eight
+162 Hundred sixty-two
+164 Hundred sixty-four
+166 Hundred sixty-six
+168 Hundred sixty-eight
+182 Hundred eighty-two
+184 Hundred eighty-four
+186 Hundred eighty-six
+188 Hundred eighty-eight
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+ALTER TABLE tsp EXCHANGE PARTITION sp01 WITH TABLE tsp_01;
+ALTER TABLE tsp EXCHANGE PARTITION sp02 WITH TABLE tsp_02;
+ALTER TABLE tsp EXCHANGE PARTITION sp03 WITH TABLE tsp_03;
+ALTER TABLE tsp EXCHANGE PARTITION sp04 WITH TABLE tsp_04;
+SELECT * FROM tsp_00;
+a b
+SELECT * FROM tsp_01;
+a b
+6 Six
+SELECT * FROM tsp_02;
+a b
+2 Two
+SELECT * FROM tsp_03;
+a b
+8 Eight
+SELECT * FROM tsp_04;
+a b
+4 Four
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+a b
+1 One
+3 Three
+5 Five
+9 Nine
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+ALTER TABLE tsp EXCHANGE PARTITION sp01 WITH TABLE tsp_01;
+ALTER TABLE tsp EXCHANGE PARTITION sp02 WITH TABLE tsp_02;
+ALTER TABLE tsp EXCHANGE PARTITION sp03 WITH TABLE tsp_03;
+ALTER TABLE tsp EXCHANGE PARTITION sp04 WITH TABLE tsp_04;
+SELECT * FROM tsp_00;
+a b
+5 Five
+SELECT * FROM tsp_01;
+a b
+1 One
+SELECT * FROM tsp_02;
+a b
+SELECT * FROM tsp_03;
+a b
+3 Three
+SELECT * FROM tsp_04;
+a b
+9 Nine
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+ALTER TABLE tsp EXCHANGE PARTITION sp01 WITH TABLE t_null;
+SELECT * FROM t_null;
+a b
+6 Six
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+a b
+1 NULL
+2 Two
+4 Four
+8 Eight
+ALTER TABLE tsp EXCHANGE PARTITION sp01 WITH TABLE t_null;
+SELECT * FROM t_null;
+a b
+1 NULL
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
diff --git a/mysql-test/suite/parts/r/partition_exch_myisam_innodb.result b/mysql-test/suite/parts/r/partition_exch_myisam_innodb.result
new file mode 100755
index 00000000000..9ff4afcfe35
--- /dev/null
+++ b/mysql-test/suite/parts/r/partition_exch_myisam_innodb.result
@@ -0,0 +1,14 @@
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR HY000: The mix of handlers in the partitions is not allowed in this version of MariaDB
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
diff --git a/mysql-test/suite/parts/r/partition_exch_qa.result b/mysql-test/suite/parts/r/partition_exch_qa.result
new file mode 100755
index 00000000000..d444e2e3558
--- /dev/null
+++ b/mysql-test/suite/parts/r/partition_exch_qa.result
@@ -0,0 +1,355 @@
+use test;
+SELECT * FROM t_10;
+a b
+1 One
+3 Three
+5 Five
+9 Nine
+SELECT * FROM t_100;
+a b
+11 Eleven
+13 Thirdteen
+15 Fifeteen
+19 Nineteen
+91 Ninety-one
+93 Ninety-three
+95 Ninety-five
+99 Ninety-nine
+SELECT * FROM t_1000;
+a b
+111 Hundred elven
+113 Hundred thirdteen
+115 Hundred fiveteen
+119 Hundred nineteen
+131 Hundred thirty-one
+133 Hundred thirty-three
+135 Hundred thirty-five
+139 Hundred thirty-nine
+151 Hundred fifty-one
+153 Hundred fifty-three
+155 Hundred fity-five
+159 Hundred fifty-nine
+191 Hundred ninety-one
+193 Hundred ninety-three
+195 Hundred ninety-five
+199 Hundred ninety-nine
+SELECT * FROM tp;
+a b
+112 Hundred twelve
+114 Hundred fourteen
+116 Hundred sixteen
+118 Hundred eightteen
+12 twelve
+122 Hundred twenty-two
+124 Hundred twenty-four
+126 Hundred twenty-six
+128 Hundred twenty-eight
+14 Fourteen
+16 Sixteen
+162 Hundred sixty-two
+164 Hundred sixty-four
+166 Hundred sixty-six
+168 Hundred sixty-eight
+18 Eightteen
+182 Hundred eighty-two
+184 Hundred eighty-four
+186 Hundred eighty-six
+188 Hundred eighty-eight
+2 Two
+4 Four
+6 Six
+8 Eight
+SELECT * FROM tsp;
+a b
+112 Hundred twelve
+114 Hundred fourteen
+116 Hundred sixteen
+118 Hundred eightteen
+12 twelve
+122 Hundred twenty-two
+124 Hundred twenty-four
+126 Hundred twenty-six
+128 Hundred twenty-eight
+14 Fourteen
+16 Sixteen
+162 Hundred sixty-two
+164 Hundred sixty-four
+166 Hundred sixty-six
+168 Hundred sixty-eight
+18 Eightteen
+182 Hundred eight-two
+184 Hundred eighty-four
+186 Hundred eighty-six
+188 Hundred eighty-eight
+2 Two
+4 Four
+6 Six
+8 Eight
+SELECT * FROM tsp_00;
+a b
+5 Five
+SELECT * FROM tsp_01;
+a b
+1 One
+SELECT * FROM tsp_02;
+a b
+SELECT * FROM tsp_03;
+a b
+3 Three
+SELECT * FROM tsp_04;
+a b
+9 Nine
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+SELECT * FROM t_10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a b
+1 One
+3 Three
+5 Five
+9 Nine
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+SELECT * FROM t_10;
+a b
+1 One
+3 Three
+5 Five
+9 Nine
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_empty;
+SELECT * FROM t_empty;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a b
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_empty;
+SELECT * FROM t_empty;
+a b
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_null;
+SELECT * FROM t_null;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a b
+1 NULL
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_null;
+SELECT * FROM t_null;
+a b
+1 NULL
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+ALTER TABLE tp EXCHANGE PARTITION p1 WITH TABLE t_100;
+SELECT * FROM t_100;
+a b
+12 twelve
+14 Fourteen
+16 Sixteen
+18 Eightteen
+SELECT * FROM tp WHERE a BETWEEN 10 AND 100;
+a b
+11 Eleven
+13 Thirdteen
+15 Fifeteen
+19 Nineteen
+91 Ninety-one
+93 Ninety-three
+95 Ninety-five
+99 Ninety-nine
+ALTER TABLE tp EXCHANGE PARTITION p1 WITH TABLE t_100;
+SELECT * FROM t_100;
+a b
+11 Eleven
+13 Thirdteen
+15 Fifeteen
+19 Nineteen
+91 Ninety-one
+93 Ninety-three
+95 Ninety-five
+99 Ninety-nine
+SELECT * FROM tp WHERE a BETWEEN 10 AND 100;
+a b
+12 twelve
+14 Fourteen
+16 Sixteen
+18 Eightteen
+ALTER TABLE tp EXCHANGE PARTITION p2 WITH TABLE t_1000;
+SELECT * FROM t_1000;
+a b
+112 Hundred twelve
+114 Hundred fourteen
+116 Hundred sixteen
+118 Hundred eightteen
+122 Hundred twenty-two
+124 Hundred twenty-four
+126 Hundred twenty-six
+128 Hundred twenty-eight
+162 Hundred sixty-two
+164 Hundred sixty-four
+166 Hundred sixty-six
+168 Hundred sixty-eight
+182 Hundred eighty-two
+184 Hundred eighty-four
+186 Hundred eighty-six
+188 Hundred eighty-eight
+SELECT * FROM tp WHERE a BETWEEN 100 AND 1000;
+a b
+111 Hundred elven
+113 Hundred thirdteen
+115 Hundred fiveteen
+119 Hundred nineteen
+131 Hundred thirty-one
+133 Hundred thirty-three
+135 Hundred thirty-five
+139 Hundred thirty-nine
+151 Hundred fifty-one
+153 Hundred fifty-three
+155 Hundred fity-five
+159 Hundred fifty-nine
+191 Hundred ninety-one
+193 Hundred ninety-three
+195 Hundred ninety-five
+199 Hundred ninety-nine
+ALTER TABLE tp EXCHANGE PARTITION p2 WITH TABLE t_1000;
+SELECT * FROM t_1000;
+a b
+111 Hundred elven
+113 Hundred thirdteen
+115 Hundred fiveteen
+119 Hundred nineteen
+131 Hundred thirty-one
+133 Hundred thirty-three
+135 Hundred thirty-five
+139 Hundred thirty-nine
+151 Hundred fifty-one
+153 Hundred fifty-three
+155 Hundred fity-five
+159 Hundred fifty-nine
+191 Hundred ninety-one
+193 Hundred ninety-three
+195 Hundred ninety-five
+199 Hundred ninety-nine
+SELECT * FROM tp WHERE a BETWEEN 100 AND 1000;
+a b
+112 Hundred twelve
+114 Hundred fourteen
+116 Hundred sixteen
+118 Hundred eightteen
+122 Hundred twenty-two
+124 Hundred twenty-four
+126 Hundred twenty-six
+128 Hundred twenty-eight
+162 Hundred sixty-two
+164 Hundred sixty-four
+166 Hundred sixty-six
+168 Hundred sixty-eight
+182 Hundred eighty-two
+184 Hundred eighty-four
+186 Hundred eighty-six
+188 Hundred eighty-eight
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+ALTER TABLE tsp EXCHANGE PARTITION sp01 WITH TABLE tsp_01;
+ALTER TABLE tsp EXCHANGE PARTITION sp02 WITH TABLE tsp_02;
+ALTER TABLE tsp EXCHANGE PARTITION sp03 WITH TABLE tsp_03;
+ALTER TABLE tsp EXCHANGE PARTITION sp04 WITH TABLE tsp_04;
+SELECT * FROM tsp_00;
+a b
+SELECT * FROM tsp_01;
+a b
+6 Six
+SELECT * FROM tsp_02;
+a b
+2 Two
+SELECT * FROM tsp_03;
+a b
+8 Eight
+SELECT * FROM tsp_04;
+a b
+4 Four
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+a b
+1 One
+3 Three
+5 Five
+9 Nine
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+ALTER TABLE tsp EXCHANGE PARTITION sp01 WITH TABLE tsp_01;
+ALTER TABLE tsp EXCHANGE PARTITION sp02 WITH TABLE tsp_02;
+ALTER TABLE tsp EXCHANGE PARTITION sp03 WITH TABLE tsp_03;
+ALTER TABLE tsp EXCHANGE PARTITION sp04 WITH TABLE tsp_04;
+SELECT * FROM tsp_00;
+a b
+5 Five
+SELECT * FROM tsp_01;
+a b
+1 One
+SELECT * FROM tsp_02;
+a b
+SELECT * FROM tsp_03;
+a b
+3 Three
+SELECT * FROM tsp_04;
+a b
+9 Nine
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+ALTER TABLE tsp EXCHANGE PARTITION sp01 WITH TABLE t_null;
+SELECT * FROM t_null;
+a b
+6 Six
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+a b
+1 NULL
+2 Two
+4 Four
+8 Eight
+ALTER TABLE tsp EXCHANGE PARTITION sp01 WITH TABLE t_null;
+SELECT * FROM t_null;
+a b
+1 NULL
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
diff --git a/mysql-test/suite/parts/r/partition_exch_qa_10.result b/mysql-test/suite/parts/r/partition_exch_qa_10.result
new file mode 100755
index 00000000000..77b91f19e8f
--- /dev/null
+++ b/mysql-test/suite/parts/r/partition_exch_qa_10.result
@@ -0,0 +1,70 @@
+use test;
+CREATE PROCEDURE test_p1 ()
+BEGIN
+ALTER TABLE t_10 ADD UNIQUE INDEX USING BTREE (a);
+ALTER TABLE tp ADD UNIQUE INDEX USING BTREE (a);
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ALTER TABLE tp DROP INDEX a;
+ALTER TABLE t_10 DROP INDEX a;
+END|
+CALL test_p1;
+SELECT * FROM t_10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+SELECT * FROM tp WHERE a BETWEEN 0 AND 9;
+a b
+1 One
+3 Three
+5 Five
+9 Nine
+DROP PROCEDURE test_p1;
+SET @save_autocommit= @@autocommit;
+SET @@autocommit= OFF;
+SHOW VARIABLES LIKE '%autocommit%';
+Variable_name Value
+autocommit OFF
+CREATE TRIGGER test_trg_1 BEFORE UPDATE ON tp FOR EACH ROW
+BEGIN
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+END|
+ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
+CREATE FUNCTION test_f_1() RETURNS int
+BEGIN
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+END|
+ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
+SET @@autocommit= @save_autocommit;
+SET @save_event_scheduler= @@global.event_scheduler;
+SET @@global.event_scheduler= ON;
+CREATE EVENT test_ev_1
+ON SCHEDULE AT CURRENT_TIMESTAMP
+DO
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+SELECT * FROM t_10;
+a b
+1 One
+3 Three
+5 Five
+9 Nine
+SELECT * FROM tp WHERE a BETWEEN 0 AND 9;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+SET @@global.event_scheduler= @save_event_scheduler;
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
diff --git a/mysql-test/suite/parts/r/partition_exch_qa_11.result b/mysql-test/suite/parts/r/partition_exch_qa_11.result
new file mode 100755
index 00000000000..2fe6c05e29c
--- /dev/null
+++ b/mysql-test/suite/parts/r/partition_exch_qa_11.result
@@ -0,0 +1,56 @@
+use test;
+SET @part= 'p0';
+SET @part_tab= 'tp';
+SET @table= 't_10';
+SET @s= CONCAT('ALTER TABLE ',@part_tab,' EXCHANGE PARTITION ',@part,' WITH TABLE ',@table);
+PREPARE test_stmt1 FROM @s;
+EXECUTE test_stmt1;
+SELECT * FROM t_10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+SELECT * FROM tp;
+a b
+1 One
+112 Hundred twelve
+114 Hundred fourteen
+116 Hundred sixteen
+118 Hundred eightteen
+12 twelve
+122 Hundred twenty-two
+124 Hundred twenty-four
+126 Hundred twenty-six
+128 Hundred twenty-eight
+14 Fourteen
+16 Sixteen
+162 Hundred sixty-two
+164 Hundred sixty-four
+166 Hundred sixty-six
+168 Hundred sixty-eight
+18 Eightteen
+182 Hundred eighty-two
+184 Hundred eighty-four
+186 Hundred eighty-six
+188 Hundred eighty-eight
+3 Three
+5 Five
+9 Nine
+DEALLOCATE PREPARE test_stmt1;
+SET @part_tab= 'tp';
+SET @s= CONCAT('ALTER TABLE ',@part_tab,' EXCHANGE PARTITION ? WITH TABLE ?');
+PREPARE test_stmt2 FROM @s;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '? WITH TABLE ?' at line 1
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
diff --git a/mysql-test/suite/parts/r/partition_exch_qa_12.result b/mysql-test/suite/parts/r/partition_exch_qa_12.result
new file mode 100644
index 00000000000..32e0721e48f
--- /dev/null
+++ b/mysql-test/suite/parts/r/partition_exch_qa_12.result
@@ -0,0 +1,123 @@
+use test;
+SELECT * FROM t_10;
+a b
+1 One
+3 Three
+5 Five
+9 Nine
+SELECT * FROM t_100;
+a b
+11 Eleven
+13 Thirdteen
+15 Fifeteen
+19 Nineteen
+91 Ninety-one
+93 Ninety-three
+95 Ninety-five
+99 Ninety-nine
+SELECT * FROM t_1000;
+a b
+111 Hundred elven
+113 Hundred thirdteen
+115 Hundred fiveteen
+119 Hundred nineteen
+131 Hundred thirty-one
+133 Hundred thirty-three
+135 Hundred thirty-five
+139 Hundred thirty-nine
+151 Hundred fifty-one
+153 Hundred fifty-three
+155 Hundred fity-five
+159 Hundred fifty-nine
+191 Hundred ninety-one
+193 Hundred ninety-three
+195 Hundred ninety-five
+199 Hundred ninety-nine
+SELECT * FROM tp;
+a b
+112 Hundred twelve
+114 Hundred fourteen
+116 Hundred sixteen
+118 Hundred eightteen
+12 twelve
+122 Hundred twenty-two
+124 Hundred twenty-four
+126 Hundred twenty-six
+128 Hundred twenty-eight
+14 Fourteen
+16 Sixteen
+162 Hundred sixty-two
+164 Hundred sixty-four
+166 Hundred sixty-six
+168 Hundred sixty-eight
+18 Eightteen
+182 Hundred eighty-two
+184 Hundred eighty-four
+186 Hundred eighty-six
+188 Hundred eighty-eight
+2 Two
+4 Four
+6 Six
+8 Eight
+SELECT * FROM tsp;
+a b
+112 Hundred twelve
+114 Hundred fourteen
+116 Hundred sixteen
+118 Hundred eightteen
+12 twelve
+122 Hundred twenty-two
+124 Hundred twenty-four
+126 Hundred twenty-six
+128 Hundred twenty-eight
+14 Fourteen
+16 Sixteen
+162 Hundred sixty-two
+164 Hundred sixty-four
+166 Hundred sixty-six
+168 Hundred sixty-eight
+18 Eightteen
+182 Hundred eight-two
+184 Hundred eighty-four
+186 Hundred eighty-six
+188 Hundred eighty-eight
+2 Two
+4 Four
+6 Six
+8 Eight
+SELECT * FROM tsp_00;
+a b
+5 Five
+SELECT * FROM tsp_01;
+a b
+1 One
+SELECT * FROM tsp_02;
+a b
+SELECT * FROM tsp_03;
+a b
+3 Three
+SELECT * FROM tsp_04;
+a b
+9 Nine
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR HY000: Tables have different definitions
+SELECT TABLE_NAME, ROW_FORMAT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'test'
+AND TABLE_NAME IN ('tp', 't_100');
+TABLE_NAME ROW_FORMAT
+t_100 Dynamic
+tp Dynamic
+ALTER TABLE tp EXCHANGE PARTITION p1 WITH TABLE t_100;
+ALTER TABLE tp EXCHANGE PARTITION p1 WITH TABLE t_1000;
+ERROR HY000: Non matching attribute 'MAX_ROWS' between partition and table
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
diff --git a/mysql-test/suite/parts/r/partition_exch_qa_13.result b/mysql-test/suite/parts/r/partition_exch_qa_13.result
new file mode 100644
index 00000000000..476f33c0d47
--- /dev/null
+++ b/mysql-test/suite/parts/r/partition_exch_qa_13.result
@@ -0,0 +1,203 @@
+use test;
+SELECT * FROM t_10;
+a b
+1 One
+3 Three
+5 Five
+9 Nine
+SELECT * FROM t_100;
+a b
+11 Eleven
+13 Thirdteen
+15 Fifeteen
+19 Nineteen
+91 Ninety-one
+93 Ninety-three
+95 Ninety-five
+99 Ninety-nine
+SELECT * FROM t_1000;
+a b
+111 Hundred elven
+113 Hundred thirdteen
+115 Hundred fiveteen
+119 Hundred nineteen
+131 Hundred thirty-one
+133 Hundred thirty-three
+135 Hundred thirty-five
+139 Hundred thirty-nine
+151 Hundred fifty-one
+153 Hundred fifty-three
+155 Hundred fity-five
+159 Hundred fifty-nine
+191 Hundred ninety-one
+193 Hundred ninety-three
+195 Hundred ninety-five
+199 Hundred ninety-nine
+SELECT * FROM tp;
+a b
+112 Hundred twelve
+114 Hundred fourteen
+116 Hundred sixteen
+118 Hundred eightteen
+12 twelve
+122 Hundred twenty-two
+124 Hundred twenty-four
+126 Hundred twenty-six
+128 Hundred twenty-eight
+14 Fourteen
+16 Sixteen
+162 Hundred sixty-two
+164 Hundred sixty-four
+166 Hundred sixty-six
+168 Hundred sixty-eight
+18 Eightteen
+182 Hundred eighty-two
+184 Hundred eighty-four
+186 Hundred eighty-six
+188 Hundred eighty-eight
+2 Two
+4 Four
+6 Six
+8 Eight
+SELECT * FROM tsp;
+a b
+112 Hundred twelve
+114 Hundred fourteen
+116 Hundred sixteen
+118 Hundred eightteen
+12 twelve
+122 Hundred twenty-two
+124 Hundred twenty-four
+126 Hundred twenty-six
+128 Hundred twenty-eight
+14 Fourteen
+16 Sixteen
+162 Hundred sixty-two
+164 Hundred sixty-four
+166 Hundred sixty-six
+168 Hundred sixty-eight
+18 Eightteen
+182 Hundred eight-two
+184 Hundred eighty-four
+186 Hundred eighty-six
+188 Hundred eighty-eight
+2 Two
+4 Four
+6 Six
+8 Eight
+SELECT * FROM tsp_00;
+a b
+5 Five
+SELECT * FROM tsp_01;
+a b
+1 One
+SELECT * FROM tsp_02;
+a b
+SELECT * FROM tsp_03;
+a b
+3 Three
+SELECT * FROM tsp_04;
+a b
+9 Nine
+INSERT INTO t_10 VALUES (10, "TEN");
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR HY000: Found a row that does not match the partition
+SELECT * FROM tp WHERE a < 11;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+SELECT * FROM t_10 WHERE a < 11;
+a b
+1 One
+10 TEN
+3 Three
+5 Five
+9 Nine
+INSERT INTO t_1000 VALUES (99, "Ninetynine");
+ALTER TABLE tp1 EXCHANGE PARTITION p2 WITH TABLE t_1000;
+ERROR HY000: Found a row that does not match the partition
+SELECT * FROM tp1 WHERE a < 1000 AND a > 98;
+a b
+112 Hundred twelve
+114 Hundred fourteen
+116 Hundred sixteen
+118 Hundred eightteen
+122 Hundred twenty-two
+124 Hundred twenty-four
+126 Hundred twenty-six
+128 Hundred twenty-eight
+162 Hundred sixty-two
+164 Hundred sixty-four
+166 Hundred sixty-six
+168 Hundred sixty-eight
+182 Hundred eighty-two
+184 Hundred eighty-four
+186 Hundred eighty-six
+188 Hundred eighty-eight
+SELECT * FROM t_1000 WHERE a < 1000 AND a > 98;
+a b
+111 Hundred elven
+113 Hundred thirdteen
+115 Hundred fiveteen
+119 Hundred nineteen
+131 Hundred thirty-one
+133 Hundred thirty-three
+135 Hundred thirty-five
+139 Hundred thirty-nine
+151 Hundred fifty-one
+153 Hundred fifty-three
+155 Hundred fity-five
+159 Hundred fifty-nine
+191 Hundred ninety-one
+193 Hundred ninety-three
+195 Hundred ninety-five
+199 Hundred ninety-nine
+99 Ninetynine
+INSERT INTO tsp_03 VALUES (20, "Twenty");
+ALTER TABLE tsp EXCHANGE PARTITION sp03 WITH TABLE tsp_03;
+ERROR HY000: Found a row that does not match the partition
+SELECT * FROM tsp;
+a b
+112 Hundred twelve
+114 Hundred fourteen
+116 Hundred sixteen
+118 Hundred eightteen
+12 twelve
+122 Hundred twenty-two
+124 Hundred twenty-four
+126 Hundred twenty-six
+128 Hundred twenty-eight
+14 Fourteen
+16 Sixteen
+162 Hundred sixty-two
+164 Hundred sixty-four
+166 Hundred sixty-six
+168 Hundred sixty-eight
+18 Eightteen
+182 Hundred eight-two
+184 Hundred eighty-four
+186 Hundred eighty-six
+188 Hundred eighty-eight
+2 Two
+4 Four
+6 Six
+8 Eight
+SELECT * FROM tsp_03;
+a b
+20 Twenty
+3 Three
+DROP TABLE tp1;
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
diff --git a/mysql-test/suite/parts/r/partition_exch_qa_14.result b/mysql-test/suite/parts/r/partition_exch_qa_14.result
new file mode 100755
index 00000000000..f6866727184
--- /dev/null
+++ b/mysql-test/suite/parts/r/partition_exch_qa_14.result
@@ -0,0 +1,45 @@
+use test;
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR HY000: Tables have different definitions
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
+use test;
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR HY000: Tables have different definitions
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
+use test;
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR HY000: Tables have different definitions
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
diff --git a/mysql-test/suite/parts/r/partition_exch_qa_15.result b/mysql-test/suite/parts/r/partition_exch_qa_15.result
new file mode 100644
index 00000000000..87671a74253
--- /dev/null
+++ b/mysql-test/suite/parts/r/partition_exch_qa_15.result
@@ -0,0 +1,19 @@
+use test;
+CREATE TABLE t_11 (a INT, b VARCHAR(55),
+FOREIGN KEY (a) REFERENCES t_10 (a) ON DELETE CASCADE)
+ENGINE= InnoDB;
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_11;
+ERROR HY000: Table to exchange with partition has foreign key references: 't_11'
+DROP TABLE IF EXISTS t_11;
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
diff --git a/mysql-test/suite/parts/r/partition_exch_qa_1_innodb.result b/mysql-test/suite/parts/r/partition_exch_qa_1_innodb.result
new file mode 100644
index 00000000000..574518bff38
--- /dev/null
+++ b/mysql-test/suite/parts/r/partition_exch_qa_1_innodb.result
@@ -0,0 +1,171 @@
+use test;
+SELECT * FROM t_10;
+a b
+1 One
+3 Three
+5 Five
+9 Nine
+SELECT * FROM t_100;
+a b
+11 Eleven
+13 Thirdteen
+15 Fifeteen
+19 Nineteen
+91 Ninety-one
+93 Ninety-three
+95 Ninety-five
+99 Ninety-nine
+SELECT * FROM t_1000;
+a b
+111 Hundred elven
+113 Hundred thirdteen
+115 Hundred fiveteen
+119 Hundred nineteen
+131 Hundred thirty-one
+133 Hundred thirty-three
+135 Hundred thirty-five
+139 Hundred thirty-nine
+151 Hundred fifty-one
+153 Hundred fifty-three
+155 Hundred fity-five
+159 Hundred fifty-nine
+191 Hundred ninety-one
+193 Hundred ninety-three
+195 Hundred ninety-five
+199 Hundred ninety-nine
+SELECT * FROM tp;
+a b
+112 Hundred twelve
+114 Hundred fourteen
+116 Hundred sixteen
+118 Hundred eightteen
+12 twelve
+122 Hundred twenty-two
+124 Hundred twenty-four
+126 Hundred twenty-six
+128 Hundred twenty-eight
+14 Fourteen
+16 Sixteen
+162 Hundred sixty-two
+164 Hundred sixty-four
+166 Hundred sixty-six
+168 Hundred sixty-eight
+18 Eightteen
+182 Hundred eighty-two
+184 Hundred eighty-four
+186 Hundred eighty-six
+188 Hundred eighty-eight
+2 Two
+4 Four
+6 Six
+8 Eight
+SELECT * FROM tsp;
+a b
+112 Hundred twelve
+114 Hundred fourteen
+116 Hundred sixteen
+118 Hundred eightteen
+12 twelve
+122 Hundred twenty-two
+124 Hundred twenty-four
+126 Hundred twenty-six
+128 Hundred twenty-eight
+14 Fourteen
+16 Sixteen
+162 Hundred sixty-two
+164 Hundred sixty-four
+166 Hundred sixty-six
+168 Hundred sixty-eight
+18 Eightteen
+182 Hundred eight-two
+184 Hundred eighty-four
+186 Hundred eighty-six
+188 Hundred eighty-eight
+2 Two
+4 Four
+6 Six
+8 Eight
+SELECT * FROM tsp_00;
+a b
+5 Five
+SELECT * FROM tsp_01;
+a b
+1 One
+SELECT * FROM tsp_02;
+a b
+SELECT * FROM tsp_03;
+a b
+3 Three
+SELECT * FROM tsp_04;
+a b
+9 Nine
+CREATE INDEX id_t_10_b USING BTREE ON t_10 (b);
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR HY000: Tables have different definitions
+CREATE INDEX id_tp_b USING BTREE ON tp (b);
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR HY000: Tables have different definitions
+DROP INDEX id_t_10_b ON t_10;
+DROP INDEX id_tp_b ON tp;
+ALTER TABLE t_10 ADD UNIQUE INDEX USING BTREE (a);
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR HY000: Tables have different definitions
+ALTER TABLE tp ADD UNIQUE INDEX USING BTREE (a);
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+show create table t_10;
+Table Create Table
+t_10 CREATE TABLE `t_10` (
+ `a` int(11) NOT NULL DEFAULT '0',
+ `b` varchar(55) DEFAULT NULL,
+ PRIMARY KEY (`a`),
+ UNIQUE KEY `a` (`a`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+show create table tp ;
+Table Create Table
+tp CREATE TABLE `tp` (
+ `a` int(11) NOT NULL DEFAULT '0',
+ `b` varchar(55) DEFAULT NULL,
+ PRIMARY KEY (`a`),
+ UNIQUE KEY `a` (`a`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10) ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN (100) ENGINE = InnoDB,
+ PARTITION p2 VALUES LESS THAN (1000) ENGINE = InnoDB) */
+ALTER TABLE tp DROP INDEX a;
+ALTER TABLE t_10 DROP INDEX a;
+ALTER TABLE tp ADD UNIQUE INDEX USING BTREE (a,b);
+ALTER TABLE t_10 ADD UNIQUE INDEX USING BTREE (a,b);
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+show create table t_10;
+Table Create Table
+t_10 CREATE TABLE `t_10` (
+ `a` int(11) NOT NULL DEFAULT '0',
+ `b` varchar(55) DEFAULT NULL,
+ PRIMARY KEY (`a`),
+ UNIQUE KEY `a` (`a`,`b`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+show create table tp ;
+Table Create Table
+tp CREATE TABLE `tp` (
+ `a` int(11) NOT NULL DEFAULT '0',
+ `b` varchar(55) DEFAULT NULL,
+ PRIMARY KEY (`a`),
+ UNIQUE KEY `a` (`a`,`b`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10) ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN (100) ENGINE = InnoDB,
+ PARTITION p2 VALUES LESS THAN (1000) ENGINE = InnoDB) */
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
diff --git a/mysql-test/suite/parts/r/partition_exch_qa_1_myisam.result b/mysql-test/suite/parts/r/partition_exch_qa_1_myisam.result
new file mode 100644
index 00000000000..f15e56e76aa
--- /dev/null
+++ b/mysql-test/suite/parts/r/partition_exch_qa_1_myisam.result
@@ -0,0 +1,171 @@
+use test;
+SELECT * FROM t_10;
+a b
+1 One
+3 Three
+5 Five
+9 Nine
+SELECT * FROM t_100;
+a b
+11 Eleven
+13 Thirdteen
+15 Fifeteen
+19 Nineteen
+91 Ninety-one
+93 Ninety-three
+95 Ninety-five
+99 Ninety-nine
+SELECT * FROM t_1000;
+a b
+111 Hundred elven
+113 Hundred thirdteen
+115 Hundred fiveteen
+119 Hundred nineteen
+131 Hundred thirty-one
+133 Hundred thirty-three
+135 Hundred thirty-five
+139 Hundred thirty-nine
+151 Hundred fifty-one
+153 Hundred fifty-three
+155 Hundred fity-five
+159 Hundred fifty-nine
+191 Hundred ninety-one
+193 Hundred ninety-three
+195 Hundred ninety-five
+199 Hundred ninety-nine
+SELECT * FROM tp;
+a b
+112 Hundred twelve
+114 Hundred fourteen
+116 Hundred sixteen
+118 Hundred eightteen
+12 twelve
+122 Hundred twenty-two
+124 Hundred twenty-four
+126 Hundred twenty-six
+128 Hundred twenty-eight
+14 Fourteen
+16 Sixteen
+162 Hundred sixty-two
+164 Hundred sixty-four
+166 Hundred sixty-six
+168 Hundred sixty-eight
+18 Eightteen
+182 Hundred eighty-two
+184 Hundred eighty-four
+186 Hundred eighty-six
+188 Hundred eighty-eight
+2 Two
+4 Four
+6 Six
+8 Eight
+SELECT * FROM tsp;
+a b
+112 Hundred twelve
+114 Hundred fourteen
+116 Hundred sixteen
+118 Hundred eightteen
+12 twelve
+122 Hundred twenty-two
+124 Hundred twenty-four
+126 Hundred twenty-six
+128 Hundred twenty-eight
+14 Fourteen
+16 Sixteen
+162 Hundred sixty-two
+164 Hundred sixty-four
+166 Hundred sixty-six
+168 Hundred sixty-eight
+18 Eightteen
+182 Hundred eight-two
+184 Hundred eighty-four
+186 Hundred eighty-six
+188 Hundred eighty-eight
+2 Two
+4 Four
+6 Six
+8 Eight
+SELECT * FROM tsp_00;
+a b
+5 Five
+SELECT * FROM tsp_01;
+a b
+1 One
+SELECT * FROM tsp_02;
+a b
+SELECT * FROM tsp_03;
+a b
+3 Three
+SELECT * FROM tsp_04;
+a b
+9 Nine
+CREATE INDEX id_t_10_b USING BTREE ON t_10 (b);
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR HY000: Tables have different definitions
+CREATE INDEX id_tp_b USING BTREE ON tp (b);
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR HY000: Tables have different definitions
+DROP INDEX id_t_10_b ON t_10;
+DROP INDEX id_tp_b ON tp;
+ALTER TABLE t_10 ADD UNIQUE INDEX USING BTREE (a);
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR HY000: Tables have different definitions
+ALTER TABLE tp ADD UNIQUE INDEX USING BTREE (a);
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+show create table t_10;
+Table Create Table
+t_10 CREATE TABLE `t_10` (
+ `a` int(11) NOT NULL DEFAULT '0',
+ `b` varchar(55) DEFAULT NULL,
+ PRIMARY KEY (`a`),
+ UNIQUE KEY `a` (`a`) USING BTREE
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+show create table tp ;
+Table Create Table
+tp CREATE TABLE `tp` (
+ `a` int(11) NOT NULL DEFAULT '0',
+ `b` varchar(55) DEFAULT NULL,
+ PRIMARY KEY (`a`),
+ UNIQUE KEY `a` (`a`) USING BTREE
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10) ENGINE = MyISAM,
+ PARTITION p1 VALUES LESS THAN (100) ENGINE = MyISAM,
+ PARTITION p2 VALUES LESS THAN (1000) ENGINE = MyISAM) */
+ALTER TABLE tp DROP INDEX a;
+ALTER TABLE t_10 DROP INDEX a;
+ALTER TABLE tp ADD UNIQUE INDEX USING BTREE (a,b);
+ALTER TABLE t_10 ADD UNIQUE INDEX USING BTREE (a,b);
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+show create table t_10;
+Table Create Table
+t_10 CREATE TABLE `t_10` (
+ `a` int(11) NOT NULL DEFAULT '0',
+ `b` varchar(55) DEFAULT NULL,
+ PRIMARY KEY (`a`),
+ UNIQUE KEY `a` (`a`,`b`) USING BTREE
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+show create table tp ;
+Table Create Table
+tp CREATE TABLE `tp` (
+ `a` int(11) NOT NULL DEFAULT '0',
+ `b` varchar(55) DEFAULT NULL,
+ PRIMARY KEY (`a`),
+ UNIQUE KEY `a` (`a`,`b`) USING BTREE
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10) ENGINE = MyISAM,
+ PARTITION p1 VALUES LESS THAN (100) ENGINE = MyISAM,
+ PARTITION p2 VALUES LESS THAN (1000) ENGINE = MyISAM) */
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
diff --git a/mysql-test/suite/parts/r/partition_exch_qa_2.result b/mysql-test/suite/parts/r/partition_exch_qa_2.result
new file mode 100644
index 00000000000..ea4983db3dc
--- /dev/null
+++ b/mysql-test/suite/parts/r/partition_exch_qa_2.result
@@ -0,0 +1,138 @@
+use test;
+SELECT * FROM t_10;
+a b
+1 One
+3 Three
+5 Five
+9 Nine
+SELECT * FROM t_100;
+a b
+11 Eleven
+13 Thirdteen
+15 Fifeteen
+19 Nineteen
+91 Ninety-one
+93 Ninety-three
+95 Ninety-five
+99 Ninety-nine
+SELECT * FROM t_1000;
+a b
+111 Hundred elven
+113 Hundred thirdteen
+115 Hundred fiveteen
+119 Hundred nineteen
+131 Hundred thirty-one
+133 Hundred thirty-three
+135 Hundred thirty-five
+139 Hundred thirty-nine
+151 Hundred fifty-one
+153 Hundred fifty-three
+155 Hundred fity-five
+159 Hundred fifty-nine
+191 Hundred ninety-one
+193 Hundred ninety-three
+195 Hundred ninety-five
+199 Hundred ninety-nine
+SELECT * FROM tp;
+a b
+112 Hundred twelve
+114 Hundred fourteen
+116 Hundred sixteen
+118 Hundred eightteen
+12 twelve
+122 Hundred twenty-two
+124 Hundred twenty-four
+126 Hundred twenty-six
+128 Hundred twenty-eight
+14 Fourteen
+16 Sixteen
+162 Hundred sixty-two
+164 Hundred sixty-four
+166 Hundred sixty-six
+168 Hundred sixty-eight
+18 Eightteen
+182 Hundred eighty-two
+184 Hundred eighty-four
+186 Hundred eighty-six
+188 Hundred eighty-eight
+2 Two
+4 Four
+6 Six
+8 Eight
+SELECT * FROM tsp;
+a b
+112 Hundred twelve
+114 Hundred fourteen
+116 Hundred sixteen
+118 Hundred eightteen
+12 twelve
+122 Hundred twenty-two
+124 Hundred twenty-four
+126 Hundred twenty-six
+128 Hundred twenty-eight
+14 Fourteen
+16 Sixteen
+162 Hundred sixty-two
+164 Hundred sixty-four
+166 Hundred sixty-six
+168 Hundred sixty-eight
+18 Eightteen
+182 Hundred eight-two
+184 Hundred eighty-four
+186 Hundred eighty-six
+188 Hundred eighty-eight
+2 Two
+4 Four
+6 Six
+8 Eight
+SELECT * FROM tsp_00;
+a b
+5 Five
+SELECT * FROM tsp_01;
+a b
+1 One
+SELECT * FROM tsp_02;
+a b
+SELECT * FROM tsp_03;
+a b
+3 Three
+SELECT * FROM tsp_04;
+a b
+9 Nine
+CREATE TABLE t_11(a INT,b VARCHAR(55)) SELECT * FROM t_10;
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_11;
+ERROR HY000: Tables have different definitions
+DROP TABLE IF EXISTS t_11;
+CREATE TABLE t_11(a INT,b CHAR(55),PRIMARY KEY(a)) ENGINE= MYISAM SELECT * FROM t_10;
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_11;
+ERROR HY000: Tables have different definitions
+DROP TABLE IF EXISTS t_11;
+CREATE TABLE t_11(a INT,b VARCHAR(55),PRIMARY KEY(a)) ENGINE= MEMORY SELECT * FROM t_10;
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_11;
+ERROR HY000: The mix of handlers in the partitions is not allowed in this version of MariaDB
+DROP TABLE IF EXISTS t_11;
+CREATE TABLE t_11(a INT,b CHAR(55),PRIMARY KEY(a)) ENGINE= MYISAM
+PARTITION BY KEY() AS SELECT * FROM t_10;
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_11;
+ERROR HY000: Table to exchange with partition is partitioned: 't_11'
+DROP TABLE IF EXISTS t_11;
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE tsp;
+ERROR HY000: Table to exchange with partition is partitioned: 'tsp'
+ALTER TABLE tsp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR HY000: Subpartitioned table, use subpartition instead of partition
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_100;
+ERROR HY000: Found a row that does not match the partition
+ALTER TABLE tp EXCHANGE PARTITION p2 WITH TABLE t_10;
+ERROR HY000: Found a row that does not match the partition
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
diff --git a/mysql-test/suite/parts/r/partition_exch_qa_3.result b/mysql-test/suite/parts/r/partition_exch_qa_3.result
new file mode 100755
index 00000000000..9f4043a055a
--- /dev/null
+++ b/mysql-test/suite/parts/r/partition_exch_qa_3.result
@@ -0,0 +1,17 @@
+use test;
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR HY000: The mix of handlers in the partitions is not allowed in this version of MariaDB
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+ERROR HY000: The mix of handlers in the partitions is not allowed in this version of MariaDB
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
diff --git a/mysql-test/suite/parts/r/partition_exch_qa_4_innodb.result b/mysql-test/suite/parts/r/partition_exch_qa_4_innodb.result
new file mode 100755
index 00000000000..35f3499fce7
--- /dev/null
+++ b/mysql-test/suite/parts/r/partition_exch_qa_4_innodb.result
@@ -0,0 +1,76 @@
+CREATE DATABASE test_2;
+USE test;
+USE test;
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE test_2.t_10;
+SELECT * FROM test_2.t_10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a b
+1 One
+3 Three
+5 Five
+9 Nine
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE test_2.t_10;
+SELECT * FROM test_2.t_10;
+a b
+1 One
+3 Three
+5 Five
+9 Nine
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE test_2.tsp_00;
+SELECT * FROM test_2.tsp_00;
+a b
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+a b
+2 Two
+4 Four
+5 Five
+6 Six
+8 Eight
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE test_2.tsp_00;
+SELECT * FROM test_2.tsp_00;
+a b
+5 Five
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
+USE test_2;
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
+USE test;
+DROP DATABASE test_2;
diff --git a/mysql-test/suite/parts/r/partition_exch_qa_4_myisam.result b/mysql-test/suite/parts/r/partition_exch_qa_4_myisam.result
new file mode 100755
index 00000000000..35f3499fce7
--- /dev/null
+++ b/mysql-test/suite/parts/r/partition_exch_qa_4_myisam.result
@@ -0,0 +1,76 @@
+CREATE DATABASE test_2;
+USE test;
+USE test;
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE test_2.t_10;
+SELECT * FROM test_2.t_10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a b
+1 One
+3 Three
+5 Five
+9 Nine
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE test_2.t_10;
+SELECT * FROM test_2.t_10;
+a b
+1 One
+3 Three
+5 Five
+9 Nine
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE test_2.tsp_00;
+SELECT * FROM test_2.tsp_00;
+a b
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+a b
+2 Two
+4 Four
+5 Five
+6 Six
+8 Eight
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE test_2.tsp_00;
+SELECT * FROM test_2.tsp_00;
+a b
+5 Five
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
+USE test_2;
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
+USE test;
+DROP DATABASE test_2;
diff --git a/mysql-test/suite/parts/r/partition_exch_qa_5_innodb.result b/mysql-test/suite/parts/r/partition_exch_qa_5_innodb.result
new file mode 100755
index 00000000000..e539c37a0b4
--- /dev/null
+++ b/mysql-test/suite/parts/r/partition_exch_qa_5_innodb.result
@@ -0,0 +1,114 @@
+CREATE USER test1@localhost;
+CREATE USER test2@localhost;
+GRANT USAGE ON *.* TO test1@localhost;
+GRANT USAGE ON *.* TO test2@localhost;
+GRANT CREATE, DROP, INSERT, SELECT ON test.* TO test1@localhost;
+GRANT CREATE, DROP, ALTER, UPDATE, INSERT, SELECT ON test.* TO test2@localhost;
+connect (test1,localhost,test1,,test,MASTER_MYPORT,MASTER_MYSOCK);
+SELECT current_user();
+current_user()
+test1@localhost
+SHOW GRANTS FOR CURRENT_USER;
+Grants for test1@localhost
+GRANT USAGE ON *.* TO 'test1'@'localhost'
+GRANT SELECT, INSERT, CREATE, DROP ON `test`.* TO 'test1'@'localhost'
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR 42000: ALTER command denied to user 'test1'@'localhost' for table 'tp'
+disconnect test1;
+connect (test2,localhost,test2,,test,MASTER_MYPORT,MASTER_MYSOCK);
+USE test;
+SELECT current_user();
+current_user()
+test2@localhost
+SHOW GRANTS FOR CURRENT_USER;
+Grants for test2@localhost
+GRANT USAGE ON *.* TO 'test2'@'localhost'
+GRANT SELECT, INSERT, UPDATE, CREATE, DROP, ALTER ON `test`.* TO 'test2'@'localhost'
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+SELECT * FROM t_10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a b
+1 One
+3 Three
+5 Five
+9 Nine
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+SELECT * FROM t_10;
+a b
+1 One
+3 Three
+5 Five
+9 Nine
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+SELECT * FROM tsp_00;
+a b
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+a b
+2 Two
+4 Four
+5 Five
+6 Six
+8 Eight
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+SELECT * FROM tsp_00;
+a b
+5 Five
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+disconnect test2;
+connection default;
+REVOKE ALTER ON test.* FROM test2@localhost;
+connect (test2,localhost,test2,,test,MASTER_MYPORT,MASTER_MYSOCK);
+USE test;
+SELECT current_user();
+current_user()
+test2@localhost
+SHOW GRANTS FOR CURRENT_USER;
+Grants for test2@localhost
+GRANT USAGE ON *.* TO 'test2'@'localhost'
+GRANT SELECT, INSERT, UPDATE, CREATE, DROP ON `test`.* TO 'test2'@'localhost'
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR 42000: ALTER command denied to user 'test2'@'localhost' for table 'tp'
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR 42000: ALTER command denied to user 'test2'@'localhost' for table 'tp'
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+ERROR 42000: ALTER command denied to user 'test2'@'localhost' for table 'tsp'
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+ERROR 42000: ALTER command denied to user 'test2'@'localhost' for table 'tsp'
+connection default;
+disconnect test2;
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
+DROP USER test1@localhost;
+DROP USER test2@localhost;
diff --git a/mysql-test/suite/parts/r/partition_exch_qa_5_myisam.result b/mysql-test/suite/parts/r/partition_exch_qa_5_myisam.result
new file mode 100755
index 00000000000..e539c37a0b4
--- /dev/null
+++ b/mysql-test/suite/parts/r/partition_exch_qa_5_myisam.result
@@ -0,0 +1,114 @@
+CREATE USER test1@localhost;
+CREATE USER test2@localhost;
+GRANT USAGE ON *.* TO test1@localhost;
+GRANT USAGE ON *.* TO test2@localhost;
+GRANT CREATE, DROP, INSERT, SELECT ON test.* TO test1@localhost;
+GRANT CREATE, DROP, ALTER, UPDATE, INSERT, SELECT ON test.* TO test2@localhost;
+connect (test1,localhost,test1,,test,MASTER_MYPORT,MASTER_MYSOCK);
+SELECT current_user();
+current_user()
+test1@localhost
+SHOW GRANTS FOR CURRENT_USER;
+Grants for test1@localhost
+GRANT USAGE ON *.* TO 'test1'@'localhost'
+GRANT SELECT, INSERT, CREATE, DROP ON `test`.* TO 'test1'@'localhost'
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR 42000: ALTER command denied to user 'test1'@'localhost' for table 'tp'
+disconnect test1;
+connect (test2,localhost,test2,,test,MASTER_MYPORT,MASTER_MYSOCK);
+USE test;
+SELECT current_user();
+current_user()
+test2@localhost
+SHOW GRANTS FOR CURRENT_USER;
+Grants for test2@localhost
+GRANT USAGE ON *.* TO 'test2'@'localhost'
+GRANT SELECT, INSERT, UPDATE, CREATE, DROP, ALTER ON `test`.* TO 'test2'@'localhost'
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+SELECT * FROM t_10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a b
+1 One
+3 Three
+5 Five
+9 Nine
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+SELECT * FROM t_10;
+a b
+1 One
+3 Three
+5 Five
+9 Nine
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+SELECT * FROM tsp_00;
+a b
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+a b
+2 Two
+4 Four
+5 Five
+6 Six
+8 Eight
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+SELECT * FROM tsp_00;
+a b
+5 Five
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+disconnect test2;
+connection default;
+REVOKE ALTER ON test.* FROM test2@localhost;
+connect (test2,localhost,test2,,test,MASTER_MYPORT,MASTER_MYSOCK);
+USE test;
+SELECT current_user();
+current_user()
+test2@localhost
+SHOW GRANTS FOR CURRENT_USER;
+Grants for test2@localhost
+GRANT USAGE ON *.* TO 'test2'@'localhost'
+GRANT SELECT, INSERT, UPDATE, CREATE, DROP ON `test`.* TO 'test2'@'localhost'
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR 42000: ALTER command denied to user 'test2'@'localhost' for table 'tp'
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR 42000: ALTER command denied to user 'test2'@'localhost' for table 'tp'
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+ERROR 42000: ALTER command denied to user 'test2'@'localhost' for table 'tsp'
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+ERROR 42000: ALTER command denied to user 'test2'@'localhost' for table 'tsp'
+connection default;
+disconnect test2;
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
+DROP USER test1@localhost;
+DROP USER test2@localhost;
diff --git a/mysql-test/suite/parts/r/partition_exch_qa_6.result b/mysql-test/suite/parts/r/partition_exch_qa_6.result
new file mode 100755
index 00000000000..92527ab1dd9
--- /dev/null
+++ b/mysql-test/suite/parts/r/partition_exch_qa_6.result
@@ -0,0 +1,105 @@
+CREATE USER test2@localhost;
+GRANT USAGE ON *.* TO test2@localhost;
+GRANT CREATE, DROP, ALTER, UPDATE, INSERT, SELECT ON test.* TO test2@localhost;
+connect (test2,localhost,test2,,test,MASTER_MYPORT,MASTER_MYSOCK);
+USE test;
+SHOW GRANTS FOR CURRENT_USER;
+Grants for test2@localhost
+GRANT USAGE ON *.* TO 'test2'@'localhost'
+GRANT SELECT, INSERT, UPDATE, CREATE, DROP, ALTER ON `test`.* TO 'test2'@'localhost'
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+SELECT * FROM t_10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a b
+1 One
+3 Three
+5 Five
+9 Nine
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+SELECT * FROM t_10;
+a b
+1 One
+3 Three
+5 Five
+9 Nine
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+SELECT * FROM tsp_00;
+a b
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+a b
+2 Two
+4 Four
+5 Five
+6 Six
+8 Eight
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+SELECT * FROM tsp_00;
+a b
+5 Five
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+disconnect test2;
+connection default;
+REVOKE INSERT ON test.* FROM test2@localhost;
+connect (test2,localhost,test2,,test,MASTER_MYPORT,MASTER_MYSOCK);
+USE test;
+SHOW GRANTS FOR CURRENT_USER;
+Grants for test2@localhost
+GRANT USAGE ON *.* TO 'test2'@'localhost'
+GRANT SELECT, UPDATE, CREATE, DROP, ALTER ON `test`.* TO 'test2'@'localhost'
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR 42000: INSERT command denied to user 'test2'@'localhost' for table 'tp'
+disconnect test2;
+connection default;
+GRANT INSERT ON test.* TO test2@localhost;
+REVOKE CREATE ON test.* FROM test2@localhost;
+connect (test2,localhost,test2,,test,MASTER_MYPORT,MASTER_MYSOCK);
+USE test;
+SHOW GRANTS FOR CURRENT_USER;
+Grants for test2@localhost
+GRANT USAGE ON *.* TO 'test2'@'localhost'
+GRANT SELECT, INSERT, UPDATE, DROP, ALTER ON `test`.* TO 'test2'@'localhost'
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+ERROR 42000: CREATE command denied to user 'test2'@'localhost' for table 'tsp'
+disconnect test2;
+connection default;
+GRANT CREATE ON test.* TO test2@localhost;
+REVOKE DROP ON test.* FROM test2@localhost;
+connect (test2,localhost,test2,,test,MASTER_MYPORT,MASTER_MYSOCK);
+USE test;
+SHOW GRANTS FOR CURRENT_USER;
+Grants for test2@localhost
+GRANT USAGE ON *.* TO 'test2'@'localhost'
+GRANT SELECT, INSERT, UPDATE, CREATE, ALTER ON `test`.* TO 'test2'@'localhost'
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR 42000: DROP command denied to user 'test2'@'localhost' for table 'tp'
+disconnect test2;
+connection default;
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
+DROP USER test2@localhost;
diff --git a/mysql-test/suite/parts/r/partition_exch_qa_7_innodb.result b/mysql-test/suite/parts/r/partition_exch_qa_7_innodb.result
new file mode 100755
index 00000000000..8ae4bfd3d3a
--- /dev/null
+++ b/mysql-test/suite/parts/r/partition_exch_qa_7_innodb.result
@@ -0,0 +1,82 @@
+CREATE USER test_2@localhost;
+send
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+connect (test_2,localhost,test_2,,test,MASTER_MYPORT,MASTER_MYSOCK);
+SELECT * FROM t_10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a b
+1 One
+3 Three
+5 Five
+9 Nine
+INSERT INTO tp VALUES (7,"Seven");
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a b
+1 One
+3 Three
+5 Five
+7 Seven
+9 Nine
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+connection default;
+reap;
+SELECT * FROM t_10;
+a b
+1 One
+3 Three
+5 Five
+7 Seven
+9 Nine
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+connection test_2;
+SELECT * FROM t_10;
+a b
+1 One
+3 Three
+5 Five
+7 Seven
+9 Nine
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+disconnect test_2;
+connection default;
+SELECT * FROM t_10;
+a b
+1 One
+3 Three
+5 Five
+7 Seven
+9 Nine
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
+DROP USER test_2@localhost;
diff --git a/mysql-test/suite/parts/r/partition_exch_qa_7_myisam.result b/mysql-test/suite/parts/r/partition_exch_qa_7_myisam.result
new file mode 100755
index 00000000000..8ae4bfd3d3a
--- /dev/null
+++ b/mysql-test/suite/parts/r/partition_exch_qa_7_myisam.result
@@ -0,0 +1,82 @@
+CREATE USER test_2@localhost;
+send
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+connect (test_2,localhost,test_2,,test,MASTER_MYPORT,MASTER_MYSOCK);
+SELECT * FROM t_10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a b
+1 One
+3 Three
+5 Five
+9 Nine
+INSERT INTO tp VALUES (7,"Seven");
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a b
+1 One
+3 Three
+5 Five
+7 Seven
+9 Nine
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+connection default;
+reap;
+SELECT * FROM t_10;
+a b
+1 One
+3 Three
+5 Five
+7 Seven
+9 Nine
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+connection test_2;
+SELECT * FROM t_10;
+a b
+1 One
+3 Three
+5 Five
+7 Seven
+9 Nine
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+disconnect test_2;
+connection default;
+SELECT * FROM t_10;
+a b
+1 One
+3 Three
+5 Five
+7 Seven
+9 Nine
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
+DROP USER test_2@localhost;
diff --git a/mysql-test/suite/parts/r/partition_exch_qa_8_innodb.result b/mysql-test/suite/parts/r/partition_exch_qa_8_innodb.result
new file mode 100755
index 00000000000..b252fc616b1
--- /dev/null
+++ b/mysql-test/suite/parts/r/partition_exch_qa_8_innodb.result
@@ -0,0 +1,83 @@
+CREATE USER test2@localhost;
+CREATE DATABASE testdb;
+USE testdb;
+USE test;
+GRANT CREATE, ALTER, DROP, INSERT, SELECT on test.* TO test2@localhost;
+GRANT CREATE, ALTER, DROP, INSERT, SELECT on testdb.* TO test2@localhost;
+connect (test2,localhost,test2,,test,MASTER_MYPORT,MASTER_MYSOCK);
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE testdb.t_10;
+SELECT * FROM testdb.t_10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a b
+1 One
+3 Three
+5 Five
+9 Nine
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE testdb.t_10;
+SELECT * FROM testdb.t_10;
+a b
+1 One
+3 Three
+5 Five
+9 Nine
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+ALTER TABLE testdb.tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+SELECT * FROM t_10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+SELECT * FROM testdb.tp WHERE a BETWEEN 0 AND 10;
+a b
+1 One
+3 Three
+5 Five
+9 Nine
+ALTER TABLE testdb.tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+SELECT * FROM t_10;
+a b
+1 One
+3 Three
+5 Five
+9 Nine
+SELECT * FROM testdb.tp WHERE a BETWEEN 0 AND 10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+disconnect test2;
+connection default;
+REVOKE INSERT ON testdb.* FROM test2@localhost;
+connect (test2,localhost,test2,,test,MASTER_MYPORT,MASTER_MYSOCK);
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE testdb.t_10;
+ERROR 42000: INSERT command denied to user 'test2'@'localhost' for table 't_10'
+ALTER TABLE testdb.tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR 42000: INSERT command denied to user 'test2'@'localhost' for table 'tp'
+disconnect test2;
+connection default;
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
+DROP USER test2@localhost;
+DROP DATABASE testdb;
diff --git a/mysql-test/suite/parts/r/partition_exch_qa_8_myisam.result b/mysql-test/suite/parts/r/partition_exch_qa_8_myisam.result
new file mode 100755
index 00000000000..b252fc616b1
--- /dev/null
+++ b/mysql-test/suite/parts/r/partition_exch_qa_8_myisam.result
@@ -0,0 +1,83 @@
+CREATE USER test2@localhost;
+CREATE DATABASE testdb;
+USE testdb;
+USE test;
+GRANT CREATE, ALTER, DROP, INSERT, SELECT on test.* TO test2@localhost;
+GRANT CREATE, ALTER, DROP, INSERT, SELECT on testdb.* TO test2@localhost;
+connect (test2,localhost,test2,,test,MASTER_MYPORT,MASTER_MYSOCK);
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE testdb.t_10;
+SELECT * FROM testdb.t_10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a b
+1 One
+3 Three
+5 Five
+9 Nine
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE testdb.t_10;
+SELECT * FROM testdb.t_10;
+a b
+1 One
+3 Three
+5 Five
+9 Nine
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+ALTER TABLE testdb.tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+SELECT * FROM t_10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+SELECT * FROM testdb.tp WHERE a BETWEEN 0 AND 10;
+a b
+1 One
+3 Three
+5 Five
+9 Nine
+ALTER TABLE testdb.tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+SELECT * FROM t_10;
+a b
+1 One
+3 Three
+5 Five
+9 Nine
+SELECT * FROM testdb.tp WHERE a BETWEEN 0 AND 10;
+a b
+2 Two
+4 Four
+6 Six
+8 Eight
+disconnect test2;
+connection default;
+REVOKE INSERT ON testdb.* FROM test2@localhost;
+connect (test2,localhost,test2,,test,MASTER_MYPORT,MASTER_MYSOCK);
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE testdb.t_10;
+ERROR 42000: INSERT command denied to user 'test2'@'localhost' for table 't_10'
+ALTER TABLE testdb.tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR 42000: INSERT command denied to user 'test2'@'localhost' for table 'tp'
+disconnect test2;
+connection default;
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
+DROP USER test2@localhost;
+DROP DATABASE testdb;
diff --git a/mysql-test/suite/parts/r/partition_exchange_archive.result b/mysql-test/suite/parts/r/partition_exchange_archive.result
new file mode 100644
index 00000000000..2918c2eed31
--- /dev/null
+++ b/mysql-test/suite/parts/r/partition_exchange_archive.result
@@ -0,0 +1,322 @@
+# Archive does not support keys, update or delete
+# Test with AUTO_INCREMENT
+CREATE TABLE tp
+(a INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+b varchar(24))
+ENGINE = 'Archive'
+PARTITION BY HASH (a) PARTITIONS 4;
+CREATE TABLE t LIKE tp;
+ALTER TABLE t REMOVE PARTITIONING;
+SHOW CREATE TABLE tp;
+Table Create Table
+tp CREATE TABLE `tp` (
+ `a` int(11) NOT NULL AUTO_INCREMENT,
+ `b` varchar(24) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=ARCHIVE DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY HASH (a)
+PARTITIONS 4 */
+SHOW CREATE TABLE t;
+Table Create Table
+t CREATE TABLE `t` (
+ `a` int(11) NOT NULL AUTO_INCREMENT,
+ `b` varchar(24) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=ARCHIVE DEFAULT CHARSET=latin1
+INSERT INTO tp (b) VALUES ("One"), ("Two"), ("Three"), ("Four"), ("Five"),
+("Six"), ("Seven"), ("Eight"), ("Nine"), ("Ten"), ("Eleven"), ("Twelwe");
+INSERT INTO tp VALUES (41, "One hundred one");
+INSERT INTO tp VALUES (97, "Ninety seven");
+SET INSERT_ID = 13;
+INSERT INTO t (b) VALUES ("Thirteen");
+SET INSERT_ID = 17;
+INSERT INTO t (b) VALUES ("Twenty five");
+SET INSERT_ID = 21;
+INSERT INTO t (b) VALUES ("Twenty one");
+SELECT PARTITION_NAME, IF(TABLE_ROWS, 'YES', 'NO') AS HAVE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA ='test' AND TABLE_NAME = 'tp';
+PARTITION_NAME HAVE_ROWS
+p0 YES
+p1 YES
+p2 YES
+p3 YES
+SELECT IF(TABLE_ROWS, 'YES', 'NO') AS HAVE_ROWS FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA ='test' AND TABLE_NAME = 't';
+HAVE_ROWS
+YES
+ALTER TABLE tp EXCHANGE PARTITION p1 WITH TABLE t;
+SELECT PARTITION_NAME, IF(TABLE_ROWS, 'YES', 'NO') AS HAVE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA ='test' AND TABLE_NAME = 'tp';
+PARTITION_NAME HAVE_ROWS
+p0 YES
+p1 YES
+p2 YES
+p3 YES
+SELECT IF(TABLE_ROWS, 'YES', 'NO') AS HAVE_ROWS FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA ='test' AND TABLE_NAME = 't';
+HAVE_ROWS
+YES
+SELECT * FROM tp ORDER BY a;
+a b
+2 Two
+3 Three
+4 Four
+6 Six
+7 Seven
+8 Eight
+10 Ten
+11 Eleven
+12 Twelwe
+13 Thirteen
+17 Twenty five
+21 Twenty one
+SELECT * FROM t ORDER BY a;
+a b
+1 One
+5 Five
+9 Nine
+41 One hundred one
+97 Ninety seven
+SHOW CREATE TABLE tp;
+Table Create Table
+tp CREATE TABLE `tp` (
+ `a` int(11) NOT NULL AUTO_INCREMENT,
+ `b` varchar(24) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=ARCHIVE AUTO_INCREMENT=22 DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY HASH (a)
+PARTITIONS 4 */
+SHOW CREATE TABLE t;
+Table Create Table
+t CREATE TABLE `t` (
+ `a` int(11) NOT NULL AUTO_INCREMENT,
+ `b` varchar(24) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=ARCHIVE AUTO_INCREMENT=98 DEFAULT CHARSET=latin1
+DROP TABLE tp, t;
+CREATE TABLE t
+(a INT,
+b VARCHAR(55))
+ENGINE = 'Archive';
+CREATE TABLE tp
+(a INT,
+b VARCHAR(55))
+ENGINE = 'Archive'
+PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (100),
+PARTITION p1 VALUES LESS THAN MAXVALUE);
+CREATE TABLE tsp
+(a INT,
+b VARCHAR(55))
+ENGINE = 'Archive'
+PARTITION BY RANGE (a)
+SUBPARTITION BY HASH(a)
+(PARTITION p0 VALUES LESS THAN (100)
+(SUBPARTITION sp0,
+SUBPARTITION sp1),
+PARTITION p1 VALUES LESS THAN MAXVALUE
+(SUBPARTITION sp2,
+SUBPARTITION sp3));
+INSERT INTO t VALUES (1, "First value"), (3, "Three"), (5, "Five"), (99, "End of values");
+INSERT INTO tp VALUES (2, "First value"), (10, "Ten"), (50, "Fifty"), (200, "Two hundred, end of values"), (61, "Sixty one"), (62, "Sixty two"), (63, "Sixty three"), (64, "Sixty four"), (161, "161"), (162, "162"), (163, "163"), (164, "164");
+INSERT INTO tsp VALUES (2, "First value"), (10, "Ten"), (50, "Fifty"), (200, "Two hundred, end of values"), (61, "Sixty one"), (62, "Sixty two"), (63, "Sixty three"), (64, "Sixty four"), (161, "161"), (162, "162"), (163, "163"), (164, "164");
+SELECT * FROM t;
+a b
+1 First value
+3 Three
+5 Five
+99 End of values
+SELECT * FROM tp;
+a b
+10 Ten
+161 161
+162 162
+163 163
+164 164
+2 First value
+200 Two hundred, end of values
+50 Fifty
+61 Sixty one
+62 Sixty two
+63 Sixty three
+64 Sixty four
+# Start by testing read/write locking
+SET AUTOCOMMIT = 1;
+# con1
+SET DEBUG_SYNC= 'swap_partition_after_compare_tables SIGNAL swap_in_progress WAIT_FOR goto_verification';
+SET DEBUG_SYNC= 'swap_partition_first_row_read SIGNAL swap_in_progress WAIT_FOR goto_wait';
+SET DEBUG_SYNC= 'swap_partition_after_wait SIGNAL swap_in_progress WAIT_FOR goto_rename';
+SET DEBUG_SYNC= 'swap_partition_before_rename SIGNAL swap_in_progress WAIT_FOR test_done';
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t;
+# con default
+SET DEBUG_SYNC= 'now WAIT_FOR swap_in_progress';
+# select from t and select/update/delete/insert from tp should work
+SELECT * FROM t WHERE a = 99;
+a b
+99 End of values
+SELECT * FROM tp WHERE a = 61;
+a b
+61 Sixty one
+# any write (update/delete/insert) into t or tp should fail
+SET SESSION lock_wait_timeout=1;
+INSERT INTO tp VALUES (63, "Sixty three, new"), (59, "To be deleted");
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+INSERT INTO t VALUES (63, "Sixty three, new"), (59, "To be deleted");
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+ALTER TABLE t ENGINE = 'Archive';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+ALTER TABLE tp ENGINE = 'Archive';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SHOW CREATE TABLE t;
+Table Create Table
+t CREATE TABLE `t` (
+ `a` int(11) DEFAULT NULL,
+ `b` varchar(55) DEFAULT NULL
+) ENGINE=ARCHIVE DEFAULT CHARSET=latin1
+SHOW CREATE TABLE tp;
+Table Create Table
+tp CREATE TABLE `tp` (
+ `a` int(11) DEFAULT NULL,
+ `b` varchar(55) DEFAULT NULL
+) ENGINE=ARCHIVE DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (100) ENGINE = ARCHIVE,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = ARCHIVE) */
+SET DEBUG_SYNC= 'now SIGNAL goto_verification';
+SET DEBUG_SYNC= 'now WAIT_FOR swap_in_progress';
+# select from t and select/update/delete/insert from tp should work
+SELECT * FROM t WHERE a = 99;
+a b
+99 End of values
+SELECT * FROM tp WHERE a = 61;
+a b
+61 Sixty one
+INSERT INTO tp VALUES (63, "Sixty three, new 2"), (59, "To be deleted");
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+# any write (update/delete/insert) into t should fail
+INSERT INTO t VALUES (63, "Sixty three, new"), (59, "To be deleted");
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+ALTER TABLE t ENGINE = 'Archive';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+ALTER TABLE tp ENGINE = 'Archive';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SHOW CREATE TABLE t;
+Table Create Table
+t CREATE TABLE `t` (
+ `a` int(11) DEFAULT NULL,
+ `b` varchar(55) DEFAULT NULL
+) ENGINE=ARCHIVE DEFAULT CHARSET=latin1
+SHOW CREATE TABLE tp;
+Table Create Table
+tp CREATE TABLE `tp` (
+ `a` int(11) DEFAULT NULL,
+ `b` varchar(55) DEFAULT NULL
+) ENGINE=ARCHIVE DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (100) ENGINE = ARCHIVE,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = ARCHIVE) */
+SET DEBUG_SYNC= 'now SIGNAL goto_wait';
+SET DEBUG_SYNC= 'now WAIT_FOR swap_in_progress';
+# Both tables should now be under exclusive lock, even SHOW should fail
+SELECT * FROM t WHERE a = 99;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SELECT * FROM tp WHERE a = 61;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+INSERT INTO tp VALUES (63, "Sixty three, new 2"), (59, "To be deleted");
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+INSERT INTO t VALUES (63, "Sixty three, new"), (59, "To be deleted");
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SHOW CREATE TABLE t;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SHOW CREATE TABLE tp;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+ALTER TABLE t ENGINE = 'Archive';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+ALTER TABLE tp ENGINE = 'Archive';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SET DEBUG_SYNC= 'now SIGNAL goto_rename';
+SET DEBUG_SYNC= 'now WAIT_FOR swap_in_progress';
+# Both tables should now be under exclusive lock
+SELECT * FROM t WHERE a = 99;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SELECT * FROM tp WHERE a = 61;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+INSERT INTO tp VALUES (63, "Sixty three, new 2"), (59, "To be deleted");
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+INSERT INTO t VALUES (63, "Sixty three, new"), (59, "To be deleted");
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+ALTER TABLE t ENGINE = 'Archive';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+ALTER TABLE tp ENGINE = 'Archive';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SHOW CREATE TABLE t;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SHOW CREATE TABLE tp;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SET DEBUG_SYNC= 'now SIGNAL test_done';
+# con1
+# con default
+# Tables should now be as normal
+SHOW CREATE TABLE t;
+Table Create Table
+t CREATE TABLE `t` (
+ `a` int(11) DEFAULT NULL,
+ `b` varchar(55) DEFAULT NULL
+) ENGINE=ARCHIVE DEFAULT CHARSET=latin1
+SHOW CREATE TABLE tp;
+Table Create Table
+tp CREATE TABLE `tp` (
+ `a` int(11) DEFAULT NULL,
+ `b` varchar(55) DEFAULT NULL
+) ENGINE=ARCHIVE DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (100) ENGINE = ARCHIVE,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = ARCHIVE) */
+SELECT * FROM tp WHERE a = 99;
+a b
+99 End of values
+SELECT * FROM t WHERE a = 61;
+a b
+61 Sixty one
+INSERT INTO t VALUES (63, "Sixty three, new"), (59, "To be deleted");
+INSERT INTO tp VALUES (63, "Sixty three, new"), (59, "To be deleted");
+ALTER TABLE t ENGINE = 'Archive';
+ALTER TABLE tp ENGINE = 'Archive';
+# con default
+SET DEBUG_SYNC= 'RESET';
+SHOW CREATE TABLE t;
+Table Create Table
+t CREATE TABLE `t` (
+ `a` int(11) DEFAULT NULL,
+ `b` varchar(55) DEFAULT NULL
+) ENGINE=ARCHIVE DEFAULT CHARSET=latin1
+SHOW CREATE TABLE tp;
+Table Create Table
+tp CREATE TABLE `tp` (
+ `a` int(11) DEFAULT NULL,
+ `b` varchar(55) DEFAULT NULL
+) ENGINE=ARCHIVE DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (100) ENGINE = ARCHIVE,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = ARCHIVE) */
+SELECT * FROM t;
+a b
+10 Ten
+2 First value
+50 Fifty
+59 To be deleted
+61 Sixty one
+62 Sixty two
+63 Sixty three
+63 Sixty three, new
+64 Sixty four
+SELECT * FROM tp;
+a b
+1 First value
+161 161
+162 162
+163 163
+164 164
+200 Two hundred, end of values
+3 Three
+5 Five
+59 To be deleted
+63 Sixty three, new
+99 End of values
+DROP TABLE t, tp, tsp;
diff --git a/mysql-test/suite/parts/r/partition_exchange_blackhole.result b/mysql-test/suite/parts/r/partition_exchange_blackhole.result
new file mode 100644
index 00000000000..f293bd8f960
--- /dev/null
+++ b/mysql-test/suite/parts/r/partition_exchange_blackhole.result
@@ -0,0 +1,10 @@
+# Blackhole has not implemented check_if_incompatible_data,
+# so it cannot support EXCHANGE PARTITION
+CREATE TABLE t (a int, b varchar(55)) ENGINE = 'Blackhole';
+CREATE TABLE tp (a int, b varchar(55)) ENGINE = 'Blackhole'
+PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (100),
+PARTITION p1 VALUES LESS THAN MAXVALUE);
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t;
+ERROR HY000: Tables have different definitions
+DROP TABLE t, tp;
diff --git a/mysql-test/suite/parts/r/partition_exchange_innodb.result b/mysql-test/suite/parts/r/partition_exchange_innodb.result
new file mode 100644
index 00000000000..d3287310f73
--- /dev/null
+++ b/mysql-test/suite/parts/r/partition_exchange_innodb.result
@@ -0,0 +1,374 @@
+# Test with AUTO_INCREMENT
+CREATE TABLE tp
+(a INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+b varchar(24))
+ENGINE = 'InnoDB'
+PARTITION BY HASH (a) PARTITIONS 4;
+CREATE TABLE t LIKE tp;
+ALTER TABLE t REMOVE PARTITIONING;
+SHOW CREATE TABLE tp;
+Table Create Table
+tp CREATE TABLE `tp` (
+ `a` int(11) NOT NULL AUTO_INCREMENT,
+ `b` varchar(24) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY HASH (a)
+PARTITIONS 4 */
+SHOW CREATE TABLE t;
+Table Create Table
+t CREATE TABLE `t` (
+ `a` int(11) NOT NULL AUTO_INCREMENT,
+ `b` varchar(24) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+INSERT INTO tp (b) VALUES ("One"), ("Two"), ("Three"), ("Four"), ("Five"),
+("Six"), ("Seven"), ("Eight"), ("Nine"), ("Ten"), ("Eleven"), ("Twelwe");
+INSERT INTO tp VALUES (97, "Ninety seven");
+INSERT INTO tp VALUES (111, "One hundred eleven");
+INSERT INTO tp VALUES (101, "One hundred one");
+SET INSERT_ID = 13;
+INSERT INTO t (b) VALUES ("Thirteen");
+SET INSERT_ID = 21;
+INSERT INTO t (b) VALUES ("Twenty one");
+SET INSERT_ID = 25;
+INSERT INTO t (b) VALUES ("Twenty five");
+SET INSERT_ID = 55;
+INSERT INTO t (b) VALUES ("Fifty five");
+DELETE FROM tp WHERE a = 111;
+DELETE FROM t WHERE a = 55;
+UPDATE tp SET a = 41 WHERE a = 101;
+UPDATE t SET a = 17 WHERE a = 25;
+SELECT PARTITION_NAME, IF(TABLE_ROWS, 'YES', 'NO') AS HAVE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA ='test' AND TABLE_NAME = 'tp';
+PARTITION_NAME HAVE_ROWS
+p0 YES
+p1 YES
+p2 YES
+p3 YES
+SELECT IF(TABLE_ROWS, 'YES', 'NO') AS HAVE_ROWS FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA ='test' AND TABLE_NAME = 't';
+HAVE_ROWS
+YES
+ALTER TABLE tp EXCHANGE PARTITION p1 WITH TABLE t;
+SELECT PARTITION_NAME, IF(TABLE_ROWS, 'YES', 'NO') AS HAVE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA ='test' AND TABLE_NAME = 'tp';
+PARTITION_NAME HAVE_ROWS
+p0 YES
+p1 YES
+p2 YES
+p3 YES
+SELECT IF(TABLE_ROWS, 'YES', 'NO') AS HAVE_ROWS FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA ='test' AND TABLE_NAME = 't';
+HAVE_ROWS
+YES
+SELECT * FROM tp ORDER BY a;
+a b
+2 Two
+3 Three
+4 Four
+6 Six
+7 Seven
+8 Eight
+10 Ten
+11 Eleven
+12 Twelwe
+13 Thirteen
+17 Twenty five
+21 Twenty one
+SELECT * FROM t ORDER BY a;
+a b
+1 One
+5 Five
+9 Nine
+41 One hundred one
+97 Ninety seven
+SHOW CREATE TABLE tp;
+Table Create Table
+tp CREATE TABLE `tp` (
+ `a` int(11) NOT NULL AUTO_INCREMENT,
+ `b` varchar(24) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB AUTO_INCREMENT=112 DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY HASH (a)
+PARTITIONS 4 */
+SHOW CREATE TABLE t;
+Table Create Table
+t CREATE TABLE `t` (
+ `a` int(11) NOT NULL AUTO_INCREMENT,
+ `b` varchar(24) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB AUTO_INCREMENT=102 DEFAULT CHARSET=latin1
+DROP TABLE tp, t;
+CREATE TABLE t
+(a INT,
+b VARCHAR(55),
+PRIMARY KEY (a))
+ENGINE = 'InnoDB';
+CREATE TABLE tp
+(a INT,
+b VARCHAR(55),
+PRIMARY KEY (a))
+ENGINE = 'InnoDB'
+PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (100),
+PARTITION p1 VALUES LESS THAN MAXVALUE);
+CREATE TABLE tsp
+(a INT,
+b VARCHAR(55),
+PRIMARY KEY (a))
+ENGINE = 'InnoDB'
+PARTITION BY RANGE (a)
+SUBPARTITION BY HASH(a)
+(PARTITION p0 VALUES LESS THAN (100)
+(SUBPARTITION sp0,
+SUBPARTITION sp1),
+PARTITION p1 VALUES LESS THAN MAXVALUE
+(SUBPARTITION sp2,
+SUBPARTITION sp3));
+INSERT INTO t VALUES (1, "First value"), (3, "Three"), (5, "Five"), (99, "End of values");
+INSERT INTO tp VALUES (2, "First value"), (10, "Ten"), (50, "Fifty"), (200, "Two hundred, end of values"), (61, "Sixty one"), (62, "Sixty two"), (63, "Sixty three"), (64, "Sixty four"), (161, "161"), (162, "162"), (163, "163"), (164, "164");
+INSERT INTO tsp VALUES (2, "First value"), (10, "Ten"), (50, "Fifty"), (200, "Two hundred, end of values"), (61, "Sixty one"), (62, "Sixty two"), (63, "Sixty three"), (64, "Sixty four"), (161, "161"), (162, "162"), (163, "163"), (164, "164");
+SELECT * FROM t;
+a b
+1 First value
+3 Three
+5 Five
+99 End of values
+SELECT * FROM tp;
+a b
+10 Ten
+161 161
+162 162
+163 163
+164 164
+2 First value
+200 Two hundred, end of values
+50 Fifty
+61 Sixty one
+62 Sixty two
+63 Sixty three
+64 Sixty four
+# Start by testing read/write locking
+SET AUTOCOMMIT = 1;
+# con1
+SET DEBUG_SYNC= 'swap_partition_after_compare_tables SIGNAL swap_in_progress WAIT_FOR goto_verification';
+SET DEBUG_SYNC= 'swap_partition_first_row_read SIGNAL swap_in_progress WAIT_FOR goto_wait';
+SET DEBUG_SYNC= 'swap_partition_after_wait SIGNAL swap_in_progress WAIT_FOR goto_rename';
+SET DEBUG_SYNC= 'swap_partition_before_rename SIGNAL swap_in_progress WAIT_FOR test_done';
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t;
+# con default
+SET DEBUG_SYNC= 'now WAIT_FOR swap_in_progress';
+# select from t and select/update/delete/insert from tp should work
+SELECT * FROM t WHERE a = 99;
+a b
+99 End of values
+SELECT * FROM tp WHERE a = 61;
+a b
+61 Sixty one
+# any write (update/delete/insert) into t or tp should fail
+SET SESSION lock_wait_timeout=1;
+UPDATE tp SET a = 53, b = concat("Fifty three, was ", b) WHERE a = 63;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+INSERT INTO tp VALUES (63, "Sixty three, new"), (59, "To be deleted");
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+DELETE FROM tp WHERE a = 59;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+UPDATE t SET a = 53, b = "Fifty three, was three" WHERE a = 3;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+INSERT INTO t VALUES (63, "Sixty three, new"), (59, "To be deleted");
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+DELETE FROM t WHERE a = 3;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+ALTER TABLE t ENGINE = 'InnoDB';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+ALTER TABLE tp ENGINE = 'InnoDB';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SHOW CREATE TABLE t;
+Table Create Table
+t CREATE TABLE `t` (
+ `a` int(11) NOT NULL DEFAULT '0',
+ `b` varchar(55) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+SHOW CREATE TABLE tp;
+Table Create Table
+tp CREATE TABLE `tp` (
+ `a` int(11) NOT NULL DEFAULT '0',
+ `b` varchar(55) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (100) ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
+SET DEBUG_SYNC= 'now SIGNAL goto_verification';
+SET DEBUG_SYNC= 'now WAIT_FOR swap_in_progress';
+# select from t and select/update/delete/insert from tp should work
+SELECT * FROM t WHERE a = 99;
+a b
+99 End of values
+SELECT * FROM tp WHERE a = 61;
+a b
+61 Sixty one
+UPDATE tp SET a = 43, b = concat("Fifty three, was ", b) WHERE a = 63;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+INSERT INTO tp VALUES (63, "Sixty three, new 2"), (59, "To be deleted");
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+DELETE FROM tp WHERE a = 59;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+# any write (update/delete/insert) into t should fail
+UPDATE t SET a = 53, b = "Fifty three, was three" WHERE a = 3;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+INSERT INTO t VALUES (63, "Sixty three, new"), (59, "To be deleted");
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+DELETE FROM t WHERE a = 3;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+ALTER TABLE t ENGINE = 'InnoDB';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+ALTER TABLE tp ENGINE = 'InnoDB';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SHOW CREATE TABLE t;
+Table Create Table
+t CREATE TABLE `t` (
+ `a` int(11) NOT NULL DEFAULT '0',
+ `b` varchar(55) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+SHOW CREATE TABLE tp;
+Table Create Table
+tp CREATE TABLE `tp` (
+ `a` int(11) NOT NULL DEFAULT '0',
+ `b` varchar(55) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (100) ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
+SET DEBUG_SYNC= 'now SIGNAL goto_wait';
+SET DEBUG_SYNC= 'now WAIT_FOR swap_in_progress';
+# Both tables should now be under exclusive lock, even SHOW should fail
+SELECT * FROM t WHERE a = 99;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SELECT * FROM tp WHERE a = 61;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+UPDATE tp SET a = 53, b = concat("Fifty three, was ", b) WHERE a = 63;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+INSERT INTO tp VALUES (63, "Sixty three, new 2"), (59, "To be deleted");
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+DELETE FROM tp WHERE a = 59;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+UPDATE t SET a = 53, b = "Fifty three, was three" WHERE a = 3;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+INSERT INTO t VALUES (63, "Sixty three, new"), (59, "To be deleted");
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+DELETE FROM t WHERE a = 3;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SHOW CREATE TABLE t;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SHOW CREATE TABLE tp;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+ALTER TABLE t ENGINE = 'InnoDB';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+ALTER TABLE tp ENGINE = 'InnoDB';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SET DEBUG_SYNC= 'now SIGNAL goto_rename';
+SET DEBUG_SYNC= 'now WAIT_FOR swap_in_progress';
+# Both tables should now be under exclusive lock
+SELECT * FROM t WHERE a = 99;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SELECT * FROM tp WHERE a = 61;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+UPDATE tp SET a = 53, b = concat("Fifty three, was ", b) WHERE a = 63;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+INSERT INTO tp VALUES (63, "Sixty three, new 2"), (59, "To be deleted");
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+DELETE FROM tp WHERE a = 59;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+UPDATE t SET a = 53, b = "Fifty three, was three" WHERE a = 3;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+INSERT INTO t VALUES (63, "Sixty three, new"), (59, "To be deleted");
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+DELETE FROM t WHERE a = 3;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+ALTER TABLE t ENGINE = 'InnoDB';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+ALTER TABLE tp ENGINE = 'InnoDB';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SHOW CREATE TABLE t;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SHOW CREATE TABLE tp;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SET DEBUG_SYNC= 'now SIGNAL test_done';
+# con1
+# con default
+# Tables should now be as normal
+SHOW CREATE TABLE t;
+Table Create Table
+t CREATE TABLE `t` (
+ `a` int(11) NOT NULL DEFAULT '0',
+ `b` varchar(55) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+SHOW CREATE TABLE tp;
+Table Create Table
+tp CREATE TABLE `tp` (
+ `a` int(11) NOT NULL DEFAULT '0',
+ `b` varchar(55) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (100) ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
+SELECT * FROM tp WHERE a = 99;
+a b
+99 End of values
+SELECT * FROM t WHERE a = 61;
+a b
+61 Sixty one
+UPDATE t SET a = 53, b = "Fifty three, was sixty three" WHERE a = 63;
+INSERT INTO t VALUES (63, "Sixty three, new"), (59, "To be deleted");
+DELETE FROM t WHERE a = 59;
+UPDATE tp SET a = 53, b = "Fifty three, was three" WHERE a = 3;
+INSERT INTO tp VALUES (63, "Sixty three, new"), (59, "To be deleted");
+DELETE FROM tp WHERE a = 3;
+ALTER TABLE t ENGINE = 'InnoDB';
+ALTER TABLE tp ENGINE = 'InnoDB';
+# con default
+SET DEBUG_SYNC= 'RESET';
+SHOW CREATE TABLE t;
+Table Create Table
+t CREATE TABLE `t` (
+ `a` int(11) NOT NULL DEFAULT '0',
+ `b` varchar(55) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+SHOW CREATE TABLE tp;
+Table Create Table
+tp CREATE TABLE `tp` (
+ `a` int(11) NOT NULL DEFAULT '0',
+ `b` varchar(55) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (100) ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
+SELECT * FROM t;
+a b
+10 Ten
+2 First value
+50 Fifty
+53 Fifty three, was sixty three
+61 Sixty one
+62 Sixty two
+63 Sixty three, new
+64 Sixty four
+SELECT * FROM tp;
+a b
+1 First value
+161 161
+162 162
+163 163
+164 164
+200 Two hundred, end of values
+5 Five
+53 Fifty three, was three
+59 To be deleted
+63 Sixty three, new
+99 End of values
+DROP TABLE t, tp, tsp;
diff --git a/mysql-test/suite/parts/r/partition_exchange_memory.result b/mysql-test/suite/parts/r/partition_exchange_memory.result
new file mode 100644
index 00000000000..b6df8259b8c
--- /dev/null
+++ b/mysql-test/suite/parts/r/partition_exchange_memory.result
@@ -0,0 +1,374 @@
+# Test with AUTO_INCREMENT
+CREATE TABLE tp
+(a INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+b varchar(24))
+ENGINE = 'Memory'
+PARTITION BY HASH (a) PARTITIONS 4;
+CREATE TABLE t LIKE tp;
+ALTER TABLE t REMOVE PARTITIONING;
+SHOW CREATE TABLE tp;
+Table Create Table
+tp CREATE TABLE `tp` (
+ `a` int(11) NOT NULL AUTO_INCREMENT,
+ `b` varchar(24) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MEMORY DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY HASH (a)
+PARTITIONS 4 */
+SHOW CREATE TABLE t;
+Table Create Table
+t CREATE TABLE `t` (
+ `a` int(11) NOT NULL AUTO_INCREMENT,
+ `b` varchar(24) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MEMORY DEFAULT CHARSET=latin1
+INSERT INTO tp (b) VALUES ("One"), ("Two"), ("Three"), ("Four"), ("Five"),
+("Six"), ("Seven"), ("Eight"), ("Nine"), ("Ten"), ("Eleven"), ("Twelwe");
+INSERT INTO tp VALUES (97, "Ninety seven");
+INSERT INTO tp VALUES (111, "One hundred eleven");
+INSERT INTO tp VALUES (101, "One hundred one");
+SET INSERT_ID = 13;
+INSERT INTO t (b) VALUES ("Thirteen");
+SET INSERT_ID = 21;
+INSERT INTO t (b) VALUES ("Twenty one");
+SET INSERT_ID = 25;
+INSERT INTO t (b) VALUES ("Twenty five");
+SET INSERT_ID = 55;
+INSERT INTO t (b) VALUES ("Fifty five");
+DELETE FROM tp WHERE a = 111;
+DELETE FROM t WHERE a = 55;
+UPDATE tp SET a = 41 WHERE a = 101;
+UPDATE t SET a = 17 WHERE a = 25;
+SELECT PARTITION_NAME, IF(TABLE_ROWS, 'YES', 'NO') AS HAVE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA ='test' AND TABLE_NAME = 'tp';
+PARTITION_NAME HAVE_ROWS
+p0 YES
+p1 YES
+p2 YES
+p3 YES
+SELECT IF(TABLE_ROWS, 'YES', 'NO') AS HAVE_ROWS FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA ='test' AND TABLE_NAME = 't';
+HAVE_ROWS
+YES
+ALTER TABLE tp EXCHANGE PARTITION p1 WITH TABLE t;
+SELECT PARTITION_NAME, IF(TABLE_ROWS, 'YES', 'NO') AS HAVE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA ='test' AND TABLE_NAME = 'tp';
+PARTITION_NAME HAVE_ROWS
+p0 YES
+p1 YES
+p2 YES
+p3 YES
+SELECT IF(TABLE_ROWS, 'YES', 'NO') AS HAVE_ROWS FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA ='test' AND TABLE_NAME = 't';
+HAVE_ROWS
+YES
+SELECT * FROM tp ORDER BY a;
+a b
+2 Two
+3 Three
+4 Four
+6 Six
+7 Seven
+8 Eight
+10 Ten
+11 Eleven
+12 Twelwe
+13 Thirteen
+17 Twenty five
+21 Twenty one
+SELECT * FROM t ORDER BY a;
+a b
+1 One
+5 Five
+9 Nine
+41 One hundred one
+97 Ninety seven
+SHOW CREATE TABLE tp;
+Table Create Table
+tp CREATE TABLE `tp` (
+ `a` int(11) NOT NULL AUTO_INCREMENT,
+ `b` varchar(24) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MEMORY AUTO_INCREMENT=112 DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY HASH (a)
+PARTITIONS 4 */
+SHOW CREATE TABLE t;
+Table Create Table
+t CREATE TABLE `t` (
+ `a` int(11) NOT NULL AUTO_INCREMENT,
+ `b` varchar(24) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MEMORY AUTO_INCREMENT=102 DEFAULT CHARSET=latin1
+DROP TABLE tp, t;
+CREATE TABLE t
+(a INT,
+b VARCHAR(55),
+PRIMARY KEY (a))
+ENGINE = 'Memory';
+CREATE TABLE tp
+(a INT,
+b VARCHAR(55),
+PRIMARY KEY (a))
+ENGINE = 'Memory'
+PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (100),
+PARTITION p1 VALUES LESS THAN MAXVALUE);
+CREATE TABLE tsp
+(a INT,
+b VARCHAR(55),
+PRIMARY KEY (a))
+ENGINE = 'Memory'
+PARTITION BY RANGE (a)
+SUBPARTITION BY HASH(a)
+(PARTITION p0 VALUES LESS THAN (100)
+(SUBPARTITION sp0,
+SUBPARTITION sp1),
+PARTITION p1 VALUES LESS THAN MAXVALUE
+(SUBPARTITION sp2,
+SUBPARTITION sp3));
+INSERT INTO t VALUES (1, "First value"), (3, "Three"), (5, "Five"), (99, "End of values");
+INSERT INTO tp VALUES (2, "First value"), (10, "Ten"), (50, "Fifty"), (200, "Two hundred, end of values"), (61, "Sixty one"), (62, "Sixty two"), (63, "Sixty three"), (64, "Sixty four"), (161, "161"), (162, "162"), (163, "163"), (164, "164");
+INSERT INTO tsp VALUES (2, "First value"), (10, "Ten"), (50, "Fifty"), (200, "Two hundred, end of values"), (61, "Sixty one"), (62, "Sixty two"), (63, "Sixty three"), (64, "Sixty four"), (161, "161"), (162, "162"), (163, "163"), (164, "164");
+SELECT * FROM t;
+a b
+1 First value
+3 Three
+5 Five
+99 End of values
+SELECT * FROM tp;
+a b
+10 Ten
+161 161
+162 162
+163 163
+164 164
+2 First value
+200 Two hundred, end of values
+50 Fifty
+61 Sixty one
+62 Sixty two
+63 Sixty three
+64 Sixty four
+# Start by testing read/write locking
+SET AUTOCOMMIT = 1;
+# con1
+SET DEBUG_SYNC= 'swap_partition_after_compare_tables SIGNAL swap_in_progress WAIT_FOR goto_verification';
+SET DEBUG_SYNC= 'swap_partition_first_row_read SIGNAL swap_in_progress WAIT_FOR goto_wait';
+SET DEBUG_SYNC= 'swap_partition_after_wait SIGNAL swap_in_progress WAIT_FOR goto_rename';
+SET DEBUG_SYNC= 'swap_partition_before_rename SIGNAL swap_in_progress WAIT_FOR test_done';
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t;
+# con default
+SET DEBUG_SYNC= 'now WAIT_FOR swap_in_progress';
+# select from t and select/update/delete/insert from tp should work
+SELECT * FROM t WHERE a = 99;
+a b
+99 End of values
+SELECT * FROM tp WHERE a = 61;
+a b
+61 Sixty one
+# any write (update/delete/insert) into t or tp should fail
+SET SESSION lock_wait_timeout=1;
+UPDATE tp SET a = 53, b = concat("Fifty three, was ", b) WHERE a = 63;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+INSERT INTO tp VALUES (63, "Sixty three, new"), (59, "To be deleted");
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+DELETE FROM tp WHERE a = 59;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+UPDATE t SET a = 53, b = "Fifty three, was three" WHERE a = 3;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+INSERT INTO t VALUES (63, "Sixty three, new"), (59, "To be deleted");
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+DELETE FROM t WHERE a = 3;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+ALTER TABLE t ENGINE = 'Memory';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+ALTER TABLE tp ENGINE = 'Memory';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SHOW CREATE TABLE t;
+Table Create Table
+t CREATE TABLE `t` (
+ `a` int(11) NOT NULL DEFAULT '0',
+ `b` varchar(55) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MEMORY DEFAULT CHARSET=latin1
+SHOW CREATE TABLE tp;
+Table Create Table
+tp CREATE TABLE `tp` (
+ `a` int(11) NOT NULL DEFAULT '0',
+ `b` varchar(55) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MEMORY DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (100) ENGINE = MEMORY,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = MEMORY) */
+SET DEBUG_SYNC= 'now SIGNAL goto_verification';
+SET DEBUG_SYNC= 'now WAIT_FOR swap_in_progress';
+# select from t and select/update/delete/insert from tp should work
+SELECT * FROM t WHERE a = 99;
+a b
+99 End of values
+SELECT * FROM tp WHERE a = 61;
+a b
+61 Sixty one
+UPDATE tp SET a = 43, b = concat("Fifty three, was ", b) WHERE a = 63;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+INSERT INTO tp VALUES (63, "Sixty three, new 2"), (59, "To be deleted");
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+DELETE FROM tp WHERE a = 59;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+# any write (update/delete/insert) into t should fail
+UPDATE t SET a = 53, b = "Fifty three, was three" WHERE a = 3;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+INSERT INTO t VALUES (63, "Sixty three, new"), (59, "To be deleted");
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+DELETE FROM t WHERE a = 3;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+ALTER TABLE t ENGINE = 'Memory';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+ALTER TABLE tp ENGINE = 'Memory';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SHOW CREATE TABLE t;
+Table Create Table
+t CREATE TABLE `t` (
+ `a` int(11) NOT NULL DEFAULT '0',
+ `b` varchar(55) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MEMORY DEFAULT CHARSET=latin1
+SHOW CREATE TABLE tp;
+Table Create Table
+tp CREATE TABLE `tp` (
+ `a` int(11) NOT NULL DEFAULT '0',
+ `b` varchar(55) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MEMORY DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (100) ENGINE = MEMORY,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = MEMORY) */
+SET DEBUG_SYNC= 'now SIGNAL goto_wait';
+SET DEBUG_SYNC= 'now WAIT_FOR swap_in_progress';
+# Both tables should now be under exclusive lock, even SHOW should fail
+SELECT * FROM t WHERE a = 99;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SELECT * FROM tp WHERE a = 61;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+UPDATE tp SET a = 53, b = concat("Fifty three, was ", b) WHERE a = 63;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+INSERT INTO tp VALUES (63, "Sixty three, new 2"), (59, "To be deleted");
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+DELETE FROM tp WHERE a = 59;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+UPDATE t SET a = 53, b = "Fifty three, was three" WHERE a = 3;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+INSERT INTO t VALUES (63, "Sixty three, new"), (59, "To be deleted");
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+DELETE FROM t WHERE a = 3;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SHOW CREATE TABLE t;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SHOW CREATE TABLE tp;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+ALTER TABLE t ENGINE = 'Memory';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+ALTER TABLE tp ENGINE = 'Memory';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SET DEBUG_SYNC= 'now SIGNAL goto_rename';
+SET DEBUG_SYNC= 'now WAIT_FOR swap_in_progress';
+# Both tables should now be under exclusive lock
+SELECT * FROM t WHERE a = 99;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SELECT * FROM tp WHERE a = 61;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+UPDATE tp SET a = 53, b = concat("Fifty three, was ", b) WHERE a = 63;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+INSERT INTO tp VALUES (63, "Sixty three, new 2"), (59, "To be deleted");
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+DELETE FROM tp WHERE a = 59;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+UPDATE t SET a = 53, b = "Fifty three, was three" WHERE a = 3;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+INSERT INTO t VALUES (63, "Sixty three, new"), (59, "To be deleted");
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+DELETE FROM t WHERE a = 3;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+ALTER TABLE t ENGINE = 'Memory';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+ALTER TABLE tp ENGINE = 'Memory';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SHOW CREATE TABLE t;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SHOW CREATE TABLE tp;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SET DEBUG_SYNC= 'now SIGNAL test_done';
+# con1
+# con default
+# Tables should now be as normal
+SHOW CREATE TABLE t;
+Table Create Table
+t CREATE TABLE `t` (
+ `a` int(11) NOT NULL DEFAULT '0',
+ `b` varchar(55) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MEMORY DEFAULT CHARSET=latin1
+SHOW CREATE TABLE tp;
+Table Create Table
+tp CREATE TABLE `tp` (
+ `a` int(11) NOT NULL DEFAULT '0',
+ `b` varchar(55) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MEMORY DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (100) ENGINE = MEMORY,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = MEMORY) */
+SELECT * FROM tp WHERE a = 99;
+a b
+99 End of values
+SELECT * FROM t WHERE a = 61;
+a b
+61 Sixty one
+UPDATE t SET a = 53, b = "Fifty three, was sixty three" WHERE a = 63;
+INSERT INTO t VALUES (63, "Sixty three, new"), (59, "To be deleted");
+DELETE FROM t WHERE a = 59;
+UPDATE tp SET a = 53, b = "Fifty three, was three" WHERE a = 3;
+INSERT INTO tp VALUES (63, "Sixty three, new"), (59, "To be deleted");
+DELETE FROM tp WHERE a = 3;
+ALTER TABLE t ENGINE = 'Memory';
+ALTER TABLE tp ENGINE = 'Memory';
+# con default
+SET DEBUG_SYNC= 'RESET';
+SHOW CREATE TABLE t;
+Table Create Table
+t CREATE TABLE `t` (
+ `a` int(11) NOT NULL DEFAULT '0',
+ `b` varchar(55) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MEMORY DEFAULT CHARSET=latin1
+SHOW CREATE TABLE tp;
+Table Create Table
+tp CREATE TABLE `tp` (
+ `a` int(11) NOT NULL DEFAULT '0',
+ `b` varchar(55) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MEMORY DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (100) ENGINE = MEMORY,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = MEMORY) */
+SELECT * FROM t;
+a b
+10 Ten
+2 First value
+50 Fifty
+53 Fifty three, was sixty three
+61 Sixty one
+62 Sixty two
+63 Sixty three, new
+64 Sixty four
+SELECT * FROM tp;
+a b
+1 First value
+161 161
+162 162
+163 163
+164 164
+200 Two hundred, end of values
+5 Five
+53 Fifty three, was three
+59 To be deleted
+63 Sixty three, new
+99 End of values
+DROP TABLE t, tp, tsp;
diff --git a/mysql-test/suite/parts/r/partition_exchange_myisam.result b/mysql-test/suite/parts/r/partition_exchange_myisam.result
new file mode 100644
index 00000000000..932891d74fa
--- /dev/null
+++ b/mysql-test/suite/parts/r/partition_exchange_myisam.result
@@ -0,0 +1,374 @@
+# Test with AUTO_INCREMENT
+CREATE TABLE tp
+(a INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+b varchar(24))
+ENGINE = 'MyISAM'
+PARTITION BY HASH (a) PARTITIONS 4;
+CREATE TABLE t LIKE tp;
+ALTER TABLE t REMOVE PARTITIONING;
+SHOW CREATE TABLE tp;
+Table Create Table
+tp CREATE TABLE `tp` (
+ `a` int(11) NOT NULL AUTO_INCREMENT,
+ `b` varchar(24) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY HASH (a)
+PARTITIONS 4 */
+SHOW CREATE TABLE t;
+Table Create Table
+t CREATE TABLE `t` (
+ `a` int(11) NOT NULL AUTO_INCREMENT,
+ `b` varchar(24) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+INSERT INTO tp (b) VALUES ("One"), ("Two"), ("Three"), ("Four"), ("Five"),
+("Six"), ("Seven"), ("Eight"), ("Nine"), ("Ten"), ("Eleven"), ("Twelwe");
+INSERT INTO tp VALUES (97, "Ninety seven");
+INSERT INTO tp VALUES (111, "One hundred eleven");
+INSERT INTO tp VALUES (101, "One hundred one");
+SET INSERT_ID = 13;
+INSERT INTO t (b) VALUES ("Thirteen");
+SET INSERT_ID = 21;
+INSERT INTO t (b) VALUES ("Twenty one");
+SET INSERT_ID = 25;
+INSERT INTO t (b) VALUES ("Twenty five");
+SET INSERT_ID = 55;
+INSERT INTO t (b) VALUES ("Fifty five");
+DELETE FROM tp WHERE a = 111;
+DELETE FROM t WHERE a = 55;
+UPDATE tp SET a = 41 WHERE a = 101;
+UPDATE t SET a = 17 WHERE a = 25;
+SELECT PARTITION_NAME, IF(TABLE_ROWS, 'YES', 'NO') AS HAVE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA ='test' AND TABLE_NAME = 'tp';
+PARTITION_NAME HAVE_ROWS
+p0 YES
+p1 YES
+p2 YES
+p3 YES
+SELECT IF(TABLE_ROWS, 'YES', 'NO') AS HAVE_ROWS FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA ='test' AND TABLE_NAME = 't';
+HAVE_ROWS
+YES
+ALTER TABLE tp EXCHANGE PARTITION p1 WITH TABLE t;
+SELECT PARTITION_NAME, IF(TABLE_ROWS, 'YES', 'NO') AS HAVE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA ='test' AND TABLE_NAME = 'tp';
+PARTITION_NAME HAVE_ROWS
+p0 YES
+p1 YES
+p2 YES
+p3 YES
+SELECT IF(TABLE_ROWS, 'YES', 'NO') AS HAVE_ROWS FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA ='test' AND TABLE_NAME = 't';
+HAVE_ROWS
+YES
+SELECT * FROM tp ORDER BY a;
+a b
+2 Two
+3 Three
+4 Four
+6 Six
+7 Seven
+8 Eight
+10 Ten
+11 Eleven
+12 Twelwe
+13 Thirteen
+17 Twenty five
+21 Twenty one
+SELECT * FROM t ORDER BY a;
+a b
+1 One
+5 Five
+9 Nine
+41 One hundred one
+97 Ninety seven
+SHOW CREATE TABLE tp;
+Table Create Table
+tp CREATE TABLE `tp` (
+ `a` int(11) NOT NULL AUTO_INCREMENT,
+ `b` varchar(24) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM AUTO_INCREMENT=112 DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY HASH (a)
+PARTITIONS 4 */
+SHOW CREATE TABLE t;
+Table Create Table
+t CREATE TABLE `t` (
+ `a` int(11) NOT NULL AUTO_INCREMENT,
+ `b` varchar(24) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM AUTO_INCREMENT=102 DEFAULT CHARSET=latin1
+DROP TABLE tp, t;
+CREATE TABLE t
+(a INT,
+b VARCHAR(55),
+PRIMARY KEY (a))
+ENGINE = 'MyISAM';
+CREATE TABLE tp
+(a INT,
+b VARCHAR(55),
+PRIMARY KEY (a))
+ENGINE = 'MyISAM'
+PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (100),
+PARTITION p1 VALUES LESS THAN MAXVALUE);
+CREATE TABLE tsp
+(a INT,
+b VARCHAR(55),
+PRIMARY KEY (a))
+ENGINE = 'MyISAM'
+PARTITION BY RANGE (a)
+SUBPARTITION BY HASH(a)
+(PARTITION p0 VALUES LESS THAN (100)
+(SUBPARTITION sp0,
+SUBPARTITION sp1),
+PARTITION p1 VALUES LESS THAN MAXVALUE
+(SUBPARTITION sp2,
+SUBPARTITION sp3));
+INSERT INTO t VALUES (1, "First value"), (3, "Three"), (5, "Five"), (99, "End of values");
+INSERT INTO tp VALUES (2, "First value"), (10, "Ten"), (50, "Fifty"), (200, "Two hundred, end of values"), (61, "Sixty one"), (62, "Sixty two"), (63, "Sixty three"), (64, "Sixty four"), (161, "161"), (162, "162"), (163, "163"), (164, "164");
+INSERT INTO tsp VALUES (2, "First value"), (10, "Ten"), (50, "Fifty"), (200, "Two hundred, end of values"), (61, "Sixty one"), (62, "Sixty two"), (63, "Sixty three"), (64, "Sixty four"), (161, "161"), (162, "162"), (163, "163"), (164, "164");
+SELECT * FROM t;
+a b
+1 First value
+3 Three
+5 Five
+99 End of values
+SELECT * FROM tp;
+a b
+10 Ten
+161 161
+162 162
+163 163
+164 164
+2 First value
+200 Two hundred, end of values
+50 Fifty
+61 Sixty one
+62 Sixty two
+63 Sixty three
+64 Sixty four
+# Start by testing read/write locking
+SET AUTOCOMMIT = 1;
+# con1
+SET DEBUG_SYNC= 'swap_partition_after_compare_tables SIGNAL swap_in_progress WAIT_FOR goto_verification';
+SET DEBUG_SYNC= 'swap_partition_first_row_read SIGNAL swap_in_progress WAIT_FOR goto_wait';
+SET DEBUG_SYNC= 'swap_partition_after_wait SIGNAL swap_in_progress WAIT_FOR goto_rename';
+SET DEBUG_SYNC= 'swap_partition_before_rename SIGNAL swap_in_progress WAIT_FOR test_done';
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t;
+# con default
+SET DEBUG_SYNC= 'now WAIT_FOR swap_in_progress';
+# select from t and select/update/delete/insert from tp should work
+SELECT * FROM t WHERE a = 99;
+a b
+99 End of values
+SELECT * FROM tp WHERE a = 61;
+a b
+61 Sixty one
+# any write (update/delete/insert) into t or tp should fail
+SET SESSION lock_wait_timeout=1;
+UPDATE tp SET a = 53, b = concat("Fifty three, was ", b) WHERE a = 63;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+INSERT INTO tp VALUES (63, "Sixty three, new"), (59, "To be deleted");
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+DELETE FROM tp WHERE a = 59;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+UPDATE t SET a = 53, b = "Fifty three, was three" WHERE a = 3;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+INSERT INTO t VALUES (63, "Sixty three, new"), (59, "To be deleted");
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+DELETE FROM t WHERE a = 3;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+ALTER TABLE t ENGINE = 'MyISAM';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+ALTER TABLE tp ENGINE = 'MyISAM';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SHOW CREATE TABLE t;
+Table Create Table
+t CREATE TABLE `t` (
+ `a` int(11) NOT NULL DEFAULT '0',
+ `b` varchar(55) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+SHOW CREATE TABLE tp;
+Table Create Table
+tp CREATE TABLE `tp` (
+ `a` int(11) NOT NULL DEFAULT '0',
+ `b` varchar(55) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (100) ENGINE = MyISAM,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
+SET DEBUG_SYNC= 'now SIGNAL goto_verification';
+SET DEBUG_SYNC= 'now WAIT_FOR swap_in_progress';
+# select from t and select/update/delete/insert from tp should work
+SELECT * FROM t WHERE a = 99;
+a b
+99 End of values
+SELECT * FROM tp WHERE a = 61;
+a b
+61 Sixty one
+UPDATE tp SET a = 43, b = concat("Fifty three, was ", b) WHERE a = 63;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+INSERT INTO tp VALUES (63, "Sixty three, new 2"), (59, "To be deleted");
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+DELETE FROM tp WHERE a = 59;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+# any write (update/delete/insert) into t should fail
+UPDATE t SET a = 53, b = "Fifty three, was three" WHERE a = 3;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+INSERT INTO t VALUES (63, "Sixty three, new"), (59, "To be deleted");
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+DELETE FROM t WHERE a = 3;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+ALTER TABLE t ENGINE = 'MyISAM';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+ALTER TABLE tp ENGINE = 'MyISAM';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SHOW CREATE TABLE t;
+Table Create Table
+t CREATE TABLE `t` (
+ `a` int(11) NOT NULL DEFAULT '0',
+ `b` varchar(55) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+SHOW CREATE TABLE tp;
+Table Create Table
+tp CREATE TABLE `tp` (
+ `a` int(11) NOT NULL DEFAULT '0',
+ `b` varchar(55) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (100) ENGINE = MyISAM,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
+SET DEBUG_SYNC= 'now SIGNAL goto_wait';
+SET DEBUG_SYNC= 'now WAIT_FOR swap_in_progress';
+# Both tables should now be under exclusive lock, even SHOW should fail
+SELECT * FROM t WHERE a = 99;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SELECT * FROM tp WHERE a = 61;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+UPDATE tp SET a = 53, b = concat("Fifty three, was ", b) WHERE a = 63;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+INSERT INTO tp VALUES (63, "Sixty three, new 2"), (59, "To be deleted");
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+DELETE FROM tp WHERE a = 59;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+UPDATE t SET a = 53, b = "Fifty three, was three" WHERE a = 3;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+INSERT INTO t VALUES (63, "Sixty three, new"), (59, "To be deleted");
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+DELETE FROM t WHERE a = 3;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SHOW CREATE TABLE t;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SHOW CREATE TABLE tp;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+ALTER TABLE t ENGINE = 'MyISAM';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+ALTER TABLE tp ENGINE = 'MyISAM';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SET DEBUG_SYNC= 'now SIGNAL goto_rename';
+SET DEBUG_SYNC= 'now WAIT_FOR swap_in_progress';
+# Both tables should now be under exclusive lock
+SELECT * FROM t WHERE a = 99;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SELECT * FROM tp WHERE a = 61;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+UPDATE tp SET a = 53, b = concat("Fifty three, was ", b) WHERE a = 63;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+INSERT INTO tp VALUES (63, "Sixty three, new 2"), (59, "To be deleted");
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+DELETE FROM tp WHERE a = 59;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+UPDATE t SET a = 53, b = "Fifty three, was three" WHERE a = 3;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+INSERT INTO t VALUES (63, "Sixty three, new"), (59, "To be deleted");
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+DELETE FROM t WHERE a = 3;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+ALTER TABLE t ENGINE = 'MyISAM';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+ALTER TABLE tp ENGINE = 'MyISAM';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SHOW CREATE TABLE t;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SHOW CREATE TABLE tp;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SET DEBUG_SYNC= 'now SIGNAL test_done';
+# con1
+# con default
+# Tables should now be as normal
+SHOW CREATE TABLE t;
+Table Create Table
+t CREATE TABLE `t` (
+ `a` int(11) NOT NULL DEFAULT '0',
+ `b` varchar(55) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+SHOW CREATE TABLE tp;
+Table Create Table
+tp CREATE TABLE `tp` (
+ `a` int(11) NOT NULL DEFAULT '0',
+ `b` varchar(55) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (100) ENGINE = MyISAM,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
+SELECT * FROM tp WHERE a = 99;
+a b
+99 End of values
+SELECT * FROM t WHERE a = 61;
+a b
+61 Sixty one
+UPDATE t SET a = 53, b = "Fifty three, was sixty three" WHERE a = 63;
+INSERT INTO t VALUES (63, "Sixty three, new"), (59, "To be deleted");
+DELETE FROM t WHERE a = 59;
+UPDATE tp SET a = 53, b = "Fifty three, was three" WHERE a = 3;
+INSERT INTO tp VALUES (63, "Sixty three, new"), (59, "To be deleted");
+DELETE FROM tp WHERE a = 3;
+ALTER TABLE t ENGINE = 'MyISAM';
+ALTER TABLE tp ENGINE = 'MyISAM';
+# con default
+SET DEBUG_SYNC= 'RESET';
+SHOW CREATE TABLE t;
+Table Create Table
+t CREATE TABLE `t` (
+ `a` int(11) NOT NULL DEFAULT '0',
+ `b` varchar(55) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+SHOW CREATE TABLE tp;
+Table Create Table
+tp CREATE TABLE `tp` (
+ `a` int(11) NOT NULL DEFAULT '0',
+ `b` varchar(55) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (100) ENGINE = MyISAM,
+ PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
+SELECT * FROM t;
+a b
+10 Ten
+2 First value
+50 Fifty
+53 Fifty three, was sixty three
+61 Sixty one
+62 Sixty two
+63 Sixty three, new
+64 Sixty four
+SELECT * FROM tp;
+a b
+1 First value
+161 161
+162 162
+163 163
+164 164
+200 Two hundred, end of values
+5 Five
+53 Fifty three, was three
+59 To be deleted
+63 Sixty three, new
+99 End of values
+DROP TABLE t, tp, tsp;
diff --git a/mysql-test/suite/parts/r/partition_mdev6067.result b/mysql-test/suite/parts/r/partition_mdev6067.result
index 7b123d7c17c..4737d3679f3 100644
--- a/mysql-test/suite/parts/r/partition_mdev6067.result
+++ b/mysql-test/suite/parts/r/partition_mdev6067.result
@@ -3,15 +3,15 @@ PARTITION BY KEY (a) PARTITIONS 2;
INSERT INTO t1 VALUES (1,1);
INSERT INTO t1 VALUES (2,2), (3,8);
INSERT INTO t1 VALUES (4,16);
-show binlog events in 'master-bin.000001' from <binlog_start>;
+include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (1,1)
master-bin.000001 # Xid # # COMMIT /* XID */
-master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (2,2), (3,8)
master-bin.000001 # Xid # # COMMIT /* XID */
-master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (4,16)
master-bin.000001 # Xid # # COMMIT /* XID */
DROP TABLE t1;
@@ -21,18 +21,18 @@ PARTITION BY KEY (a) PARTITIONS 2;
INSERT INTO t1 VALUES (1,1);
INSERT INTO t1 VALUES (2,2), (3,8);
INSERT INTO t1 VALUES (4,16);
-show binlog events in 'master-bin.000001' from <binlog_start>;
+include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
+master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
master-bin.000001 # Xid # # COMMIT /* XID */
-master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
+master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
master-bin.000001 # Xid # # COMMIT /* XID */
-master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
+master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
master-bin.000001 # Xid # # COMMIT /* XID */
DROP TABLE t1;
diff --git a/mysql-test/suite/parts/r/partition_mgm_lc0_archive.result b/mysql-test/suite/parts/r/partition_mgm_lc0_archive.result
index f4d76874b4c..330258094ef 100644
--- a/mysql-test/suite/parts/r/partition_mgm_lc0_archive.result
+++ b/mysql-test/suite/parts/r/partition_mgm_lc0_archive.result
@@ -32,7 +32,7 @@ ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
@@ -88,6 +88,78 @@ TableA CREATE TABLE `TableA` (
(PARTITION parta ENGINE = ARCHIVE,
PARTITION partB ENGINE = ARCHIVE,
PARTITION Partc ENGINE = ARCHIVE) */
+# Test of EXCHANGE PARTITION WITH TABLE
+SELECT PARTITION_NAME, TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA ='MySQL_Test_DB' AND TABLE_NAME = 'TableA';
+PARTITION_NAME TABLE_ROWS
+parta 4
+partB 4
+Partc 4
+CREATE TABLE TableB LIKE TableA;
+ALTER TABLE TableB REMOVE PARTITIONING;
+ALTER TABLE TableA EXCHANGE PARTITION parta WITH TABLE TableB;
+SELECT * FROM TableA;
+a
+1
+12
+2
+3
+6
+7
+8
+9
+SHOW CREATE TABLE TableA;
+Table Create Table
+TableA CREATE TABLE `TableA` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=ARCHIVE DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+(PARTITION parta ENGINE = ARCHIVE,
+ PARTITION partB ENGINE = ARCHIVE,
+ PARTITION Partc ENGINE = ARCHIVE) */
+SELECT * FROM TableB;
+a
+10
+11
+4
+5
+SHOW CREATE TABLE TableB;
+Table Create Table
+TableB CREATE TABLE `TableB` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=ARCHIVE DEFAULT CHARSET=latin1
+SELECT PARTITION_NAME, IF(TABLE_ROWS, 'YES', 'NO') AS HAVE_TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA ='MySQL_Test_DB' AND TABLE_NAME = 'TableA';
+PARTITION_NAME HAVE_TABLE_ROWS
+parta NO
+partB YES
+Partc YES
+ALTER TABLE TableA EXCHANGE PARTITION parta WITH TABLE TableB;
+INSERT INTO TableB VALUES (11);
+ALTER TABLE TableA EXCHANGE PARTITION Partc WITH TABLE TableB;
+ERROR HY000: Found a row that does not match the partition
+DROP TABLE TableB;
+SELECT * FROM TableA;
+a
+1
+10
+11
+12
+2
+3
+4
+5
+6
+7
+8
+9
+SHOW CREATE TABLE TableA;
+Table Create Table
+TableA CREATE TABLE `TableA` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=ARCHIVE DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+(PARTITION parta ENGINE = ARCHIVE,
+ PARTITION partB ENGINE = ARCHIVE,
+ PARTITION Partc ENGINE = ARCHIVE) */
# Test of REORGANIZE PARTITIONS
# Should not work on HASH/KEY
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
@@ -237,7 +309,7 @@ PARTITION BY HASH (a)
PARTITION partA ,
PARTITION Parta ,
PARTITION PartA );
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
# Creating Hash partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'Archive'
@@ -268,7 +340,7 @@ ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
@@ -493,7 +565,7 @@ a
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES LESS THAN (MAXVALUE));
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES LESS THAN (16),
PARTITION Partf VALUES LESS THAN (19),
@@ -724,7 +796,7 @@ a
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES IN (0));
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES IN (16),
PARTITION Partf VALUES IN (19),
diff --git a/mysql-test/suite/parts/r/partition_mgm_lc0_innodb.result b/mysql-test/suite/parts/r/partition_mgm_lc0_innodb.result
index 19f16780d13..5b54e9c571f 100644
--- a/mysql-test/suite/parts/r/partition_mgm_lc0_innodb.result
+++ b/mysql-test/suite/parts/r/partition_mgm_lc0_innodb.result
@@ -32,7 +32,7 @@ ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
@@ -88,6 +88,78 @@ TableA CREATE TABLE `TableA` (
(PARTITION parta ENGINE = InnoDB,
PARTITION partB ENGINE = InnoDB,
PARTITION Partc ENGINE = InnoDB) */
+# Test of EXCHANGE PARTITION WITH TABLE
+SELECT PARTITION_NAME, TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA ='MySQL_Test_DB' AND TABLE_NAME = 'TableA';
+PARTITION_NAME TABLE_ROWS
+parta 4
+partB 4
+Partc 4
+CREATE TABLE TableB LIKE TableA;
+ALTER TABLE TableB REMOVE PARTITIONING;
+ALTER TABLE TableA EXCHANGE PARTITION parta WITH TABLE TableB;
+SELECT * FROM TableA;
+a
+1
+12
+2
+3
+6
+7
+8
+9
+SHOW CREATE TABLE TableA;
+Table Create Table
+TableA CREATE TABLE `TableA` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+(PARTITION parta ENGINE = InnoDB,
+ PARTITION partB ENGINE = InnoDB,
+ PARTITION Partc ENGINE = InnoDB) */
+SELECT * FROM TableB;
+a
+10
+11
+4
+5
+SHOW CREATE TABLE TableB;
+Table Create Table
+TableB CREATE TABLE `TableB` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+SELECT PARTITION_NAME, IF(TABLE_ROWS, 'YES', 'NO') AS HAVE_TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA ='MySQL_Test_DB' AND TABLE_NAME = 'TableA';
+PARTITION_NAME HAVE_TABLE_ROWS
+parta NO
+partB YES
+Partc YES
+ALTER TABLE TableA EXCHANGE PARTITION parta WITH TABLE TableB;
+INSERT INTO TableB VALUES (11);
+ALTER TABLE TableA EXCHANGE PARTITION Partc WITH TABLE TableB;
+ERROR HY000: Found a row that does not match the partition
+DROP TABLE TableB;
+SELECT * FROM TableA;
+a
+1
+10
+11
+12
+2
+3
+4
+5
+6
+7
+8
+9
+SHOW CREATE TABLE TableA;
+Table Create Table
+TableA CREATE TABLE `TableA` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+(PARTITION parta ENGINE = InnoDB,
+ PARTITION partB ENGINE = InnoDB,
+ PARTITION Partc ENGINE = InnoDB) */
# Test of REORGANIZE PARTITIONS
# Should not work on HASH/KEY
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
@@ -237,7 +309,7 @@ PARTITION BY HASH (a)
PARTITION partA ,
PARTITION Parta ,
PARTITION PartA );
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
# Creating Hash partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'InnoDB'
@@ -268,7 +340,7 @@ ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
@@ -493,7 +565,7 @@ a
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES LESS THAN (MAXVALUE));
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES LESS THAN (16),
PARTITION Partf VALUES LESS THAN (19),
@@ -724,7 +796,7 @@ a
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES IN (0));
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES IN (16),
PARTITION Partf VALUES IN (19),
diff --git a/mysql-test/suite/parts/r/partition_mgm_lc0_memory.result b/mysql-test/suite/parts/r/partition_mgm_lc0_memory.result
index 69a43b64d87..dd4bed89ea8 100644
--- a/mysql-test/suite/parts/r/partition_mgm_lc0_memory.result
+++ b/mysql-test/suite/parts/r/partition_mgm_lc0_memory.result
@@ -32,7 +32,7 @@ ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
@@ -88,6 +88,78 @@ TableA CREATE TABLE `TableA` (
(PARTITION parta ENGINE = MEMORY,
PARTITION partB ENGINE = MEMORY,
PARTITION Partc ENGINE = MEMORY) */
+# Test of EXCHANGE PARTITION WITH TABLE
+SELECT PARTITION_NAME, TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA ='MySQL_Test_DB' AND TABLE_NAME = 'TableA';
+PARTITION_NAME TABLE_ROWS
+parta 4
+partB 4
+Partc 4
+CREATE TABLE TableB LIKE TableA;
+ALTER TABLE TableB REMOVE PARTITIONING;
+ALTER TABLE TableA EXCHANGE PARTITION parta WITH TABLE TableB;
+SELECT * FROM TableA;
+a
+1
+12
+2
+3
+6
+7
+8
+9
+SHOW CREATE TABLE TableA;
+Table Create Table
+TableA CREATE TABLE `TableA` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=MEMORY DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+(PARTITION parta ENGINE = MEMORY,
+ PARTITION partB ENGINE = MEMORY,
+ PARTITION Partc ENGINE = MEMORY) */
+SELECT * FROM TableB;
+a
+10
+11
+4
+5
+SHOW CREATE TABLE TableB;
+Table Create Table
+TableB CREATE TABLE `TableB` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=MEMORY DEFAULT CHARSET=latin1
+SELECT PARTITION_NAME, IF(TABLE_ROWS, 'YES', 'NO') AS HAVE_TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA ='MySQL_Test_DB' AND TABLE_NAME = 'TableA';
+PARTITION_NAME HAVE_TABLE_ROWS
+parta NO
+partB YES
+Partc YES
+ALTER TABLE TableA EXCHANGE PARTITION parta WITH TABLE TableB;
+INSERT INTO TableB VALUES (11);
+ALTER TABLE TableA EXCHANGE PARTITION Partc WITH TABLE TableB;
+ERROR HY000: Found a row that does not match the partition
+DROP TABLE TableB;
+SELECT * FROM TableA;
+a
+1
+10
+11
+12
+2
+3
+4
+5
+6
+7
+8
+9
+SHOW CREATE TABLE TableA;
+Table Create Table
+TableA CREATE TABLE `TableA` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=MEMORY DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+(PARTITION parta ENGINE = MEMORY,
+ PARTITION partB ENGINE = MEMORY,
+ PARTITION Partc ENGINE = MEMORY) */
# Test of REORGANIZE PARTITIONS
# Should not work on HASH/KEY
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
@@ -237,7 +309,7 @@ PARTITION BY HASH (a)
PARTITION partA ,
PARTITION Parta ,
PARTITION PartA );
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
# Creating Hash partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'Memory'
@@ -268,7 +340,7 @@ ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
@@ -493,7 +565,7 @@ a
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES LESS THAN (MAXVALUE));
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES LESS THAN (16),
PARTITION Partf VALUES LESS THAN (19),
@@ -724,7 +796,7 @@ a
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES IN (0));
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES IN (16),
PARTITION Partf VALUES IN (19),
diff --git a/mysql-test/suite/parts/r/partition_mgm_lc0_myisam.result b/mysql-test/suite/parts/r/partition_mgm_lc0_myisam.result
index 9b4e85be9d0..b01279017fe 100644
--- a/mysql-test/suite/parts/r/partition_mgm_lc0_myisam.result
+++ b/mysql-test/suite/parts/r/partition_mgm_lc0_myisam.result
@@ -32,7 +32,7 @@ ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
@@ -88,6 +88,78 @@ TableA CREATE TABLE `TableA` (
(PARTITION parta ENGINE = MyISAM,
PARTITION partB ENGINE = MyISAM,
PARTITION Partc ENGINE = MyISAM) */
+# Test of EXCHANGE PARTITION WITH TABLE
+SELECT PARTITION_NAME, TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA ='MySQL_Test_DB' AND TABLE_NAME = 'TableA';
+PARTITION_NAME TABLE_ROWS
+parta 4
+partB 4
+Partc 4
+CREATE TABLE TableB LIKE TableA;
+ALTER TABLE TableB REMOVE PARTITIONING;
+ALTER TABLE TableA EXCHANGE PARTITION parta WITH TABLE TableB;
+SELECT * FROM TableA;
+a
+1
+12
+2
+3
+6
+7
+8
+9
+SHOW CREATE TABLE TableA;
+Table Create Table
+TableA CREATE TABLE `TableA` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+(PARTITION parta ENGINE = MyISAM,
+ PARTITION partB ENGINE = MyISAM,
+ PARTITION Partc ENGINE = MyISAM) */
+SELECT * FROM TableB;
+a
+10
+11
+4
+5
+SHOW CREATE TABLE TableB;
+Table Create Table
+TableB CREATE TABLE `TableB` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+SELECT PARTITION_NAME, IF(TABLE_ROWS, 'YES', 'NO') AS HAVE_TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA ='MySQL_Test_DB' AND TABLE_NAME = 'TableA';
+PARTITION_NAME HAVE_TABLE_ROWS
+parta NO
+partB YES
+Partc YES
+ALTER TABLE TableA EXCHANGE PARTITION parta WITH TABLE TableB;
+INSERT INTO TableB VALUES (11);
+ALTER TABLE TableA EXCHANGE PARTITION Partc WITH TABLE TableB;
+ERROR HY000: Found a row that does not match the partition
+DROP TABLE TableB;
+SELECT * FROM TableA;
+a
+1
+10
+11
+12
+2
+3
+4
+5
+6
+7
+8
+9
+SHOW CREATE TABLE TableA;
+Table Create Table
+TableA CREATE TABLE `TableA` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+(PARTITION parta ENGINE = MyISAM,
+ PARTITION partB ENGINE = MyISAM,
+ PARTITION Partc ENGINE = MyISAM) */
# Test of REORGANIZE PARTITIONS
# Should not work on HASH/KEY
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
@@ -237,7 +309,7 @@ PARTITION BY HASH (a)
PARTITION partA ,
PARTITION Parta ,
PARTITION PartA );
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
# Creating Hash partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'MyISAM'
@@ -268,7 +340,7 @@ ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
@@ -493,7 +565,7 @@ a
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES LESS THAN (MAXVALUE));
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES LESS THAN (16),
PARTITION Partf VALUES LESS THAN (19),
@@ -724,7 +796,7 @@ a
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES IN (0));
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES IN (16),
PARTITION Partf VALUES IN (19),
diff --git a/mysql-test/suite/parts/r/partition_mgm_lc1_archive.result b/mysql-test/suite/parts/r/partition_mgm_lc1_archive.result
index 1113e7dcb0c..66ba08cfbe0 100644
--- a/mysql-test/suite/parts/r/partition_mgm_lc1_archive.result
+++ b/mysql-test/suite/parts/r/partition_mgm_lc1_archive.result
@@ -32,7 +32,7 @@ ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
@@ -88,6 +88,78 @@ TableA CREATE TABLE `tablea` (
(PARTITION parta ENGINE = ARCHIVE,
PARTITION partB ENGINE = ARCHIVE,
PARTITION Partc ENGINE = ARCHIVE) */
+# Test of EXCHANGE PARTITION WITH TABLE
+SELECT PARTITION_NAME, TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA ='MySQL_Test_DB' AND TABLE_NAME = 'TableA';
+PARTITION_NAME TABLE_ROWS
+parta 4
+partB 4
+Partc 4
+CREATE TABLE TableB LIKE TableA;
+ALTER TABLE TableB REMOVE PARTITIONING;
+ALTER TABLE TableA EXCHANGE PARTITION parta WITH TABLE TableB;
+SELECT * FROM TableA;
+a
+1
+12
+2
+3
+6
+7
+8
+9
+SHOW CREATE TABLE TableA;
+Table Create Table
+TableA CREATE TABLE `tablea` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=ARCHIVE DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+(PARTITION parta ENGINE = ARCHIVE,
+ PARTITION partB ENGINE = ARCHIVE,
+ PARTITION Partc ENGINE = ARCHIVE) */
+SELECT * FROM TableB;
+a
+10
+11
+4
+5
+SHOW CREATE TABLE TableB;
+Table Create Table
+TableB CREATE TABLE `tableb` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=ARCHIVE DEFAULT CHARSET=latin1
+SELECT PARTITION_NAME, IF(TABLE_ROWS, 'YES', 'NO') AS HAVE_TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA ='MySQL_Test_DB' AND TABLE_NAME = 'TableA';
+PARTITION_NAME HAVE_TABLE_ROWS
+parta NO
+partB YES
+Partc YES
+ALTER TABLE TableA EXCHANGE PARTITION parta WITH TABLE TableB;
+INSERT INTO TableB VALUES (11);
+ALTER TABLE TableA EXCHANGE PARTITION Partc WITH TABLE TableB;
+ERROR HY000: Found a row that does not match the partition
+DROP TABLE TableB;
+SELECT * FROM TableA;
+a
+1
+10
+11
+12
+2
+3
+4
+5
+6
+7
+8
+9
+SHOW CREATE TABLE TableA;
+Table Create Table
+TableA CREATE TABLE `tablea` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=ARCHIVE DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+(PARTITION parta ENGINE = ARCHIVE,
+ PARTITION partB ENGINE = ARCHIVE,
+ PARTITION Partc ENGINE = ARCHIVE) */
# Test of REORGANIZE PARTITIONS
# Should not work on HASH/KEY
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
@@ -228,7 +300,7 @@ PARTITION BY HASH (a)
PARTITION partA ,
PARTITION Parta ,
PARTITION PartA );
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
# Creating Hash partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'Archive'
@@ -259,7 +331,7 @@ ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
@@ -475,7 +547,7 @@ a
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES LESS THAN (MAXVALUE));
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES LESS THAN (16),
PARTITION Partf VALUES LESS THAN (19),
@@ -698,7 +770,7 @@ a
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES IN (0));
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES IN (16),
PARTITION Partf VALUES IN (19),
diff --git a/mysql-test/suite/parts/r/partition_mgm_lc1_innodb.result b/mysql-test/suite/parts/r/partition_mgm_lc1_innodb.result
index 952f4136cb6..e1c2d0a74bb 100644
--- a/mysql-test/suite/parts/r/partition_mgm_lc1_innodb.result
+++ b/mysql-test/suite/parts/r/partition_mgm_lc1_innodb.result
@@ -32,7 +32,7 @@ ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
@@ -88,6 +88,78 @@ TableA CREATE TABLE `tablea` (
(PARTITION parta ENGINE = InnoDB,
PARTITION partB ENGINE = InnoDB,
PARTITION Partc ENGINE = InnoDB) */
+# Test of EXCHANGE PARTITION WITH TABLE
+SELECT PARTITION_NAME, TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA ='MySQL_Test_DB' AND TABLE_NAME = 'TableA';
+PARTITION_NAME TABLE_ROWS
+parta 4
+partB 4
+Partc 4
+CREATE TABLE TableB LIKE TableA;
+ALTER TABLE TableB REMOVE PARTITIONING;
+ALTER TABLE TableA EXCHANGE PARTITION parta WITH TABLE TableB;
+SELECT * FROM TableA;
+a
+1
+12
+2
+3
+6
+7
+8
+9
+SHOW CREATE TABLE TableA;
+Table Create Table
+TableA CREATE TABLE `tablea` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+(PARTITION parta ENGINE = InnoDB,
+ PARTITION partB ENGINE = InnoDB,
+ PARTITION Partc ENGINE = InnoDB) */
+SELECT * FROM TableB;
+a
+10
+11
+4
+5
+SHOW CREATE TABLE TableB;
+Table Create Table
+TableB CREATE TABLE `tableb` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+SELECT PARTITION_NAME, IF(TABLE_ROWS, 'YES', 'NO') AS HAVE_TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA ='MySQL_Test_DB' AND TABLE_NAME = 'TableA';
+PARTITION_NAME HAVE_TABLE_ROWS
+parta NO
+partB YES
+Partc YES
+ALTER TABLE TableA EXCHANGE PARTITION parta WITH TABLE TableB;
+INSERT INTO TableB VALUES (11);
+ALTER TABLE TableA EXCHANGE PARTITION Partc WITH TABLE TableB;
+ERROR HY000: Found a row that does not match the partition
+DROP TABLE TableB;
+SELECT * FROM TableA;
+a
+1
+10
+11
+12
+2
+3
+4
+5
+6
+7
+8
+9
+SHOW CREATE TABLE TableA;
+Table Create Table
+TableA CREATE TABLE `tablea` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+(PARTITION parta ENGINE = InnoDB,
+ PARTITION partB ENGINE = InnoDB,
+ PARTITION Partc ENGINE = InnoDB) */
# Test of REORGANIZE PARTITIONS
# Should not work on HASH/KEY
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
@@ -228,7 +300,7 @@ PARTITION BY HASH (a)
PARTITION partA ,
PARTITION Parta ,
PARTITION PartA );
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
# Creating Hash partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'InnoDB'
@@ -259,7 +331,7 @@ ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
@@ -475,7 +547,7 @@ a
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES LESS THAN (MAXVALUE));
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES LESS THAN (16),
PARTITION Partf VALUES LESS THAN (19),
@@ -698,7 +770,7 @@ a
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES IN (0));
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES IN (16),
PARTITION Partf VALUES IN (19),
diff --git a/mysql-test/suite/parts/r/partition_mgm_lc1_memory.result b/mysql-test/suite/parts/r/partition_mgm_lc1_memory.result
index 435a0d8313e..ecd89689435 100644
--- a/mysql-test/suite/parts/r/partition_mgm_lc1_memory.result
+++ b/mysql-test/suite/parts/r/partition_mgm_lc1_memory.result
@@ -32,7 +32,7 @@ ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
@@ -88,6 +88,78 @@ TableA CREATE TABLE `tablea` (
(PARTITION parta ENGINE = MEMORY,
PARTITION partB ENGINE = MEMORY,
PARTITION Partc ENGINE = MEMORY) */
+# Test of EXCHANGE PARTITION WITH TABLE
+SELECT PARTITION_NAME, TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA ='MySQL_Test_DB' AND TABLE_NAME = 'TableA';
+PARTITION_NAME TABLE_ROWS
+parta 4
+partB 4
+Partc 4
+CREATE TABLE TableB LIKE TableA;
+ALTER TABLE TableB REMOVE PARTITIONING;
+ALTER TABLE TableA EXCHANGE PARTITION parta WITH TABLE TableB;
+SELECT * FROM TableA;
+a
+1
+12
+2
+3
+6
+7
+8
+9
+SHOW CREATE TABLE TableA;
+Table Create Table
+TableA CREATE TABLE `tablea` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=MEMORY DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+(PARTITION parta ENGINE = MEMORY,
+ PARTITION partB ENGINE = MEMORY,
+ PARTITION Partc ENGINE = MEMORY) */
+SELECT * FROM TableB;
+a
+10
+11
+4
+5
+SHOW CREATE TABLE TableB;
+Table Create Table
+TableB CREATE TABLE `tableb` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=MEMORY DEFAULT CHARSET=latin1
+SELECT PARTITION_NAME, IF(TABLE_ROWS, 'YES', 'NO') AS HAVE_TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA ='MySQL_Test_DB' AND TABLE_NAME = 'TableA';
+PARTITION_NAME HAVE_TABLE_ROWS
+parta NO
+partB YES
+Partc YES
+ALTER TABLE TableA EXCHANGE PARTITION parta WITH TABLE TableB;
+INSERT INTO TableB VALUES (11);
+ALTER TABLE TableA EXCHANGE PARTITION Partc WITH TABLE TableB;
+ERROR HY000: Found a row that does not match the partition
+DROP TABLE TableB;
+SELECT * FROM TableA;
+a
+1
+10
+11
+12
+2
+3
+4
+5
+6
+7
+8
+9
+SHOW CREATE TABLE TableA;
+Table Create Table
+TableA CREATE TABLE `tablea` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=MEMORY DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+(PARTITION parta ENGINE = MEMORY,
+ PARTITION partB ENGINE = MEMORY,
+ PARTITION Partc ENGINE = MEMORY) */
# Test of REORGANIZE PARTITIONS
# Should not work on HASH/KEY
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
@@ -228,7 +300,7 @@ PARTITION BY HASH (a)
PARTITION partA ,
PARTITION Parta ,
PARTITION PartA );
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
# Creating Hash partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'Memory'
@@ -259,7 +331,7 @@ ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
@@ -475,7 +547,7 @@ a
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES LESS THAN (MAXVALUE));
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES LESS THAN (16),
PARTITION Partf VALUES LESS THAN (19),
@@ -698,7 +770,7 @@ a
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES IN (0));
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES IN (16),
PARTITION Partf VALUES IN (19),
diff --git a/mysql-test/suite/parts/r/partition_mgm_lc1_myisam.result b/mysql-test/suite/parts/r/partition_mgm_lc1_myisam.result
index 3a90ce4d73c..deecf320d7d 100644
--- a/mysql-test/suite/parts/r/partition_mgm_lc1_myisam.result
+++ b/mysql-test/suite/parts/r/partition_mgm_lc1_myisam.result
@@ -32,7 +32,7 @@ ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
@@ -88,6 +88,78 @@ TableA CREATE TABLE `tablea` (
(PARTITION parta ENGINE = MyISAM,
PARTITION partB ENGINE = MyISAM,
PARTITION Partc ENGINE = MyISAM) */
+# Test of EXCHANGE PARTITION WITH TABLE
+SELECT PARTITION_NAME, TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA ='MySQL_Test_DB' AND TABLE_NAME = 'TableA';
+PARTITION_NAME TABLE_ROWS
+parta 4
+partB 4
+Partc 4
+CREATE TABLE TableB LIKE TableA;
+ALTER TABLE TableB REMOVE PARTITIONING;
+ALTER TABLE TableA EXCHANGE PARTITION parta WITH TABLE TableB;
+SELECT * FROM TableA;
+a
+1
+12
+2
+3
+6
+7
+8
+9
+SHOW CREATE TABLE TableA;
+Table Create Table
+TableA CREATE TABLE `tablea` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+(PARTITION parta ENGINE = MyISAM,
+ PARTITION partB ENGINE = MyISAM,
+ PARTITION Partc ENGINE = MyISAM) */
+SELECT * FROM TableB;
+a
+10
+11
+4
+5
+SHOW CREATE TABLE TableB;
+Table Create Table
+TableB CREATE TABLE `tableb` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+SELECT PARTITION_NAME, IF(TABLE_ROWS, 'YES', 'NO') AS HAVE_TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA ='MySQL_Test_DB' AND TABLE_NAME = 'TableA';
+PARTITION_NAME HAVE_TABLE_ROWS
+parta NO
+partB YES
+Partc YES
+ALTER TABLE TableA EXCHANGE PARTITION parta WITH TABLE TableB;
+INSERT INTO TableB VALUES (11);
+ALTER TABLE TableA EXCHANGE PARTITION Partc WITH TABLE TableB;
+ERROR HY000: Found a row that does not match the partition
+DROP TABLE TableB;
+SELECT * FROM TableA;
+a
+1
+10
+11
+12
+2
+3
+4
+5
+6
+7
+8
+9
+SHOW CREATE TABLE TableA;
+Table Create Table
+TableA CREATE TABLE `tablea` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+(PARTITION parta ENGINE = MyISAM,
+ PARTITION partB ENGINE = MyISAM,
+ PARTITION Partc ENGINE = MyISAM) */
# Test of REORGANIZE PARTITIONS
# Should not work on HASH/KEY
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
@@ -228,7 +300,7 @@ PARTITION BY HASH (a)
PARTITION partA ,
PARTITION Parta ,
PARTITION PartA );
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
# Creating Hash partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'MyISAM'
@@ -259,7 +331,7 @@ ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
@@ -475,7 +547,7 @@ a
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES LESS THAN (MAXVALUE));
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES LESS THAN (16),
PARTITION Partf VALUES LESS THAN (19),
@@ -698,7 +770,7 @@ a
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES IN (0));
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES IN (16),
PARTITION Partf VALUES IN (19),
diff --git a/mysql-test/suite/parts/r/partition_mgm_lc2_archive.result b/mysql-test/suite/parts/r/partition_mgm_lc2_archive.result
index e71803fcac9..f3503889699 100644
--- a/mysql-test/suite/parts/r/partition_mgm_lc2_archive.result
+++ b/mysql-test/suite/parts/r/partition_mgm_lc2_archive.result
@@ -32,7 +32,7 @@ ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
@@ -88,6 +88,78 @@ TableA CREATE TABLE `TableA` (
(PARTITION parta ENGINE = ARCHIVE,
PARTITION partB ENGINE = ARCHIVE,
PARTITION Partc ENGINE = ARCHIVE) */
+# Test of EXCHANGE PARTITION WITH TABLE
+SELECT PARTITION_NAME, TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA ='MySQL_Test_DB' AND TABLE_NAME = 'TableA';
+PARTITION_NAME TABLE_ROWS
+parta 4
+partB 4
+Partc 4
+CREATE TABLE TableB LIKE TableA;
+ALTER TABLE TableB REMOVE PARTITIONING;
+ALTER TABLE TableA EXCHANGE PARTITION parta WITH TABLE TableB;
+SELECT * FROM TableA;
+a
+1
+12
+2
+3
+6
+7
+8
+9
+SHOW CREATE TABLE TableA;
+Table Create Table
+TableA CREATE TABLE `TableA` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=ARCHIVE DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+(PARTITION parta ENGINE = ARCHIVE,
+ PARTITION partB ENGINE = ARCHIVE,
+ PARTITION Partc ENGINE = ARCHIVE) */
+SELECT * FROM TableB;
+a
+10
+11
+4
+5
+SHOW CREATE TABLE TableB;
+Table Create Table
+TableB CREATE TABLE `TableB` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=ARCHIVE DEFAULT CHARSET=latin1
+SELECT PARTITION_NAME, IF(TABLE_ROWS, 'YES', 'NO') AS HAVE_TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA ='MySQL_Test_DB' AND TABLE_NAME = 'TableA';
+PARTITION_NAME HAVE_TABLE_ROWS
+parta NO
+partB YES
+Partc YES
+ALTER TABLE TableA EXCHANGE PARTITION parta WITH TABLE TableB;
+INSERT INTO TableB VALUES (11);
+ALTER TABLE TableA EXCHANGE PARTITION Partc WITH TABLE TableB;
+ERROR HY000: Found a row that does not match the partition
+DROP TABLE TableB;
+SELECT * FROM TableA;
+a
+1
+10
+11
+12
+2
+3
+4
+5
+6
+7
+8
+9
+SHOW CREATE TABLE TableA;
+Table Create Table
+TableA CREATE TABLE `TableA` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=ARCHIVE DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+(PARTITION parta ENGINE = ARCHIVE,
+ PARTITION partB ENGINE = ARCHIVE,
+ PARTITION Partc ENGINE = ARCHIVE) */
# Test of REORGANIZE PARTITIONS
# Should not work on HASH/KEY
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
@@ -228,7 +300,7 @@ PARTITION BY HASH (a)
PARTITION partA ,
PARTITION Parta ,
PARTITION PartA );
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
# Creating Hash partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'Archive'
@@ -259,7 +331,7 @@ ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
@@ -475,7 +547,7 @@ a
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES LESS THAN (MAXVALUE));
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES LESS THAN (16),
PARTITION Partf VALUES LESS THAN (19),
@@ -698,7 +770,7 @@ a
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES IN (0));
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES IN (16),
PARTITION Partf VALUES IN (19),
diff --git a/mysql-test/suite/parts/r/partition_mgm_lc2_innodb.result b/mysql-test/suite/parts/r/partition_mgm_lc2_innodb.result
index 8e42bc9eb62..50579e84d96 100644
--- a/mysql-test/suite/parts/r/partition_mgm_lc2_innodb.result
+++ b/mysql-test/suite/parts/r/partition_mgm_lc2_innodb.result
@@ -32,7 +32,7 @@ ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
@@ -88,6 +88,78 @@ TableA CREATE TABLE `TableA` (
(PARTITION parta ENGINE = InnoDB,
PARTITION partB ENGINE = InnoDB,
PARTITION Partc ENGINE = InnoDB) */
+# Test of EXCHANGE PARTITION WITH TABLE
+SELECT PARTITION_NAME, TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA ='MySQL_Test_DB' AND TABLE_NAME = 'TableA';
+PARTITION_NAME TABLE_ROWS
+parta 4
+partB 4
+Partc 4
+CREATE TABLE TableB LIKE TableA;
+ALTER TABLE TableB REMOVE PARTITIONING;
+ALTER TABLE TableA EXCHANGE PARTITION parta WITH TABLE TableB;
+SELECT * FROM TableA;
+a
+1
+12
+2
+3
+6
+7
+8
+9
+SHOW CREATE TABLE TableA;
+Table Create Table
+TableA CREATE TABLE `TableA` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+(PARTITION parta ENGINE = InnoDB,
+ PARTITION partB ENGINE = InnoDB,
+ PARTITION Partc ENGINE = InnoDB) */
+SELECT * FROM TableB;
+a
+10
+11
+4
+5
+SHOW CREATE TABLE TableB;
+Table Create Table
+TableB CREATE TABLE `TableB` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+SELECT PARTITION_NAME, IF(TABLE_ROWS, 'YES', 'NO') AS HAVE_TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA ='MySQL_Test_DB' AND TABLE_NAME = 'TableA';
+PARTITION_NAME HAVE_TABLE_ROWS
+parta NO
+partB YES
+Partc YES
+ALTER TABLE TableA EXCHANGE PARTITION parta WITH TABLE TableB;
+INSERT INTO TableB VALUES (11);
+ALTER TABLE TableA EXCHANGE PARTITION Partc WITH TABLE TableB;
+ERROR HY000: Found a row that does not match the partition
+DROP TABLE TableB;
+SELECT * FROM TableA;
+a
+1
+10
+11
+12
+2
+3
+4
+5
+6
+7
+8
+9
+SHOW CREATE TABLE TableA;
+Table Create Table
+TableA CREATE TABLE `TableA` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+(PARTITION parta ENGINE = InnoDB,
+ PARTITION partB ENGINE = InnoDB,
+ PARTITION Partc ENGINE = InnoDB) */
# Test of REORGANIZE PARTITIONS
# Should not work on HASH/KEY
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
@@ -167,7 +239,7 @@ PARTITION Partc ,
PARTITION PartD );
ERROR 42S01: Table 'tablea' already exists
SHOW TABLES;
-Tables_in_mysql_test_db
+Tables_in_MySQL_Test_DB
TableA
RENAME TABLE TableA to tablea;
ERROR 42S01: Table 'tablea' already exists
@@ -228,7 +300,7 @@ PARTITION BY HASH (a)
PARTITION partA ,
PARTITION Parta ,
PARTITION PartA );
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
# Creating Hash partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'InnoDB'
@@ -259,7 +331,7 @@ ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
@@ -394,7 +466,7 @@ PARTITION Partc ,
PARTITION PartD );
ERROR 42S01: Table 'tablea' already exists
SHOW TABLES;
-Tables_in_mysql_test_db
+Tables_in_MySQL_Test_DB
TableA
RENAME TABLE TableA to tablea;
ERROR 42S01: Table 'tablea' already exists
@@ -475,7 +547,7 @@ a
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES LESS THAN (MAXVALUE));
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES LESS THAN (16),
PARTITION Partf VALUES LESS THAN (19),
@@ -616,7 +688,7 @@ PARTITION Partc VALUES LESS THAN (10) ,
PARTITION PartD VALUES LESS THAN (13) );
ERROR 42S01: Table 'tablea' already exists
SHOW TABLES;
-Tables_in_mysql_test_db
+Tables_in_MySQL_Test_DB
TableA
RENAME TABLE TableA to tablea;
ERROR 42S01: Table 'tablea' already exists
@@ -698,7 +770,7 @@ a
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES IN (0));
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES IN (16),
PARTITION Partf VALUES IN (19),
@@ -834,7 +906,7 @@ PARTITION Partc VALUES IN (3,4,7) ,
PARTITION PartD VALUES IN (5,6,12) );
ERROR 42S01: Table 'tablea' already exists
SHOW TABLES;
-Tables_in_mysql_test_db
+Tables_in_MySQL_Test_DB
TableA
RENAME TABLE TableA to tablea;
ERROR 42S01: Table 'tablea' already exists
diff --git a/mysql-test/suite/parts/r/partition_mgm_lc2_memory.result b/mysql-test/suite/parts/r/partition_mgm_lc2_memory.result
index 24047912ab1..e92aac28e79 100644
--- a/mysql-test/suite/parts/r/partition_mgm_lc2_memory.result
+++ b/mysql-test/suite/parts/r/partition_mgm_lc2_memory.result
@@ -32,7 +32,7 @@ ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
@@ -88,6 +88,78 @@ TableA CREATE TABLE `TableA` (
(PARTITION parta ENGINE = MEMORY,
PARTITION partB ENGINE = MEMORY,
PARTITION Partc ENGINE = MEMORY) */
+# Test of EXCHANGE PARTITION WITH TABLE
+SELECT PARTITION_NAME, TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA ='MySQL_Test_DB' AND TABLE_NAME = 'TableA';
+PARTITION_NAME TABLE_ROWS
+parta 4
+partB 4
+Partc 4
+CREATE TABLE TableB LIKE TableA;
+ALTER TABLE TableB REMOVE PARTITIONING;
+ALTER TABLE TableA EXCHANGE PARTITION parta WITH TABLE TableB;
+SELECT * FROM TableA;
+a
+1
+12
+2
+3
+6
+7
+8
+9
+SHOW CREATE TABLE TableA;
+Table Create Table
+TableA CREATE TABLE `TableA` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=MEMORY DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+(PARTITION parta ENGINE = MEMORY,
+ PARTITION partB ENGINE = MEMORY,
+ PARTITION Partc ENGINE = MEMORY) */
+SELECT * FROM TableB;
+a
+10
+11
+4
+5
+SHOW CREATE TABLE TableB;
+Table Create Table
+TableB CREATE TABLE `TableB` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=MEMORY DEFAULT CHARSET=latin1
+SELECT PARTITION_NAME, IF(TABLE_ROWS, 'YES', 'NO') AS HAVE_TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA ='MySQL_Test_DB' AND TABLE_NAME = 'TableA';
+PARTITION_NAME HAVE_TABLE_ROWS
+parta NO
+partB YES
+Partc YES
+ALTER TABLE TableA EXCHANGE PARTITION parta WITH TABLE TableB;
+INSERT INTO TableB VALUES (11);
+ALTER TABLE TableA EXCHANGE PARTITION Partc WITH TABLE TableB;
+ERROR HY000: Found a row that does not match the partition
+DROP TABLE TableB;
+SELECT * FROM TableA;
+a
+1
+10
+11
+12
+2
+3
+4
+5
+6
+7
+8
+9
+SHOW CREATE TABLE TableA;
+Table Create Table
+TableA CREATE TABLE `TableA` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=MEMORY DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+(PARTITION parta ENGINE = MEMORY,
+ PARTITION partB ENGINE = MEMORY,
+ PARTITION Partc ENGINE = MEMORY) */
# Test of REORGANIZE PARTITIONS
# Should not work on HASH/KEY
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
@@ -167,7 +239,7 @@ PARTITION Partc ,
PARTITION PartD );
ERROR 42S01: Table 'tablea' already exists
SHOW TABLES;
-Tables_in_mysql_test_db
+Tables_in_MySQL_Test_DB
TableA
RENAME TABLE TableA to tablea;
ERROR 42S01: Table 'tablea' already exists
@@ -228,7 +300,7 @@ PARTITION BY HASH (a)
PARTITION partA ,
PARTITION Parta ,
PARTITION PartA );
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
# Creating Hash partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'Memory'
@@ -259,7 +331,7 @@ ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
@@ -394,7 +466,7 @@ PARTITION Partc ,
PARTITION PartD );
ERROR 42S01: Table 'tablea' already exists
SHOW TABLES;
-Tables_in_mysql_test_db
+Tables_in_MySQL_Test_DB
TableA
RENAME TABLE TableA to tablea;
ERROR 42S01: Table 'tablea' already exists
@@ -475,7 +547,7 @@ a
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES LESS THAN (MAXVALUE));
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES LESS THAN (16),
PARTITION Partf VALUES LESS THAN (19),
@@ -616,7 +688,7 @@ PARTITION Partc VALUES LESS THAN (10) ,
PARTITION PartD VALUES LESS THAN (13) );
ERROR 42S01: Table 'tablea' already exists
SHOW TABLES;
-Tables_in_mysql_test_db
+Tables_in_MySQL_Test_DB
TableA
RENAME TABLE TableA to tablea;
ERROR 42S01: Table 'tablea' already exists
@@ -698,7 +770,7 @@ a
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES IN (0));
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES IN (16),
PARTITION Partf VALUES IN (19),
@@ -834,7 +906,7 @@ PARTITION Partc VALUES IN (3,4,7) ,
PARTITION PartD VALUES IN (5,6,12) );
ERROR 42S01: Table 'tablea' already exists
SHOW TABLES;
-Tables_in_mysql_test_db
+Tables_in_MySQL_Test_DB
TableA
RENAME TABLE TableA to tablea;
ERROR 42S01: Table 'tablea' already exists
diff --git a/mysql-test/suite/parts/r/partition_mgm_lc2_myisam.result b/mysql-test/suite/parts/r/partition_mgm_lc2_myisam.result
index 7a61a811ea3..35c663caae3 100644
--- a/mysql-test/suite/parts/r/partition_mgm_lc2_myisam.result
+++ b/mysql-test/suite/parts/r/partition_mgm_lc2_myisam.result
@@ -32,7 +32,7 @@ ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
@@ -88,6 +88,78 @@ TableA CREATE TABLE `TableA` (
(PARTITION parta ENGINE = MyISAM,
PARTITION partB ENGINE = MyISAM,
PARTITION Partc ENGINE = MyISAM) */
+# Test of EXCHANGE PARTITION WITH TABLE
+SELECT PARTITION_NAME, TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA ='MySQL_Test_DB' AND TABLE_NAME = 'TableA';
+PARTITION_NAME TABLE_ROWS
+parta 4
+partB 4
+Partc 4
+CREATE TABLE TableB LIKE TableA;
+ALTER TABLE TableB REMOVE PARTITIONING;
+ALTER TABLE TableA EXCHANGE PARTITION parta WITH TABLE TableB;
+SELECT * FROM TableA;
+a
+1
+12
+2
+3
+6
+7
+8
+9
+SHOW CREATE TABLE TableA;
+Table Create Table
+TableA CREATE TABLE `TableA` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+(PARTITION parta ENGINE = MyISAM,
+ PARTITION partB ENGINE = MyISAM,
+ PARTITION Partc ENGINE = MyISAM) */
+SELECT * FROM TableB;
+a
+10
+11
+4
+5
+SHOW CREATE TABLE TableB;
+Table Create Table
+TableB CREATE TABLE `TableB` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+SELECT PARTITION_NAME, IF(TABLE_ROWS, 'YES', 'NO') AS HAVE_TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA ='MySQL_Test_DB' AND TABLE_NAME = 'TableA';
+PARTITION_NAME HAVE_TABLE_ROWS
+parta NO
+partB YES
+Partc YES
+ALTER TABLE TableA EXCHANGE PARTITION parta WITH TABLE TableB;
+INSERT INTO TableB VALUES (11);
+ALTER TABLE TableA EXCHANGE PARTITION Partc WITH TABLE TableB;
+ERROR HY000: Found a row that does not match the partition
+DROP TABLE TableB;
+SELECT * FROM TableA;
+a
+1
+10
+11
+12
+2
+3
+4
+5
+6
+7
+8
+9
+SHOW CREATE TABLE TableA;
+Table Create Table
+TableA CREATE TABLE `TableA` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+(PARTITION parta ENGINE = MyISAM,
+ PARTITION partB ENGINE = MyISAM,
+ PARTITION Partc ENGINE = MyISAM) */
# Test of REORGANIZE PARTITIONS
# Should not work on HASH/KEY
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
@@ -167,7 +239,7 @@ PARTITION Partc ,
PARTITION PartD );
ERROR 42S01: Table 'tablea' already exists
SHOW TABLES;
-Tables_in_mysql_test_db
+Tables_in_MySQL_Test_DB
TableA
RENAME TABLE TableA to tablea;
ERROR 42S01: Table 'tablea' already exists
@@ -228,7 +300,7 @@ PARTITION BY HASH (a)
PARTITION partA ,
PARTITION Parta ,
PARTITION PartA );
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
# Creating Hash partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'MyISAM'
@@ -259,7 +331,7 @@ ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
@@ -394,7 +466,7 @@ PARTITION Partc ,
PARTITION PartD );
ERROR 42S01: Table 'tablea' already exists
SHOW TABLES;
-Tables_in_mysql_test_db
+Tables_in_MySQL_Test_DB
TableA
RENAME TABLE TableA to tablea;
ERROR 42S01: Table 'tablea' already exists
@@ -475,7 +547,7 @@ a
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES LESS THAN (MAXVALUE));
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES LESS THAN (16),
PARTITION Partf VALUES LESS THAN (19),
@@ -616,7 +688,7 @@ PARTITION Partc VALUES LESS THAN (10) ,
PARTITION PartD VALUES LESS THAN (13) );
ERROR 42S01: Table 'tablea' already exists
SHOW TABLES;
-Tables_in_mysql_test_db
+Tables_in_MySQL_Test_DB
TableA
RENAME TABLE TableA to tablea;
ERROR 42S01: Table 'tablea' already exists
@@ -698,7 +770,7 @@ a
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES IN (0));
-ERROR HY000: Duplicate partition name parta
+ERROR HY000: Duplicate partition name partA
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES IN (16),
PARTITION Partf VALUES IN (19),
@@ -834,7 +906,7 @@ PARTITION Partc VALUES IN (3,4,7) ,
PARTITION PartD VALUES IN (5,6,12) );
ERROR 42S01: Table 'tablea' already exists
SHOW TABLES;
-Tables_in_mysql_test_db
+Tables_in_MySQL_Test_DB
TableA
RENAME TABLE TableA to tablea;
ERROR 42S01: Table 'tablea' already exists
diff --git a/mysql-test/suite/parts/r/partition_repair_myisam.result b/mysql-test/suite/parts/r/partition_repair_myisam.result
index a9d7ce8aeb4..3652698f634 100644
--- a/mysql-test/suite/parts/r/partition_repair_myisam.result
+++ b/mysql-test/suite/parts/r/partition_repair_myisam.result
@@ -1,4 +1,65 @@
# REPAIR USE_FRM is not implemented for partitioned tables.
+# Test what happens if we exchange a crashed partition with a table
+SHOW VARIABLES LIKE 'myisam_recover_options';
+Variable_name Value
+myisam_recover_options OFF
+CREATE TABLE t (a INT, KEY (a)) ENGINE=MyISAM;
+CREATE TABLE tp (a INT, KEY (a)) ENGINE=MyISAM
+PARTITION BY RANGE (a)
+(PARTITION pCrashed VALUES LESS THAN (15),
+PARTITION pMAX VALUES LESS THAN MAXVALUE);
+INSERT INTO t VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10), (11);
+INSERT INTO tp VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10), (11);
+FLUSH TABLES;
+# replacing tp#P#pCrashed.MYI with a corrupt + unclosed one created by doing:
+# 'create table t1 (a int key(a))' head -c1024 t1.MYI > corrupt_t1.MYI
+CHECK TABLE tp;
+Table Op Msg_type Msg_text
+test.tp check warning 1 client is using or hasn't closed the table properly
+test.tp check error Size of indexfile is: 1024 Should be: 2048
+test.tp check warning Size of datafile is: 77 Should be: 7
+test.tp check error Partition pCrashed returned error
+test.tp check error Corrupt
+ALTER TABLE tp EXCHANGE PARTITION pCrashed WITH TABLE t;
+ERROR HY000: Table './test/tp#P#pCrashed' is marked as crashed and should be repaired
+REPAIR TABLE tp;
+Table Op Msg_type Msg_text
+test.tp repair warning Number of rows changed from 1 to 11
+test.tp repair status OK
+CHECK TABLE tp;
+Table Op Msg_type Msg_text
+test.tp check status OK
+ALTER TABLE tp EXCHANGE PARTITION pCrashed WITH TABLE t;
+CHECK TABLE t;
+Table Op Msg_type Msg_text
+test.t check status OK
+CHECK TABLE tp;
+Table Op Msg_type Msg_text
+test.tp check status OK
+FLUSH TABLES;
+CHECK TABLE t;
+Table Op Msg_type Msg_text
+test.t check warning 1 client is using or hasn't closed the table properly
+test.t check error Size of indexfile is: 1024 Should be: 2048
+test.t check warning Size of datafile is: 77 Should be: 7
+test.t check error Corrupt
+ALTER TABLE tp EXCHANGE PARTITION pCrashed WITH TABLE t;
+ERROR HY000: Table './test/t' is marked as crashed and should be repaired
+REPAIR TABLE t;
+Table Op Msg_type Msg_text
+test.t repair warning Number of rows changed from 1 to 11
+test.t repair status OK
+CHECK TABLE t;
+Table Op Msg_type Msg_text
+test.t check status OK
+ALTER TABLE tp EXCHANGE PARTITION pCrashed WITH TABLE t;
+CHECK TABLE tp;
+Table Op Msg_type Msg_text
+test.tp check status OK
+CHECK TABLE t;
+Table Op Msg_type Msg_text
+test.t check status OK
+DROP TABLE t, tp;
# test of non partitioned myisam for reference
CREATE TABLE t1_will_crash (a INT, KEY (a)) ENGINE=MyISAM;
INSERT INTO t1_will_crash VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10), (11);
@@ -209,7 +270,7 @@ PARTITIONS 7;
SELECT COUNT(*) FROM t1_will_crash;
COUNT(*)
33
-SELECT (b % 7) AS partition, COUNT(*) AS rows FROM t1_will_crash GROUP BY (b % 7);
+SELECT (b % 7) AS `partition`, COUNT(*) AS rows FROM t1_will_crash GROUP BY (b % 7);
partition rows
0 2
1 5
@@ -218,7 +279,7 @@ partition rows
4 4
5 4
6 8
-SELECT (b % 7) AS partition, b, a, length(c) FROM t1_will_crash ORDER BY partition, b, a;
+SELECT (b % 7) AS `partition`, b, a, length(c) FROM t1_will_crash ORDER BY `partition`, b, a;
partition b a length(c)
0 0 lost 64
0 7 z lost 64
@@ -282,7 +343,7 @@ test.t1_will_crash repair status OK
SELECT COUNT(*) FROM t1_will_crash;
COUNT(*)
29
-SELECT (b % 7) AS partition, COUNT(*) AS rows FROM t1_will_crash GROUP BY (b % 7);
+SELECT (b % 7) AS `partition`, COUNT(*) AS rows FROM t1_will_crash GROUP BY (b % 7);
partition rows
1 4
2 5
@@ -290,7 +351,7 @@ partition rows
4 4
5 4
6 7
-SELECT (b % 7) AS partition, b, a, length(c) FROM t1_will_crash ORDER BY partition, b, a;
+SELECT (b % 7) AS `partition`, b, a, length(c) FROM t1_will_crash ORDER BY `partition`, b, a;
partition b a length(c)
1 1 abc 64
1 8 tuw 64
@@ -366,9 +427,9 @@ Table Op Msg_type Msg_text
test.t1_will_crash repair info Delete link points outside datafile at 340
test.t1_will_crash repair info Delete link points outside datafile at 340
test.t1_will_crash repair status OK
-SELECT (b % 7) AS partition, b, a, length(c) FROM t1_will_crash
+SELECT (b % 7) AS `partition`, b, a, length(c) FROM t1_will_crash
WHERE (b % 7) = 6
-ORDER BY partition, b, a;
+ORDER BY `partition`, b, a;
partition b a length(c)
6 6 jkl 64
6 13 ooo 64
@@ -385,9 +446,9 @@ FLUSH TABLES;
# table, depending if one reads via index or direct on datafile.
# Since crash when reuse of deleted row space, CHECK MEDIUM or EXTENDED
# is required (MEDIUM is default) to verify correct behavior!
-SELECT (b % 7) AS partition, b, a, length(c) FROM t1_will_crash
+SELECT (b % 7) AS `partition`, b, a, length(c) FROM t1_will_crash
WHERE (b % 7) = 6
-ORDER BY partition, b, a;
+ORDER BY `partition`, b, a;
partition b a length(c)
6 6 jkl 64
6 13 ooo 64
@@ -396,9 +457,9 @@ partition b a length(c)
6 97 zzzzzZzzzzz 64
SET @save_optimizer_switch= @@optimizer_switch;
SET @@optimizer_switch='derived_merge=off';
-SELECT (b % 7) AS partition, b, a FROM (SELECT b,a FROM t1_will_crash) q
+SELECT (b % 7) AS `partition`, b, a FROM (SELECT b,a FROM t1_will_crash) q
WHERE (b % 7) = 6
-ORDER BY partition, b, a;
+ORDER BY `partition`, b, a;
partition b a
6 6 jkl
6 13 ooo
@@ -422,7 +483,7 @@ test.t1_will_crash repair status OK
SELECT COUNT(*) FROM t1_will_crash;
COUNT(*)
29
-SELECT (b % 7) AS partition, COUNT(*) AS rows FROM t1_will_crash GROUP BY (b % 7);
+SELECT (b % 7) AS `partition`, COUNT(*) AS rows FROM t1_will_crash GROUP BY (b % 7);
partition rows
1 4
2 4
@@ -430,7 +491,7 @@ partition rows
4 4
5 4
6 8
-SELECT (b % 7) AS partition, b, a, length(c) FROM t1_will_crash ORDER BY partition, b, a;
+SELECT (b % 7) AS `partition`, b, a, length(c) FROM t1_will_crash ORDER BY `partition`, b, a;
partition b a length(c)
1 1 abc 64
1 8 tuw 64
diff --git a/mysql-test/suite/parts/r/partition_syntax_innodb.result b/mysql-test/suite/parts/r/partition_syntax_innodb.result
index f704d902429..92af6bc733f 100644
--- a/mysql-test/suite/parts/r/partition_syntax_innodb.result
+++ b/mysql-test/suite/parts/r/partition_syntax_innodb.result
@@ -1,5 +1,5 @@
SET @max_row = 20;
-SET @@session.storage_engine = 'InnoDB';
+SET @@session.default_storage_engine = 'InnoDB';
#------------------------------------------------------------------------
# 0. Setting of auxiliary variables + Creation of an auxiliary tables
diff --git a/mysql-test/suite/parts/r/partition_syntax_myisam.result b/mysql-test/suite/parts/r/partition_syntax_myisam.result
index 556abf7ad39..ae401e7f88a 100644
--- a/mysql-test/suite/parts/r/partition_syntax_myisam.result
+++ b/mysql-test/suite/parts/r/partition_syntax_myisam.result
@@ -1,5 +1,5 @@
SET @max_row = 20;
-SET @@session.storage_engine = 'MyISAM';
+SET @@session.default_storage_engine = 'MyISAM';
#------------------------------------------------------------------------
# 0. Setting of auxiliary variables + Creation of an auxiliary tables
diff --git a/mysql-test/suite/parts/t/partition_alter1_1_innodb.test b/mysql-test/suite/parts/t/partition_alter1_1_innodb.test
index e50a0cd7ed6..7f768e578de 100644
--- a/mysql-test/suite/parts/t/partition_alter1_1_innodb.test
+++ b/mysql-test/suite/parts/t/partition_alter1_1_innodb.test
@@ -1,3 +1,5 @@
+# This test takes long time, so only run it with the --big-test mtr-flag.
+--source include/big_test.inc
################################################################################
# t/partition_alter1_1_innodb.test #
# #
diff --git a/mysql-test/suite/parts/t/partition_basic_innodb.test b/mysql-test/suite/parts/t/partition_basic_innodb.test
index 398f62dab28..032db63693c 100644
--- a/mysql-test/suite/parts/t/partition_basic_innodb.test
+++ b/mysql-test/suite/parts/t/partition_basic_innodb.test
@@ -1,3 +1,7 @@
+#Considering the time taken for this test on slow solaris platforms making it a big test
+--source include/big_test.inc
+# Skiping this test from Valgrind execution as per Bug-14627884
+--source include/not_valgrind.inc
################################################################################
# t/partition_basic_innodb.test #
# #
@@ -22,8 +26,6 @@
# any of the variables.
#
---source include/big_test.inc
-
#------------------------------------------------------------------------------#
# General not engine specific settings and requirements
@@ -42,12 +44,12 @@ SET @max_row = 20;
let $more_trigger_tests= 0;
let $more_pk_ui_tests= 0;
-# This test relies on connecting externally from mysqltest, doesn't
-# work with embedded.
---source include/not_embedded.inc
# The server must support partitioning.
--source include/have_partition.inc
+# Does not work with --embedded
+--source include/not_embedded.inc
+
#------------------------------------------------------------------------------#
# Engine specific settings and requirements
diff --git a/mysql-test/suite/parts/t/partition_basic_symlink_innodb.test b/mysql-test/suite/parts/t/partition_basic_symlink_innodb.test
index 17c6a845b25..35dc2d5e004 100644
--- a/mysql-test/suite/parts/t/partition_basic_symlink_innodb.test
+++ b/mysql-test/suite/parts/t/partition_basic_symlink_innodb.test
@@ -14,16 +14,20 @@
# Change Author: mattiasj #
# Change Date: 2008-03-16 #
# Change: Replaced all test with alter -> myisam, since innodb does not support#
-# DATA/INDEX DIRECTORY #
+# Change Author: Kevin lewis #
+# Change Date: 2012-03-02 #
+# Change: WL5980 activates DATA DIRECTORY for InnoDB #
################################################################################
-# NOTE: Until InnoDB supports DATA/INDEX DIR, test that a partitioned table
-# remembers the DATA/INDEX DIR and it is used if altered to MyISAM
+# NOTE: As of WL5980, InnoDB supports DATA DIRECTORY, but not INDEX DIRECTORY.
+# See innodb.innodb-tablespace for tests using partition engine, innodb
+# and DATADIRECTORY. The purpose of this test is to show that a
+# partitioned table remembers the DATA/INDEX DIR and it is used if
+# altered to MyISAM
#
---echo # Will not run partition_basic_symlink on InnoDB, since it is the same
---echo # as partition_basic, since InnoDB does not support DATA/INDEX DIR
---echo # Will only verify that the DATA/INDEX DIR is stored and used if
---echo # ALTER to MyISAM.
+--echo #
+--echo # Verify that the DATA/INDEX DIR is stored and used if ALTER to MyISAM.
+--echo #
--source include/have_innodb.inc
# The server must support partitioning.
--source include/have_partition.inc
@@ -32,17 +36,57 @@
# windows does not support symlink for DATA/INDEX DIRECTORY.
--source include/not_windows.inc
+# Does not work with --embedded
+--source include/not_embedded.inc
+
+--disable_query_log
+let $MYSQLD_DATADIR= `select @@datadir`;
+
+# These values can change during the test
+LET $innodb_file_per_table_orig=`select @@innodb_file_per_table`;
+LET $innodb_strict_mode_orig=`select @@session.innodb_strict_mode`;
+--enable_query_log
+
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
-let $MYSQLD_DATADIR= `select @@datadir`;
-
--mkdir $MYSQLTEST_VARDIR/mysql-test-data-dir
--mkdir $MYSQLTEST_VARDIR/mysql-test-idx-dir
+
+SET SESSION innodb_strict_mode = ON;
+
+--echo #
+--echo # InnoDB only supports DATA DIRECTORY with innodb_file_per_table=ON
+--echo #
+SET GLOBAL innodb_file_per_table = OFF;
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--error ER_CANT_CREATE_TABLE
+eval CREATE TABLE t1 (c1 INT) ENGINE = InnoDB
+PARTITION BY HASH (c1) (
+ PARTITION p0
+ DATA DIRECTORY = '$MYSQLTEST_VARDIR/mysql-test-data-dir'
+ INDEX DIRECTORY = '$MYSQLTEST_VARDIR/mysql-test-idx-dir',
+ PARTITION p1
+ DATA DIRECTORY = '$MYSQLTEST_VARDIR/mysql-test-data-dir'
+ INDEX DIRECTORY = '$MYSQLTEST_VARDIR/mysql-test-idx-dir'
+);
+--replace_result ./ MYSQLD_DATADIR/ $MYSQLD_DATADIR MYSQLD_DATADIR
+SHOW WARNINGS;
+
+--echo #
+--echo # InnoDB is different from MyISAM in that it uses a text file
+--echo # with an '.isl' extension instead of a symbolic link so that
+--echo # the tablespace can be re-located on any OS. Also, instead of
+--echo # putting the file directly into the DATA DIRECTORY,
+--echo # it adds a folder under it with the name of the database.
+--echo # Since strict mode is off, InnoDB ignores the INDEX DIRECTORY
+--echo # and it is no longer part of the definition.
+--echo #
+SET SESSION innodb_strict_mode = OFF;
+SET GLOBAL innodb_file_per_table = ON;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
-eval CREATE TABLE t1 (c1 INT)
-ENGINE = InnoDB
+eval CREATE TABLE t1 (c1 INT) ENGINE = InnoDB
PARTITION BY HASH (c1)
(PARTITION p0
DATA DIRECTORY = '$MYSQLTEST_VARDIR/mysql-test-data-dir'
@@ -51,116 +95,70 @@ PARTITION BY HASH (c1)
DATA DIRECTORY = '$MYSQLTEST_VARDIR/mysql-test-data-dir'
INDEX DIRECTORY = '$MYSQLTEST_VARDIR/mysql-test-idx-dir'
);
---echo # Verifying .frm and .par files
---file_exists $MYSQLD_DATADIR/test/t1.frm
---file_exists $MYSQLD_DATADIR/test/t1.par
---echo # Verifying that there are no MyISAM files
---error 1
---file_exists $MYSQLD_DATADIR/test/t1#P#p0.MYD
---error 1
---file_exists $MYSQLD_DATADIR/test/t1#P#p0.MYI
---error 1
---file_exists $MYSQLD_DATADIR/test/t1#P#p1.MYD
---error 1
---file_exists $MYSQLD_DATADIR/test/t1#P#p1.MYI
---error 1
---file_exists $MYSQLTEST_VARDIR/mysql-test-data-dir/t1#P#p0.MYD
---error 1
---file_exists $MYSQLTEST_VARDIR/mysql-test-idx-dir/t1#P#p0.MYI
---error 1
---file_exists $MYSQLTEST_VARDIR/mysql-test-data-dir/t1#P#p1.MYD
---error 1
---file_exists $MYSQLTEST_VARDIR/mysql-test-idx-dir/t1#P#p1.MYI
+SHOW WARNINGS;
+
+--echo # Verifying .frm, .par, .isl & .ibd files
+--echo ---- MYSQLD_DATADIR/test
+--list_files $MYSQLD_DATADIR/test
+--echo ---- MYSQLTEST_VARDIR/mysql-test-data-dir/test
+--list_files $MYSQLTEST_VARDIR/mysql-test-data-dir/test
+--echo # The ibd tablespaces should not be directly under the DATA DIRECTORY
+--echo ---- MYSQLTEST_VARDIR/mysql-test-data-dir
+--list_files $MYSQLTEST_VARDIR/mysql-test-data-dir
+--echo ---- MYSQLTEST_VARDIR/mysql-test-idx-dir
+--list_files $MYSQLTEST_VARDIR/mysql-test-idx-dir
+
FLUSH TABLES;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
SHOW CREATE TABLE t1;
-ALTER TABLE t1 ENGINE = MyISAM;
+
+--echo #
+--echo # Verify that the DATA/INDEX DIRECTORY is stored and used if we
+--echo # ALTER TABLE to MyISAM.
+--echo #
+ALTER TABLE t1 engine=MyISAM;
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+SHOW CREATE TABLE t1;
--echo # Verifying .frm, .par and MyISAM files (.MYD, MYI)
---file_exists $MYSQLD_DATADIR/test/t1.frm
---file_exists $MYSQLD_DATADIR/test/t1.par
---file_exists $MYSQLD_DATADIR/test/t1#P#p0.MYD
---file_exists $MYSQLD_DATADIR/test/t1#P#p0.MYI
---file_exists $MYSQLD_DATADIR/test/t1#P#p1.MYD
---file_exists $MYSQLD_DATADIR/test/t1#P#p1.MYI
---file_exists $MYSQLTEST_VARDIR/mysql-test-data-dir/t1#P#p0.MYD
---file_exists $MYSQLTEST_VARDIR/mysql-test-idx-dir/t1#P#p0.MYI
---file_exists $MYSQLTEST_VARDIR/mysql-test-data-dir/t1#P#p1.MYD
---file_exists $MYSQLTEST_VARDIR/mysql-test-idx-dir/t1#P#p1.MYI
-FLUSH TABLES;
+--echo ---- MYSQLD_DATADIR/test
+--list_files $MYSQLD_DATADIR/test
+--echo ---- MYSQLTEST_VARDIR/mysql-test-data-dir
+--list_files $MYSQLTEST_VARDIR/mysql-test-data-dir
+--echo ---- MYSQLTEST_VARDIR/mysql-test-idx-dir
+--list_files $MYSQLTEST_VARDIR/mysql-test-idx-dir
+
+--echo #
+--echo # Now verify that the DATA DIRECTORY is used again if we
+--echo # ALTER TABLE back to InnoDB.
+--echo #
+SET SESSION innodb_strict_mode = ON;
+ALTER TABLE t1 engine=InnoDB;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
SHOW CREATE TABLE t1;
-DROP TABLE t1;
---rmdir $MYSQLTEST_VARDIR/mysql-test-data-dir
---rmdir $MYSQLTEST_VARDIR/mysql-test-idx-dir
---exit
-# here is the old test, which is tested by partition_basic_innodb
-
-#
-# NOTE: PLEASE DO NOT ADD NOT INNODB SPECIFIC TESTCASES HERE !
-# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
-# THE SOURCED FILES ONLY.
-#
-# Please read the README at the end of inc/partition.pre before changing
-# any of the variables.
-#
-
-#------------------------------------------------------------------------------#
-# General not engine specific settings and requirements
-
-##### Options, for debugging support #####
-let $debug= 0;
-let $with_partitioning= 1;
-
-##### Option, for displaying files #####
-let $ls= 1;
-
-##### Number of rows for the INSERT/UPDATE/DELETE/SELECT experiments #####
-# on partioned tables
-SET @max_row = 20;
-
-##### Execute more tests #####
-let $more_trigger_tests= 0;
-let $more_pk_ui_tests= 0;
-
-# The server must support partitioning.
---source include/have_partition.inc
-# The server must support symlink for DATA/INDEX DIRECTORY.
---source include/have_symlink.inc
-# windows does not support symlink for DATA/INDEX DIRECTORY.
---source include/not_windows.inc
+--echo # Verifying .frm, .par, .isl and InnoDB .ibd files
+--echo ---- MYSQLD_DATADIR/test
+--list_files $MYSQLD_DATADIR/test
+--echo ---- MYSQLTEST_VARDIR/mysql-test-data-dir
+--list_files $MYSQLTEST_VARDIR/mysql-test-data-dir
+--echo ---- MYSQLTEST_VARDIR/mysql-test-idx-dir
+--list_files $MYSQLTEST_VARDIR/mysql-test-idx-dir
+--echo ---- MYSQLTEST_VARDIR/mysql-test-data-dir/test
+--list_files $MYSQLTEST_VARDIR/mysql-test-data-dir/test
-#------------------------------------------------------------------------------#
-# Engine specific settings and requirements
-
-##### Storage engine to be tested
---source include/have_innodb.inc
-let $engine= 'InnoDB';
-
-##### Execute the test of "table" files
-# InnoDB has no files per PK, UI, ...
-let $do_file_tests= 0;
-
-##### Execute PRIMARY KEY tests #####
-# AFAIK InnoDB clusters the table around PRIMARY KEYs.
-let $do_pk_tests= 1;
+DROP TABLE t1;
-##### Assign a big number smaller than the maximum value for partitions #####
-# and smaller than the maximum value of SIGNED INTEGER
-let $MAX_VALUE= (2147483646);
+--echo #
+--echo # Cleanup
+--echo #
-# Generate the prerequisites ($variables, @variables, tables) needed
---source suite/parts/inc/partition.pre
+--rmdir $MYSQLTEST_VARDIR/mysql-test-data-dir/test
+--rmdir $MYSQLTEST_VARDIR/mysql-test-data-dir
+--rmdir $MYSQLTEST_VARDIR/mysql-test-idx-dir
-##### Workarounds for known open engine specific bugs
-# none
+--disable_query_log
+EVAL SET GLOBAL innodb_file_per_table=$innodb_file_per_table_orig;
+EVAL SET SESSION innodb_strict_mode=$innodb_strict_mode_orig;
+--enable_query_log
-#------------------------------------------------------------------------------#
-# Execute the tests to be applied to all storage engines
---source suite/parts/inc/partition_basic_symlink.inc
-#------------------------------------------------------------------------------#
-# Execute storage engine specific tests
-#------------------------------------------------------------------------------#
-# Cleanup
---source suite/parts/inc/partition_cleanup.inc
diff --git a/mysql-test/suite/parts/t/partition_debug.test b/mysql-test/suite/parts/t/partition_debug.test
new file mode 100644
index 00000000000..11b66e4afd8
--- /dev/null
+++ b/mysql-test/suite/parts/t/partition_debug.test
@@ -0,0 +1,51 @@
+# 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_dbug="+d,ha_partition_fail_index_init";
+--error ER_NO_PARTITION_FOR_GIVEN_VALUE
+SELECT * FROM t1 WHERE b = "Seven";
+SET SESSION debug_dbug="-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
diff --git a/mysql-test/suite/parts/t/partition_debug_innodb-master.opt b/mysql-test/suite/parts/t/partition_debug_innodb-master.opt
index 6daff4c7c6b..5253df4563a 100644
--- a/mysql-test/suite/parts/t/partition_debug_innodb-master.opt
+++ b/mysql-test/suite/parts/t/partition_debug_innodb-master.opt
@@ -1 +1 @@
---loose-innodb-file-format-check --loose-innodb-file-per-table=1 --skip-stack-trace --skip-core-file
+--loose-innodb-file-format-check --loose-innodb-file-per-table=1 --skip-stack-trace --skip-core-file --loose-innodb-buffer-pool-size=32M
diff --git a/mysql-test/suite/parts/t/partition_debug_innodb.test b/mysql-test/suite/parts/t/partition_debug_innodb.test
index 33cbd8e3b7b..d4cac35c0b6 100644
--- a/mysql-test/suite/parts/t/partition_debug_innodb.test
+++ b/mysql-test/suite/parts/t/partition_debug_innodb.test
@@ -1,10 +1,12 @@
-# Partitioning test that require debug features
+# Partitioning test that require debug features and InnoDB
# including crashing tests.
--source include/have_debug.inc
--source include/have_innodb.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
@@ -13,6 +15,9 @@ DROP TABLE IF EXISTS t1;
--let $DATADIR= `SELECT @@datadir;`
+# Waiting for wl#6723
+if (0)
+{
--echo #
--echo # Bug#12696518/Bug#11766879/60106:DIFF BETWEEN # OF INDEXES IN MYSQL
--echo # VS INNODB, PARTITONING, ON INDEX CREATE
@@ -47,6 +52,7 @@ SELECT * FROM t1;
SET SESSION debug_dbug = "-d,ha_partition_fail_final_add_index";
SHOW CREATE TABLE t1;
DROP TABLE t1;
+}
# Checking with #innodb what this is...
call mtr.add_suppression("InnoDB: Warning: allocated tablespace .*, old maximum was");
@@ -60,3 +66,26 @@ let $engine= 'InnoDB';
--echo # Test crash and failure recovery in fast_alter_partition_table.
--source suite/parts/inc/partition_mgm_crash.inc
+
+--echo #
+--echo # WL#4445: EXCHANGE PARTITION WITH TABLE
+--echo # Verify ddl_log and InnoDB in case of crashing.
+# Investigating if this warning is OK when crash testing.
+call mtr.add_suppression("InnoDB: Warning: allocated tablespace .*, old maximum was ");
+#
+call mtr.add_suppression("Attempting backtrace. You can use the following information to find out");
+call mtr.add_suppression("table .* does not exist in the InnoDB internal");
+
+let $create_statement= CREATE TABLE t1 (a INT, b VARCHAR(64))
+ENGINE = InnoDB
+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)) ENGINE = InnoDB;
+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
diff --git a/mysql-test/suite/parts/t/partition_exch_innodb.test b/mysql-test/suite/parts/t/partition_exch_innodb.test
new file mode 100644
index 00000000000..cb666a426bd
--- /dev/null
+++ b/mysql-test/suite/parts/t/partition_exch_innodb.test
@@ -0,0 +1,12 @@
+# Author: Horst Hunger
+# Created: 2010-07-05
+
+--source include/have_innodb.inc
+--source include/have_partition.inc
+
+let $engine_table= InnoDB;
+let $engine_part= InnoDB;
+let $engine_subpart= InnoDB;
+
+--source suite/parts/inc/part_exch_qa.inc
+
diff --git a/mysql-test/suite/parts/t/partition_exch_myisam.test b/mysql-test/suite/parts/t/partition_exch_myisam.test
new file mode 100644
index 00000000000..c768040959f
--- /dev/null
+++ b/mysql-test/suite/parts/t/partition_exch_myisam.test
@@ -0,0 +1,11 @@
+# Author: Horst Hunger
+# Created: 2010-07-05
+
+--source include/have_partition.inc
+
+let $engine_table= MYISAM;
+let $engine_part= MYISAM;
+let $engine_subpart= MYISAM;
+
+--source suite/parts/inc/part_exch_qa.inc
+
diff --git a/mysql-test/suite/parts/t/partition_exch_myisam_innodb.test b/mysql-test/suite/parts/t/partition_exch_myisam_innodb.test
new file mode 100644
index 00000000000..fa956f19aec
--- /dev/null
+++ b/mysql-test/suite/parts/t/partition_exch_myisam_innodb.test
@@ -0,0 +1,21 @@
+# Author: Horst Hunger
+# Created: 2010-07-05
+
+--source include/have_innodb.inc
+--source include/have_partition.inc
+
+let $engine_table= MYISAM;
+let $engine_part= InnoDB;
+let $engine_subpart= InnoDB;
+
+--disable_result_log
+--disable_query_log
+--source suite/parts/inc/part_exch_tabs.inc
+--enable_result_log
+--enable_query_log
+
+--error 1497
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+
+--source suite/parts/inc/part_exch_drop_tabs.inc
+
diff --git a/mysql-test/suite/parts/t/partition_exch_qa.test b/mysql-test/suite/parts/t/partition_exch_qa.test
new file mode 100644
index 00000000000..c768040959f
--- /dev/null
+++ b/mysql-test/suite/parts/t/partition_exch_qa.test
@@ -0,0 +1,11 @@
+# Author: Horst Hunger
+# Created: 2010-07-05
+
+--source include/have_partition.inc
+
+let $engine_table= MYISAM;
+let $engine_part= MYISAM;
+let $engine_subpart= MYISAM;
+
+--source suite/parts/inc/part_exch_qa.inc
+
diff --git a/mysql-test/suite/parts/t/partition_exch_qa_10.test b/mysql-test/suite/parts/t/partition_exch_qa_10.test
new file mode 100644
index 00000000000..4f569605f5f
--- /dev/null
+++ b/mysql-test/suite/parts/t/partition_exch_qa_10.test
@@ -0,0 +1,69 @@
+# Author: Horst Hunger
+# Created: 2010-07-13
+
+--source include/not_embedded.inc
+--source include/have_partition.inc
+--source include/have_innodb.inc
+
+let $engine_table= InnoDB;
+let $engine_part= InnoDB;
+let $engine_subpart= InnoDB;
+
+use test;
+
+--disable_result_log
+--disable_query_log
+--source suite/parts/inc/part_exch_tabs.inc
+--enable_result_log
+--enable_query_log
+
+# 17) Exchanges in Procedure, triggers and events.
+DELIMITER |;
+CREATE PROCEDURE test_p1 ()
+BEGIN
+ALTER TABLE t_10 ADD UNIQUE INDEX USING BTREE (a);
+ALTER TABLE tp ADD UNIQUE INDEX USING BTREE (a);
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ALTER TABLE tp DROP INDEX a;
+ALTER TABLE t_10 DROP INDEX a;
+END|
+DELIMITER ;|
+CALL test_p1;
+--sorted_result
+SELECT * FROM t_10;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 0 AND 9;
+DROP PROCEDURE test_p1;
+
+SET @save_autocommit= @@autocommit;
+SET @@autocommit= OFF;
+SHOW VARIABLES LIKE '%autocommit%';
+DELIMITER |;
+--error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG
+CREATE TRIGGER test_trg_1 BEFORE UPDATE ON tp FOR EACH ROW
+BEGIN
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+END|
+--error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG
+CREATE FUNCTION test_f_1() RETURNS int
+BEGIN
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+END|
+DELIMITER ;|
+SET @@autocommit= @save_autocommit;
+
+SET @save_event_scheduler= @@global.event_scheduler;
+SET @@global.event_scheduler= ON;
+CREATE EVENT test_ev_1
+ ON SCHEDULE AT CURRENT_TIMESTAMP
+ DO
+ ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+sleep 1;
+--sorted_result
+SELECT * FROM t_10;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 0 AND 9;
+SET @@global.event_scheduler= @save_event_scheduler;
+
+--source suite/parts/inc/part_exch_drop_tabs.inc
+
diff --git a/mysql-test/suite/parts/t/partition_exch_qa_11.test b/mysql-test/suite/parts/t/partition_exch_qa_11.test
new file mode 100644
index 00000000000..3283c65966b
--- /dev/null
+++ b/mysql-test/suite/parts/t/partition_exch_qa_11.test
@@ -0,0 +1,37 @@
+# Author: Horst Hunger
+# Created: 2010-07-13
+
+--source include/have_partition.inc
+
+let $engine_table= MYISAM;
+let $engine_part= MYISAM;
+let $engine_subpart= MYISAM;
+
+use test;
+
+--disable_result_log
+--disable_query_log
+--source suite/parts/inc/part_exch_tabs.inc
+--enable_result_log
+--enable_query_log
+
+# 13) Exchange with dynamic variables.
+SET @part= 'p0';
+SET @part_tab= 'tp';
+SET @table= 't_10';
+SET @s= CONCAT('ALTER TABLE ',@part_tab,' EXCHANGE PARTITION ',@part,' WITH TABLE ',@table);
+PREPARE test_stmt1 FROM @s;
+EXECUTE test_stmt1;
+--sorted_result
+SELECT * FROM t_10;
+--sorted_result
+SELECT * FROM tp;
+DEALLOCATE PREPARE test_stmt1;
+
+SET @part_tab= 'tp';
+SET @s= CONCAT('ALTER TABLE ',@part_tab,' EXCHANGE PARTITION ? WITH TABLE ?');
+--error ER_PARSE_ERROR
+PREPARE test_stmt2 FROM @s;
+
+--source suite/parts/inc/part_exch_drop_tabs.inc
+
diff --git a/mysql-test/suite/parts/t/partition_exch_qa_12.test b/mysql-test/suite/parts/t/partition_exch_qa_12.test
new file mode 100644
index 00000000000..7e048f79017
--- /dev/null
+++ b/mysql-test/suite/parts/t/partition_exch_qa_12.test
@@ -0,0 +1,178 @@
+# Author: Horst Hunger
+# Created: 2010-07-13
+
+--source include/have_partition.inc
+
+let $engine_table= MYISAM;
+let $engine_part= MYISAM;
+let $engine_subpart= MYISAM;
+
+use test;
+
+--disable_result_log
+--disable_query_log
+--disable_warnings
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
+--enable_warnings
+
+eval CREATE TABLE t_10 (a INT,
+ b VARCHAR(55),
+ PRIMARY KEY (a))
+CHECKSUM= 1,
+ENGINE = $engine_table;
+
+eval CREATE TABLE t_100 (a INT,
+ b VARCHAR(55),
+ PRIMARY KEY (a))
+COMMENT= 'comment',
+ROW_FORMAT= COMPRESSED,
+ENGINE = $engine_table;
+
+eval CREATE TABLE t_1000 (a INT,
+ b VARCHAR(55),
+ PRIMARY KEY (a))
+MIN_ROWS= 1,
+MAX_ROWS= 200,
+ENGINE = $engine_table;
+
+eval CREATE TABLE t_empty (a INT,
+ b VARCHAR(55),
+ PRIMARY KEY (a))
+ENGINE = $engine_table;
+
+eval CREATE TABLE t_null (a INT,
+ b VARCHAR(55),
+ PRIMARY KEY (a))
+ENGINE = $engine_table;
+
+eval CREATE TABLE tp (a INT,
+ b VARCHAR(55),
+ PRIMARY KEY (a))
+ENGINE = $engine_part
+PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10),
+ PARTITION p1 VALUES LESS THAN (100),
+ PARTITION p2 VALUES LESS THAN (1000));
+
+eval CREATE TABLE tsp (a INT,
+ b VARCHAR(55),
+ PRIMARY KEY (a))
+ENGINE = $engine_subpart
+PARTITION BY RANGE (a)
+SUBPARTITION BY HASH(a)
+(PARTITION p0 VALUES LESS THAN (10)
+ (SUBPARTITION sp00,
+ SUBPARTITION sp01,
+ SUBPARTITION sp02,
+ SUBPARTITION sp03,
+ SUBPARTITION sp04),
+ PARTITION p1 VALUES LESS THAN (100)
+ (SUBPARTITION sp10,
+ SUBPARTITION sp11,
+ SUBPARTITION sp12,
+ SUBPARTITION sp13,
+ SUBPARTITION sp14),
+ PARTITION p2 VALUES LESS THAN (1000)
+ (SUBPARTITION sp20,
+ SUBPARTITION sp21,
+ SUBPARTITION sp22,
+ SUBPARTITION sp23,
+ SUBPARTITION sp24));
+
+# Values t_10 (not partitioned)
+INSERT INTO t_10 VALUES (1, "One"), (3, "Three"), (5, "Five"), (9, "Nine");
+
+# Values t_100 (not partitioned)
+INSERT INTO t_100 VALUES (11, "Eleven"), (13, "Thirdteen"), (15, "Fifeteen"), (19, "Nineteen");
+INSERT INTO t_100 VALUES (91, "Ninety-one"), (93, "Ninety-three"), (95, "Ninety-five"), (99, "Ninety-nine");
+
+# Values t_1000 (not partitioned)
+INSERT INTO t_1000 VALUES (111, "Hundred elven"), (113, "Hundred thirdteen"), (115, "Hundred fiveteen"), (119, "Hundred nineteen");
+INSERT INTO t_1000 VALUES (131, "Hundred thirty-one"), (133, "Hundred thirty-three"), (135, "Hundred thirty-five"), (139, "Hundred thirty-nine");
+INSERT INTO t_1000 VALUES (151, "Hundred fifty-one"), (153, "Hundred fifty-three"), (155, "Hundred fity-five"), (159, "Hundred fifty-nine");
+INSERT INTO t_1000 VALUES (191, "Hundred ninety-one"), (193, "Hundred ninety-three"), (195, "Hundred ninety-five"), (199, "Hundred ninety-nine");
+
+# Values t_null (not partitioned)
+INSERT INTO t_null VALUES (1, "NULL");
+
+# Values tp (partitions)
+INSERT INTO tp VALUES (2, "Two"), (4, "Four"), (6, "Six"), (8, "Eight");
+INSERT INTO tp VALUES (12, "twelve"), (14, "Fourteen"), (16, "Sixteen"), (18, "Eightteen");
+INSERT INTO tp VALUES (112, "Hundred twelve"), (114, "Hundred fourteen"), (116, "Hundred sixteen"), (118, "Hundred eightteen");
+INSERT INTO tp VALUES (122, "Hundred twenty-two"), (124, "Hundred twenty-four"), (126, "Hundred twenty-six"), (128, "Hundred twenty-eight");
+INSERT INTO tp VALUES (162, "Hundred sixty-two"), (164, "Hundred sixty-four"), (166, "Hundred sixty-six"), (168, "Hundred sixty-eight");
+INSERT INTO tp VALUES (182, "Hundred eighty-two"), (184, "Hundred eighty-four"), (186, "Hundred eighty-six"), (188, "Hundred eighty-eight");
+
+# Values tps (subpartitions)
+INSERT INTO tsp VALUES (2, "Two"), (4, "Four"), (6, "Six"), (8, "Eight");
+INSERT INTO tsp VALUES (12, "twelve"), (14, "Fourteen"), (16, "Sixteen"), (18, "Eightteen");
+INSERT INTO tsp VALUES (112, "Hundred twelve"), (114, "Hundred fourteen"), (116, "Hundred sixteen"), (118, "Hundred eightteen");
+INSERT INTO tsp VALUES (122, "Hundred twenty-two"), (124, "Hundred twenty-four"), (126, "Hundred twenty-six"), (128, "Hundred twenty-eight");
+INSERT INTO tsp VALUES (162, "Hundred sixty-two"), (164, "Hundred sixty-four"), (166, "Hundred sixty-six"), (168, "Hundred sixty-eight");
+INSERT INTO tsp VALUES (182, "Hundred eight-two"), (184, "Hundred eighty-four"), (186, "Hundred eighty-six"), (188, "Hundred eighty-eight");
+
+eval CREATE TABLE tsp_01(a INT,b VARCHAR(55),PRIMARY KEY (a)) ENGINE = $engine_table
+ AS SELECT a, b FROM t_10 WHERE MOD(a,5)= 1;
+eval CREATE TABLE tsp_02(a INT,b VARCHAR(55),PRIMARY KEY (a)) ENGINE = $engine_table
+ AS SELECT a, b FROM t_10 WHERE MOD(a,5)= 2;
+eval CREATE TABLE tsp_03(a INT,b VARCHAR(55),PRIMARY KEY (a)) ENGINE = $engine_table
+ AS SELECT a, b FROM t_10 WHERE MOD(a,5)= 3;
+eval CREATE TABLE tsp_04(a INT,b VARCHAR(55),PRIMARY KEY (a)) ENGINE = $engine_table
+ AS SELECT a, b FROM t_10 WHERE MOD(a,5)= 4;
+eval CREATE TABLE tsp_00(a INT,b VARCHAR(55),PRIMARY KEY (a)) ENGINE = $engine_table
+ AS SELECT a, b FROM t_10 WHERE MOD(a,5)= 0;
+
+SHOW CREATE TABLE t_10;
+SHOW CREATE TABLE t_100;
+SHOW CREATE TABLE t_1000;
+SHOW CREATE TABLE tp;
+SHOW CREATE TABLE tsp;
+
+--enable_result_log
+--enable_query_log
+
+--sorted_result
+SELECT * FROM t_10;
+--sorted_result
+SELECT * FROM t_100;
+--sorted_result
+SELECT * FROM t_1000;
+--sorted_result
+SELECT * FROM tp;
+--sorted_result
+SELECT * FROM tsp;
+--sorted_result
+SELECT * FROM tsp_00;
+--sorted_result
+SELECT * FROM tsp_01;
+--sorted_result
+SELECT * FROM tsp_02;
+--sorted_result
+SELECT * FROM tsp_03;
+--sorted_result
+SELECT * FROM tsp_04;
+
+# 13) Exchanges with different table options.
+# IGNORE was removed in bug#57708.
+--error ER_TABLES_DIFFERENT_METADATA
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+#--error ER_TABLES_DIFFERENT_METADATA
+#ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10 IGNORE;
+SELECT TABLE_NAME, ROW_FORMAT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'test'
+AND TABLE_NAME IN ('tp', 't_100');
+ALTER TABLE tp EXCHANGE PARTITION p1 WITH TABLE t_100;
+#--error ER_TABLES_DIFFERENT_METADATA
+#ALTER TABLE tp EXCHANGE PARTITION p1 WITH TABLE t_100 IGNORE;
+--error ER_PARTITION_EXCHANGE_DIFFERENT_OPTION
+ALTER TABLE tp EXCHANGE PARTITION p1 WITH TABLE t_1000;
+#--error ER_PARTITION_EXCHANGE_DIFFERENT_OPTION
+#ALTER TABLE tp EXCHANGE PARTITION p1 WITH TABLE t_1000 IGNORE;
+
+--source suite/parts/inc/part_exch_drop_tabs.inc
+
diff --git a/mysql-test/suite/parts/t/partition_exch_qa_13.test b/mysql-test/suite/parts/t/partition_exch_qa_13.test
new file mode 100644
index 00000000000..c830ee61dad
--- /dev/null
+++ b/mysql-test/suite/parts/t/partition_exch_qa_13.test
@@ -0,0 +1,11 @@
+# Author: Horst Hunger
+# Created: 2010-07-13
+
+--source include/have_partition.inc
+
+let $engine_table= MYISAM;
+let $engine_part= MYISAM;
+let $engine_subpart= MYISAM;
+
+--source suite/parts/inc/part_exch_qa_13.inc
+
diff --git a/mysql-test/suite/parts/t/partition_exch_qa_14.test b/mysql-test/suite/parts/t/partition_exch_qa_14.test
new file mode 100644
index 00000000000..7c6699a0a72
--- /dev/null
+++ b/mysql-test/suite/parts/t/partition_exch_qa_14.test
@@ -0,0 +1,94 @@
+# Author: Horst Hunger
+# Created: 2010-07-13
+
+--source include/not_windows.inc
+--source include/have_partition.inc
+--source include/have_symlink.inc
+
+let $engine_table= MYISAM;
+let $engine_part= MYISAM;
+let $engine_subpart= MYISAM;
+
+# DATA DIRECTORY
+# Make directory for partition data
+let $data_dir_path= $MYSQLTEST_VARDIR/mysql-test-data-dir;
+--mkdir $data_dir_path
+let $p_data_directory= DATA DIRECTORY = '$data_dir_path';
+let $data_directory= DATA DIRECTORY = '$data_dir_path';
+
+# INDEX DIRECTORY
+# Make directory for partition index
+let $idx_dir_path= $MYSQLTEST_VARDIR/mysql-test-idx-dir;
+--mkdir $idx_dir_path
+let $p_index_directory= INDEX DIRECTORY = '$idx_dir_path';
+let $index_directory= INDEX DIRECTORY = '$idx_dir_path';
+
+use test;
+
+--disable_result_log
+--disable_query_log
+--source suite/parts/inc/part_exch_tabs.inc
+--enable_result_log
+--enable_query_log
+
+--error ER_TABLES_DIFFERENT_METADATA
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+
+--source suite/parts/inc/part_exch_drop_tabs.inc
+--rmdir $data_dir_path
+--rmdir $idx_dir_path
+
+# DATA DIRECTORY
+# Make directory for partition data
+let $data_dir_path= $MYSQLTEST_VARDIR/mysql-test-data-dir;
+--mkdir $data_dir_path
+let $p_data_directory= DATA DIRECTORY = '$data_dir_path';
+
+# INDEX DIRECTORY
+# Make directory for partition index
+let $idx_dir_path= $MYSQLTEST_VARDIR/mysql-test-idx-dir;
+--mkdir $idx_dir_path
+let $p_index_directory= INDEX DIRECTORY = '$idx_dir_path';
+
+use test;
+
+--disable_result_log
+--disable_query_log
+--source suite/parts/inc/part_exch_tabs.inc
+--enable_result_log
+--enable_query_log
+
+--error ER_TABLES_DIFFERENT_METADATA
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+
+--source suite/parts/inc/part_exch_drop_tabs.inc
+--rmdir $data_dir_path
+--rmdir $idx_dir_path
+
+# DATA DIRECTORY
+# Make directory for partition data
+let $data_dir_path= $MYSQLTEST_VARDIR/mysql-test-data-dir;
+--mkdir $data_dir_path
+let $data_directory= DATA DIRECTORY = '$data_dir_path';
+
+# INDEX DIRECTORY
+# Make directory for partition index
+let $idx_dir_path= $MYSQLTEST_VARDIR/mysql-test-idx-dir;
+--mkdir $idx_dir_path
+let $index_directory= INDEX DIRECTORY = '$idx_dir_path';
+
+use test;
+
+--disable_result_log
+--disable_query_log
+--source suite/parts/inc/part_exch_tabs.inc
+--enable_result_log
+--enable_query_log
+
+--error ER_TABLES_DIFFERENT_METADATA
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+
+--source suite/parts/inc/part_exch_drop_tabs.inc
+--rmdir $data_dir_path
+--rmdir $idx_dir_path
+
diff --git a/mysql-test/suite/parts/t/partition_exch_qa_15.test b/mysql-test/suite/parts/t/partition_exch_qa_15.test
new file mode 100644
index 00000000000..51d09be5ed9
--- /dev/null
+++ b/mysql-test/suite/parts/t/partition_exch_qa_15.test
@@ -0,0 +1,31 @@
+# Author: Horst Hunger
+# Created: 2010-07-15
+
+--source include/have_innodb.inc
+--source include/have_partition.inc
+
+let $engine_table= InnoDB;
+let $engine_part= InnoDB;
+let $engine_subpart= InnoDB;
+
+use test;
+
+--disable_result_log
+--disable_query_log
+--source suite/parts/inc/part_exch_tabs.inc
+--enable_result_log
+--enable_query_log
+
+# 21) Foreign Key.
+# Exchange of partition with table differing in structure.
+CREATE TABLE t_11 (a INT, b VARCHAR(55),
+ FOREIGN KEY (a) REFERENCES t_10 (a) ON DELETE CASCADE)
+ ENGINE= InnoDB;
+#--error ER_TABLES_DIFFERENT_METADATA
+--error ER_PARTITION_EXCHANGE_FOREIGN_KEY
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_11;
+--disable_warnings
+DROP TABLE IF EXISTS t_11;
+--enable_warnings
+--source suite/parts/inc/part_exch_drop_tabs.inc
+
diff --git a/mysql-test/suite/parts/t/partition_exch_qa_1_innodb.test b/mysql-test/suite/parts/t/partition_exch_qa_1_innodb.test
new file mode 100644
index 00000000000..210791515dc
--- /dev/null
+++ b/mysql-test/suite/parts/t/partition_exch_qa_1_innodb.test
@@ -0,0 +1,12 @@
+# Author: Horst Hunger
+# Created: 2010-07-13
+
+--source include/have_partition.inc
+--source include/have_innodb.inc
+
+let $engine_table= InnoDB;
+let $engine_part= InnoDB;
+let $engine_subpart= InnoDB;
+
+--source suite/parts/inc/part_exch_qa_1.inc
+
diff --git a/mysql-test/suite/parts/t/partition_exch_qa_1_myisam.test b/mysql-test/suite/parts/t/partition_exch_qa_1_myisam.test
new file mode 100644
index 00000000000..db3a428b01b
--- /dev/null
+++ b/mysql-test/suite/parts/t/partition_exch_qa_1_myisam.test
@@ -0,0 +1,11 @@
+# Author: Horst Hunger
+# Created: 2010-07-13
+
+--source include/have_partition.inc
+
+let $engine_table= MYISAM;
+let $engine_part= MYISAM;
+let $engine_subpart= MYISAM;
+
+--source suite/parts/inc/part_exch_qa_1.inc
+
diff --git a/mysql-test/suite/parts/t/partition_exch_qa_2.test b/mysql-test/suite/parts/t/partition_exch_qa_2.test
new file mode 100644
index 00000000000..83dc0a81fca
--- /dev/null
+++ b/mysql-test/suite/parts/t/partition_exch_qa_2.test
@@ -0,0 +1,80 @@
+# Author: Horst Hunger
+# Created: 2010-07-05
+
+--source include/have_partition.inc
+
+let $engine_table= MYISAM;
+let $engine_part= MYISAM;
+let $engine_subpart= MYISAM;
+
+use test;
+
+--disable_result_log
+--disable_query_log
+--source suite/parts/inc/part_exch_tabs.inc
+--enable_result_log
+--enable_query_log
+
+--sorted_result
+SELECT * FROM t_10;
+--sorted_result
+SELECT * FROM t_100;
+--sorted_result
+SELECT * FROM t_1000;
+--sorted_result
+SELECT * FROM tp;
+--sorted_result
+SELECT * FROM tsp;
+--sorted_result
+SELECT * FROM tsp_00;
+--sorted_result
+SELECT * FROM tsp_01;
+--sorted_result
+SELECT * FROM tsp_02;
+--sorted_result
+SELECT * FROM tsp_03;
+--sorted_result
+SELECT * FROM tsp_04;
+
+# 3) Invalid exchanges.
+# Exchange of partition with table differing in structure.
+CREATE TABLE t_11(a INT,b VARCHAR(55)) SELECT * FROM t_10;
+--error ER_TABLES_DIFFERENT_METADATA
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_11;
+--disable_warnings
+DROP TABLE IF EXISTS t_11;
+--enable_warnings
+eval CREATE TABLE t_11(a INT,b CHAR(55),PRIMARY KEY(a)) ENGINE= $engine_table SELECT * FROM t_10;
+--error ER_TABLES_DIFFERENT_METADATA
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_11;
+--disable_warnings
+DROP TABLE IF EXISTS t_11;
+CREATE TABLE t_11(a INT,b VARCHAR(55),PRIMARY KEY(a)) ENGINE= MEMORY SELECT * FROM t_10;
+--error ER_MIX_HANDLER_ERROR
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_11;
+--disable_warnings
+DROP TABLE IF EXISTS t_11;
+--enable_warnings
+# Exchange of partition with partitioned table.
+eval CREATE TABLE t_11(a INT,b CHAR(55),PRIMARY KEY(a)) ENGINE= $engine_table
+ PARTITION BY KEY() AS SELECT * FROM t_10;
+--error ER_PARTITION_EXCHANGE_PART_TABLE
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_11;
+--disable_warnings
+DROP TABLE IF EXISTS t_11;
+--enable_warnings
+# Exchange of subpartition with partitioned table.
+--error ER_PARTITION_EXCHANGE_PART_TABLE
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE tsp;
+# Exchange of subpartitioned partition with table.
+--error ER_PARTITION_INSTEAD_OF_SUBPARTITION
+ALTER TABLE tsp EXCHANGE PARTITION p0 WITH TABLE t_10;
+# Exchange of values in partition not fitting the hash.
+--error ER_ROW_DOES_NOT_MATCH_PARTITION
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_100;
+# Exchange of values in subpartition not fitting the hash.
+--error ER_ROW_DOES_NOT_MATCH_PARTITION
+ALTER TABLE tp EXCHANGE PARTITION p2 WITH TABLE t_10;
+
+--source suite/parts/inc/part_exch_drop_tabs.inc
+
diff --git a/mysql-test/suite/parts/t/partition_exch_qa_3.test b/mysql-test/suite/parts/t/partition_exch_qa_3.test
new file mode 100644
index 00000000000..aa79e97adb6
--- /dev/null
+++ b/mysql-test/suite/parts/t/partition_exch_qa_3.test
@@ -0,0 +1,47 @@
+# Author: Horst Hunger
+# Created: 2010-07-05
+
+--source include/have_partition.inc
+--source include/have_innodb.inc
+
+let $engine_table= MYISAM;
+let $engine_part= InnoDB;
+let $engine_subpart= InnoDB;
+
+use test;
+
+--disable_result_log
+--disable_query_log
+--source suite/parts/inc/part_exch_tabs.inc
+
+--sorted_result
+SELECT * FROM t_10;
+--sorted_result
+SELECT * FROM t_100;
+--sorted_result
+SELECT * FROM t_1000;
+--sorted_result
+SELECT * FROM tp;
+--sorted_result
+SELECT * FROM tsp;
+--sorted_result
+SELECT * FROM tsp_00;
+--sorted_result
+SELECT * FROM tsp_01;
+--sorted_result
+SELECT * FROM tsp_02;
+--sorted_result
+SELECT * FROM tsp_03;
+--sorted_result
+SELECT * FROM tsp_04;
+--enable_result_log
+--enable_query_log
+
+# 5) Exchanges with different engines.
+--error ER_MIX_HANDLER_ERROR
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+--error ER_MIX_HANDLER_ERROR
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+
+--source suite/parts/inc/part_exch_drop_tabs.inc
+
diff --git a/mysql-test/suite/parts/t/partition_exch_qa_4_innodb.test b/mysql-test/suite/parts/t/partition_exch_qa_4_innodb.test
new file mode 100644
index 00000000000..ea38337f3aa
--- /dev/null
+++ b/mysql-test/suite/parts/t/partition_exch_qa_4_innodb.test
@@ -0,0 +1,12 @@
+# Author: Horst Hunger
+# Created: 2010-07-06
+
+--source include/have_partition.inc
+--source include/have_innodb.inc
+
+let $engine_table= InnoDB;
+let $engine_part= InnoDB;
+let $engine_subpart= InnoDB;
+
+--source suite/parts/inc/part_exch_qa_4.inc
+
diff --git a/mysql-test/suite/parts/t/partition_exch_qa_4_myisam.test b/mysql-test/suite/parts/t/partition_exch_qa_4_myisam.test
new file mode 100644
index 00000000000..f668164630b
--- /dev/null
+++ b/mysql-test/suite/parts/t/partition_exch_qa_4_myisam.test
@@ -0,0 +1,11 @@
+# Author: Horst Hunger
+# Created: 2010-07-06
+
+--source include/have_partition.inc
+
+let $engine_table= MYISAM;
+let $engine_part= MYISAM;
+let $engine_subpart= MYISAM;
+
+--source suite/parts/inc/part_exch_qa_4.inc
+
diff --git a/mysql-test/suite/parts/t/partition_exch_qa_5_innodb.test b/mysql-test/suite/parts/t/partition_exch_qa_5_innodb.test
new file mode 100644
index 00000000000..b1daa070412
--- /dev/null
+++ b/mysql-test/suite/parts/t/partition_exch_qa_5_innodb.test
@@ -0,0 +1,12 @@
+# Author: Horst Hunger
+# Created: 2010-07-06
+
+--source include/have_partition.inc
+--source include/have_innodb.inc
+
+let $engine_table= InnoDB;
+let $engine_part= InnoDB;
+let $engine_subpart= InnoDB;
+
+--source suite/parts/inc/part_exch_qa_5.inc
+
diff --git a/mysql-test/suite/parts/t/partition_exch_qa_5_myisam.test b/mysql-test/suite/parts/t/partition_exch_qa_5_myisam.test
new file mode 100644
index 00000000000..8fcf43b8148
--- /dev/null
+++ b/mysql-test/suite/parts/t/partition_exch_qa_5_myisam.test
@@ -0,0 +1,11 @@
+# Author: Horst Hunger
+# Created: 2010-07-06
+
+--source include/have_partition.inc
+
+let $engine_table= MYISAM;
+let $engine_part= MYISAM;
+let $engine_subpart= MYISAM;
+
+--source suite/parts/inc/part_exch_qa_5.inc
+
diff --git a/mysql-test/suite/parts/t/partition_exch_qa_6.test b/mysql-test/suite/parts/t/partition_exch_qa_6.test
new file mode 100644
index 00000000000..bad1e134af7
--- /dev/null
+++ b/mysql-test/suite/parts/t/partition_exch_qa_6.test
@@ -0,0 +1,102 @@
+# Author: Horst Hunger
+# Created: 2010-07-06
+
+--source include/not_embedded.inc
+--source include/have_partition.inc
+
+let $engine_table= MYISAM;
+let $engine_part= MYISAM;
+let $engine_subpart= MYISAM;
+
+CREATE USER test2@localhost;
+
+--disable_result_log
+--disable_query_log
+--source suite/parts/inc/part_exch_tabs.inc
+--enable_result_log
+--enable_query_log
+
+GRANT USAGE ON *.* TO test2@localhost;
+GRANT CREATE, DROP, ALTER, UPDATE, INSERT, SELECT ON test.* TO test2@localhost;
+
+--echo connect (test2,localhost,test2,,test,MASTER_MYPORT,MASTER_MYSOCK);
+connect (test2,localhost,test2,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
+USE test;
+SHOW GRANTS FOR CURRENT_USER;
+# 9) Exchanges with different owner.
+# Privilege for ALTER and SELECT
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+--sorted_result
+SELECT * FROM t_10;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+# Back to former values.
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+--sorted_result
+SELECT * FROM t_10;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+--sorted_result
+SELECT * FROM tsp_00;
+--sorted_result
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+# Back to former values.
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+--sorted_result
+SELECT * FROM tsp_00;
+--sorted_result
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+--echo disconnect test2;
+disconnect test2;
+
+--echo connection default;
+connection default;
+REVOKE INSERT ON test.* FROM test2@localhost;
+
+--echo connect (test2,localhost,test2,,test,MASTER_MYPORT,MASTER_MYSOCK);
+connect (test2,localhost,test2,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
+USE test;
+SHOW GRANTS FOR CURRENT_USER;
+# Privilege for ALTER and SELECT
+--error ER_TABLEACCESS_DENIED_ERROR
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+--echo disconnect test2;
+disconnect test2;
+
+--echo connection default;
+connection default;
+GRANT INSERT ON test.* TO test2@localhost;
+REVOKE CREATE ON test.* FROM test2@localhost;
+
+--echo connect (test2,localhost,test2,,test,MASTER_MYPORT,MASTER_MYSOCK);
+connect (test2,localhost,test2,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
+USE test;
+SHOW GRANTS FOR CURRENT_USER;
+--error ER_TABLEACCESS_DENIED_ERROR
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+--echo disconnect test2;
+disconnect test2;
+
+--echo connection default;
+connection default;
+GRANT CREATE ON test.* TO test2@localhost;
+REVOKE DROP ON test.* FROM test2@localhost;
+
+--echo connect (test2,localhost,test2,,test,MASTER_MYPORT,MASTER_MYSOCK);
+connect (test2,localhost,test2,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
+USE test;
+SHOW GRANTS FOR CURRENT_USER;
+# Privilege for ALTER and SELECT
+--error ER_TABLEACCESS_DENIED_ERROR
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+--echo disconnect test2;
+disconnect test2;
+
+--echo connection default;
+connection default;
+
+--source suite/parts/inc/part_exch_drop_tabs.inc
+
+DROP USER test2@localhost;
+
diff --git a/mysql-test/suite/parts/t/partition_exch_qa_7_innodb.test b/mysql-test/suite/parts/t/partition_exch_qa_7_innodb.test
new file mode 100644
index 00000000000..e23790672ab
--- /dev/null
+++ b/mysql-test/suite/parts/t/partition_exch_qa_7_innodb.test
@@ -0,0 +1,12 @@
+# Author: Horst Hunger
+# Created: 2010-07-06
+
+--source include/have_partition.inc
+--source include/have_innodb.inc
+
+let $engine_table= InnoDB;
+let $engine_part= InnoDB;
+let $engine_subpart= InnoDB;
+
+--source suite/parts/inc/part_exch_qa_7.inc
+
diff --git a/mysql-test/suite/parts/t/partition_exch_qa_7_myisam.test b/mysql-test/suite/parts/t/partition_exch_qa_7_myisam.test
new file mode 100644
index 00000000000..e1bbd2b5815
--- /dev/null
+++ b/mysql-test/suite/parts/t/partition_exch_qa_7_myisam.test
@@ -0,0 +1,11 @@
+# Author: Horst Hunger
+# Created: 2010-07-06
+
+--source include/have_partition.inc
+
+let $engine_table= MYISAM;
+let $engine_part= MYISAM;
+let $engine_subpart= MYISAM;
+
+--source suite/parts/inc/part_exch_qa_7.inc
+
diff --git a/mysql-test/suite/parts/t/partition_exch_qa_8_innodb.test b/mysql-test/suite/parts/t/partition_exch_qa_8_innodb.test
new file mode 100644
index 00000000000..58fecdbc66d
--- /dev/null
+++ b/mysql-test/suite/parts/t/partition_exch_qa_8_innodb.test
@@ -0,0 +1,12 @@
+# Author: Horst Hunger
+# Created: 2010-07-07
+
+--source include/have_partition.inc
+--source include/have_innodb.inc
+
+let $engine_table= InnoDB;
+let $engine_part= InnoDB;
+let $engine_subpart= InnoDB;
+
+--source suite/parts/inc/part_exch_qa_8.inc
+
diff --git a/mysql-test/suite/parts/t/partition_exch_qa_8_myisam.test b/mysql-test/suite/parts/t/partition_exch_qa_8_myisam.test
new file mode 100644
index 00000000000..b8573a6aabf
--- /dev/null
+++ b/mysql-test/suite/parts/t/partition_exch_qa_8_myisam.test
@@ -0,0 +1,11 @@
+# Author: Horst Hunger
+# Created: 2010-07-07
+
+--source include/have_partition.inc
+
+let $engine_table= MYISAM;
+let $engine_part= MYISAM;
+let $engine_subpart= MYISAM;
+
+--source suite/parts/inc/part_exch_qa_8.inc
+
diff --git a/mysql-test/suite/parts/t/partition_exchange_archive.test b/mysql-test/suite/parts/t/partition_exchange_archive.test
new file mode 100644
index 00000000000..3376e2ff884
--- /dev/null
+++ b/mysql-test/suite/parts/t/partition_exchange_archive.test
@@ -0,0 +1,11 @@
+--source include/have_archive.inc
+--source include/have_partition.inc
+--source include/have_debug_sync.inc
+
+
+--echo # Archive does not support keys, update or delete
+let $engine= 'Archive';
+let $no_keys= 1;
+let $no_update= 1;
+let $no_delete= 1;
+--source suite/parts/inc/partition_exchange.inc
diff --git a/mysql-test/suite/parts/t/partition_exchange_blackhole.test b/mysql-test/suite/parts/t/partition_exchange_blackhole.test
new file mode 100644
index 00000000000..e58bccfb1a8
--- /dev/null
+++ b/mysql-test/suite/parts/t/partition_exchange_blackhole.test
@@ -0,0 +1,18 @@
+--source include/have_blackhole.inc
+--source include/have_partition.inc
+--source include/have_debug_sync.inc
+
+let $engine= 'Blackhole';
+--echo # Blackhole has not implemented check_if_incompatible_data,
+--echo # so it cannot support EXCHANGE PARTITION
+CREATE TABLE t (a int, b varchar(55)) ENGINE = 'Blackhole';
+CREATE TABLE tp (a int, b varchar(55)) ENGINE = 'Blackhole'
+PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (100),
+ PARTITION p1 VALUES LESS THAN MAXVALUE);
+--error ER_TABLES_DIFFERENT_METADATA
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t;
+DROP TABLE t, tp;
+
+# to use when check_if_incompatible_data is implemented in ha_blackhole
+#--source suite/parts/inc/partition_exchange.inc
diff --git a/mysql-test/suite/parts/t/partition_exchange_innodb.test b/mysql-test/suite/parts/t/partition_exchange_innodb.test
new file mode 100644
index 00000000000..31ea61bbb7b
--- /dev/null
+++ b/mysql-test/suite/parts/t/partition_exchange_innodb.test
@@ -0,0 +1,6 @@
+--source include/have_innodb.inc
+--source include/have_partition.inc
+--source include/have_debug_sync.inc
+
+let $engine= 'InnoDB';
+--source suite/parts/inc/partition_exchange.inc
diff --git a/mysql-test/suite/parts/t/partition_exchange_memory.test b/mysql-test/suite/parts/t/partition_exchange_memory.test
new file mode 100644
index 00000000000..7384a49f829
--- /dev/null
+++ b/mysql-test/suite/parts/t/partition_exchange_memory.test
@@ -0,0 +1,5 @@
+--source include/have_partition.inc
+--source include/have_debug_sync.inc
+
+let $engine= 'Memory';
+--source suite/parts/inc/partition_exchange.inc
diff --git a/mysql-test/suite/parts/t/partition_exchange_myisam.test b/mysql-test/suite/parts/t/partition_exchange_myisam.test
new file mode 100644
index 00000000000..68e55090a9c
--- /dev/null
+++ b/mysql-test/suite/parts/t/partition_exchange_myisam.test
@@ -0,0 +1,5 @@
+--source include/have_partition.inc
+--source include/have_debug_sync.inc
+
+let $engine= 'MyISAM';
+--source suite/parts/inc/partition_exchange.inc
diff --git a/mysql-test/suite/parts/t/partition_repair_myisam.test b/mysql-test/suite/parts/t/partition_repair_myisam.test
index 96d68fd7fc9..f7c503a8544 100644
--- a/mysql-test/suite/parts/t/partition_repair_myisam.test
+++ b/mysql-test/suite/parts/t/partition_repair_myisam.test
@@ -5,6 +5,8 @@
drop table if exists t1_will_crash;
call mtr.add_suppression("Got an error from thread_id=.*ha_myisam.cc:");
call mtr.add_suppression("MySQL thread id .*, query id .* localhost.*root Checking table");
+call mtr.add_suppression("is marked as crashed and should be repaired");
+
--enable_query_log
--enable_warnings
@@ -12,6 +14,43 @@ call mtr.add_suppression("MySQL thread id .*, query id .* localhost.*root Checki
let $MYSQLD_DATADIR= `select @@datadir`;
+--echo # Test what happens if we exchange a crashed partition with a table
+SHOW VARIABLES LIKE 'myisam_recover_options';
+CREATE TABLE t (a INT, KEY (a)) ENGINE=MyISAM;
+CREATE TABLE tp (a INT, KEY (a)) ENGINE=MyISAM
+PARTITION BY RANGE (a)
+(PARTITION pCrashed VALUES LESS THAN (15),
+ PARTITION pMAX VALUES LESS THAN MAXVALUE);
+INSERT INTO t VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10), (11);
+INSERT INTO tp VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10), (11);
+FLUSH TABLES;
+--echo # replacing tp#P#pCrashed.MYI with a corrupt + unclosed one created by doing:
+--echo # 'create table t1 (a int key(a))' head -c1024 t1.MYI > corrupt_t1.MYI
+--remove_file $MYSQLD_DATADIR/test/tp#P#pCrashed.MYI
+--copy_file std_data/corrupt_t1.MYI $MYSQLD_DATADIR/test/tp#P#pCrashed.MYI
+CHECK TABLE tp;
+--replace_regex /[^']*test[^']*t/.\/test\/t/
+--error 145
+ALTER TABLE tp EXCHANGE PARTITION pCrashed WITH TABLE t;
+REPAIR TABLE tp;
+CHECK TABLE tp;
+ALTER TABLE tp EXCHANGE PARTITION pCrashed WITH TABLE t;
+CHECK TABLE t;
+CHECK TABLE tp;
+FLUSH TABLES;
+--remove_file $MYSQLD_DATADIR/test/t.MYI
+--copy_file std_data/corrupt_t1.MYI $MYSQLD_DATADIR/test/t.MYI
+CHECK TABLE t;
+--replace_regex /[^']*test[^']*t/.\/test\/t/
+--error 145
+ALTER TABLE tp EXCHANGE PARTITION pCrashed WITH TABLE t;
+REPAIR TABLE t;
+CHECK TABLE t;
+ALTER TABLE tp EXCHANGE PARTITION pCrashed WITH TABLE t;
+CHECK TABLE tp;
+CHECK TABLE t;
+DROP TABLE t, tp;
+
--echo # test of non partitioned myisam for reference
CREATE TABLE t1_will_crash (a INT, KEY (a)) ENGINE=MyISAM;
INSERT INTO t1_will_crash VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10), (11);
@@ -151,8 +190,8 @@ eval INSERT INTO t1_will_crash VALUES
('6 row 7 (crash before completely written to datafile)', 27, '$lt$lt');
--enable_query_log
SELECT COUNT(*) FROM t1_will_crash;
-SELECT (b % 7) AS partition, COUNT(*) AS rows FROM t1_will_crash GROUP BY (b % 7);
-SELECT (b % 7) AS partition, b, a, length(c) FROM t1_will_crash ORDER BY partition, b, a;
+SELECT (b % 7) AS `partition`, COUNT(*) AS rows FROM t1_will_crash GROUP BY (b % 7);
+SELECT (b % 7) AS `partition`, b, a, length(c) FROM t1_will_crash ORDER BY `partition`, b, a;
FLUSH TABLES;
# testing p0, p1, p3, p6(1)
--echo # truncating p0 to simulate an empty datafile (not recovered!)
@@ -177,8 +216,8 @@ OPTIMIZE TABLE t1_will_crash;
CHECK TABLE t1_will_crash;
REPAIR TABLE t1_will_crash;
SELECT COUNT(*) FROM t1_will_crash;
-SELECT (b % 7) AS partition, COUNT(*) AS rows FROM t1_will_crash GROUP BY (b % 7);
-SELECT (b % 7) AS partition, b, a, length(c) FROM t1_will_crash ORDER BY partition, b, a;
+SELECT (b % 7) AS `partition`, COUNT(*) AS rows FROM t1_will_crash GROUP BY (b % 7);
+SELECT (b % 7) AS `partition`, b, a, length(c) FROM t1_will_crash ORDER BY `partition`, b, a;
FLUSH TABLES;
# testing p2, p4, p6(2, 3)
@@ -215,9 +254,9 @@ FLUSH TABLES;
#ALTER TABLE t1_will_crash OPTIMIZE PARTITION p6;
ALTER TABLE t1_will_crash CHECK PARTITION p6;
ALTER TABLE t1_will_crash REPAIR PARTITION p6;
-SELECT (b % 7) AS partition, b, a, length(c) FROM t1_will_crash
+SELECT (b % 7) AS `partition`, b, a, length(c) FROM t1_will_crash
WHERE (b % 7) = 6
-ORDER BY partition, b, a;
+ORDER BY `partition`, b, a;
FLUSH TABLES;
--echo #
@@ -229,21 +268,21 @@ FLUSH TABLES;
--echo # table, depending if one reads via index or direct on datafile.
--echo # Since crash when reuse of deleted row space, CHECK MEDIUM or EXTENDED
--echo # is required (MEDIUM is default) to verify correct behavior!
-SELECT (b % 7) AS partition, b, a, length(c) FROM t1_will_crash
+SELECT (b % 7) AS `partition`, b, a, length(c) FROM t1_will_crash
WHERE (b % 7) = 6
-ORDER BY partition, b, a;
+ORDER BY `partition`, b, a;
SET @save_optimizer_switch= @@optimizer_switch;
SET @@optimizer_switch='derived_merge=off';
-SELECT (b % 7) AS partition, b, a FROM (SELECT b,a FROM t1_will_crash) q
+SELECT (b % 7) AS `partition`, b, a FROM (SELECT b,a FROM t1_will_crash) q
WHERE (b % 7) = 6
-ORDER BY partition, b, a;
+ORDER BY `partition`, b, a;
SET @@optimizer_switch=@save_optimizer_switch;
# NOTE: REBUILD PARTITION without CHECK before, 2 + (1) records will be lost!
#ALTER TABLE t1_will_crash REBUILD PARTITION p6;
ALTER TABLE t1_will_crash CHECK PARTITION p6;
ALTER TABLE t1_will_crash REPAIR PARTITION p6;
SELECT COUNT(*) FROM t1_will_crash;
-SELECT (b % 7) AS partition, COUNT(*) AS rows FROM t1_will_crash GROUP BY (b % 7);
-SELECT (b % 7) AS partition, b, a, length(c) FROM t1_will_crash ORDER BY partition, b, a;
+SELECT (b % 7) AS `partition`, COUNT(*) AS rows FROM t1_will_crash GROUP BY (b % 7);
+SELECT (b % 7) AS `partition`, b, a, length(c) FROM t1_will_crash ORDER BY `partition`, b, a;
ALTER TABLE t1_will_crash CHECK PARTITION all EXTENDED;
DROP TABLE t1_will_crash;